A2P SDK
Getting started

Quick Start

Quick Start

This guide walks through the Direct Standard flow — the simplest path for businesses with a Tax ID registering their own brand.

Prerequisites

  • Twilio account with A2P 10DLC enabled
  • Business Tax ID (EIN for US, CBN for Canada)
  • A Primary Customer Profile already approved in Trust Hub (create via Twilio Console)

Step 1: Create Customer Profile

First, gather your business information and create a Customer Profile:

import { A2PClient, flows } from '@warp-message/a2p-sdk';

const client = new A2PClient({
  accountSid: process.env.TWILIO_ACCOUNT_SID!,
  authToken: process.env.TWILIO_AUTH_TOKEN!,
});

// Step 1: Create Customer Profile
const step1Result = await flows.directStandard.step1_createCustomerProfile(client, {
  email: 'compliance@example.com',
  businessName: 'Example Corp',
  businessAttributes: {
    business_name: 'Example Corp',
    business_type: 'Corporation',
    business_industry: 'TECHNOLOGY',
    business_registration_identifier: 'EIN',
    business_registration_number: '12-3456789',
    website_url: 'https://example.com',
    business_identity: 'direct_customer',
    business_regions_of_operation: 'USA_AND_CANADA',
  },
  authorizedRep: {
    first_name: 'Jane',
    last_name: 'Doe',
    phone_number: '+15555551234',
    email: 'jane@example.com',
    job_position: 'CEO',
    business_title: 'Chief Executive Officer',
  },
  address: {
    city: 'San Francisco',
    customerName: 'Example Corp',
    isoCountry: 'US',
    postalCode: '94102',
    region: 'CA',
    street: '123 Main St',
  },
});

console.log('Customer Profile:', step1Result.sids.customerProfile);
// Wait for Customer Profile to be approved (up to 72 hours)
// Check status via Twilio Console or use webhooks

Step 2: Register Brand

Once your Customer Profile is approved, register your brand with The Campaign Registry:

const step2Result = await flows.directStandard.step2_registerBrand(client, {
  businessName: 'Example Corp',
  email: 'compliance@example.com',
  customerProfileSid: step1Result.state.customerProfileSid!,
  brandContactEmail: 'support@example.com', // Required since Oct 2024
  a2pMessagingProfile: {
    company_type: 'private',
  },
});

console.log('Brand Registration:', step2Result.sids.brand);
// Brand review typically takes minutes to 7+ business days
// Poll or use webhooks to check when status becomes APPROVED

Step 3: Create Campaign

Once your brand is approved, create a campaign:

const step3Result = await flows.directStandard.step3_createCampaign(client, {
  brandRegistrationSid: step2Result.state.brandSid!,
  messagingServiceName: 'Example Notifications',
  campaign: {
    description: 'Order confirmations, shipping updates, and account notifications for Example Corp customers',
    messageFlow: 'Users receive messages after making a purchase or when their account status changes. Messages include order numbers, tracking links, and account alerts.',
    messageSamples: [
      'Your order #12345 has shipped! Track it here: https://example.com/track/67890',
      'Your account password was changed. If this wasn\'t you, contact support immediately.',
    ],
    usAppToPersonUsecase: 'ACCOUNT_NOTIFICATION',
    hasEmbeddedLinks: true,
    hasEmbeddedPhone: false,
    optInMessage: 'Reply YES to receive order and account notifications from Example Corp.',
    optOutMessage: 'Reply STOP to unsubscribe from Example Corp notifications.',
    helpMessage: 'Reply HELP for support. Msg&data rates may apply.',
  },
  phoneNumberSids: ['+15555556789'], // Optional: add phone numbers now or later
});

console.log('Campaign:', step3Result.sids.campaign);
// Manual vetting takes 10-15 business days
// Use webhooks to receive status updates

Handling Results

Each step returns a StepResult with:

interface StepResult {
  success: boolean;              // Whether the step completed
  state: Partial<RegistrationState>; // Partial state updates
  sids: Record<string, string>;  // Resource SIDs for reference
}

Error Handling

Wrap calls in try/catch to handle errors:

try {
  const result = await flows.directStandard.step1_createCustomerProfile(client, input);
  console.log('Success:', result.sids);
} catch (error) {
  if (error instanceof A2PRegistrationError) {
    console.error('Registration failed:', error.step, error.guidance);
  } else {
    console.error('Unexpected error:', error);
  }
}

See Error Handling for detailed error recovery patterns.

Next Steps

On this page