Skip to content

createTwilioClient

function createTwilioClient(options): Twilio;

Defined in: lib/utils/twilio.utils.ts:174

Build a Twilio SDK client from module options.

The SDK constructor is new Twilio(username, password, opts). Which values those are depends on the authentication mode:

  • Auth token: username is the Account SID, password the auth token.
  • API key: username is the API Key SID (SK…), password is the key’s secret, and the Account SID is supplied through opts.accountSid.

Module-level keys the SDK has no concept of are stripped; everything else is forwarded as ClientOpts.

Parameter Type
options TwilioModuleOptions & Partial<{ }>

Twilio

BadRequestException When required credentials are missing or malformed.

Auth token

createTwilioClient({ accountSid: 'ACxxx', authToken: 'token', region: 'ie1' });

API key, which is also what access tokens are signed with

createTwilioClient({ accountSid: 'ACxxx', apiKey: 'SKxxx', apiSecret: 'secret' });