Connect a WhatsApp business account
Connect a WhatsApp business account. Request: POST /v1/whatsapp/business-accounts. Scope: whatsappAccounts:create.
POST
Completes embedded signup: exchanges its code for the business's Meta token, checks the token grants Samva both WhatsApp permissions over the WABA, subscribes Samva to the WABA's webhooks, and registers the phone number with the Cloud API. A number that stays on the WhatsApp Business app (coexistence) is already registered, so it skips registration and Samva asks Meta to sync its contacts and chat history. A number Meta has not verified yet connects as pending; sync it once verification finishes.
apiKeyheader
x-api-key<token>application/json- body
code*stringLength
1 <= lengthwabaId*stringLength
1 <= lengthphoneNumberId*stringLength
1 <= lengthnamespaceId?|nullSuccess
application/json- response
id*WhatsAppBusinessAccountIdMatch
^waba_[0-9a-hjkmnp-tv-z]{16,24}$organizationId*stringnamespaceId*|nullphoneNumber*stringphoneNumberId*stringdisplayName*stringwhatsappBusinessAccountId*stringverificationStatus*stringValue in
"pending""verified""failed""suspended"credentialStatus*stringValue in
"active""reconnect_required"tokenExpiresAt*string|nullisDefault*booleanwebhookUrl*string|nullqualityRating*stringValue in
"green""yellow""red""unknown"messagingLimit*string|nullcurrentLimit*integerRange
0 <= value <= 9007199254740991businessPortfolioId*string|nullbusinessAppConnectedAt*string|nullbusinessAppDisconnectedAt*string|nullbusinessAppDisconnectReason*|nullcontactsSyncRequestedAt*string|nullhistorySyncStatus*|nullhistorySyncProgress*|nullisActive*booleancreatedAt*stringupdatedAt*stringimport { createClient } from "samva";
const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
const result = await samva.whatsapp.connectBusinessAccount({
"code": "example",
"wabaId": "example",
"phoneNumberId": "example"
});Example Response
{
"id": "string",
"organizationId": "string",
"namespaceId": "string",
"phoneNumber": "string",
"phoneNumberId": "string",
"displayName": "string",
"whatsappBusinessAccountId": "string",
"verificationStatus": "pending",
"credentialStatus": "active",
"tokenExpiresAt": "string",
"isDefault": true,
"webhookUrl": "string",
"qualityRating": "green",
"messagingLimit": "string",
"currentLimit": 0,
"businessPortfolioId": "string",
"businessAppConnectedAt": "string",
"businessAppDisconnectedAt": "string",
"businessAppDisconnectReason": "partnerRemoved",
"contactsSyncRequestedAt": "string",
"historySyncStatus": "requested",
"historySyncProgress": 0,
"isActive": true,
"createdAt": "string",
"updatedAt": "string"
}