Skip to main content
The SDK has two clients. Most integrations create both with the same key. Both clients accept a team key or a project credential: A key only reaches what its permissions allow. Each task page lists the permissions its methods need. See API keys for how to create keys. The examples in these guides use three clients named platform, project, and messaging, created as shown below.

Create a team client

A team client reaches every project in the team. Methods that act on one project take a projectId argument.

Work inside one project

Call project(projectId) to get a client bound to one project:
A project client has the project-level resources: events, webhooks, webhookDeliveries, operations, flows, sipTrunks, calls, quickLinkSettings, sessionConfiguration, usage, and callRetention. Team resources such as projects, members, billing, customers, and campaigns stay on the team client. With a project credential, create the project client directly:
The API checks that the credential belongs to that project.

Create a messaging client

Use { type: "projectToken", value } for a project credential. Messaging methods take the Number as their first argument, for example messaging.messages.send("<number-id>", ...).

Client options

Both clients accept these options:

Set the API version

apiVersion is the API contract date, in YYYY-MM-DD format. It is separate from the package version. Pin it so a new API version cannot change response shapes under you. Read API versioning for supported dates. You can override it for one request:

Set request options

Every method takes an optional last argument with per-request options:

Read a response

Methods that return one result resolve to { data, metadata }:
  • data is the parsed response body. Most bodies wrap the result in their own data field, so you read response.data.data. The return type tells you which shape each method has.
  • metadata holds the HTTP status, the requestId, the resolved apiVersion, the number of attempts, and the response headers.
Include requestId when you contact support. Lists of events, webhooks, deliveries, operations, call records, and call opt-outs return a page object instead. See Read every page.

Give a browser a client token

Browser and mobile code must not hold a team key or project credential. Mint a short-lived client token on your server and send it to the browser:
The token can use only the actions allowed by the Number’s client rules. Read and change the rules with clientTokens.retrieveRules and clientTokens.updateRules. Minting needs all of these permissions: sessions:manage, messages:write, contacts:read, presence:read, presence:observe, and mcp. See Client tokens.

Call an endpoint without an SDK method

raw.request sends an authenticated request to any API path. It uses the client’s credential, API version, timeout, and retry settings:
A project client confines raw.request to its own project.

Check API status

SystemClient needs no credential. Use it in health checks:
It also has status(), health(), and ping().

Resources on each client

Client (team): MessagingClient: The API reference documents every endpoint behind these methods.