Skip to Content

Connect a WhatsApp business account

Connect a WhatsApp business account. Request: POST /v1/whatsapp/business-accounts. Scope: whatsappAccounts:create.

POST
/v1/whatsapp/business-accounts

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.

Authorization

apiKey
headerx-api-key<token>

Request Body

application/json
  1. body
code*string
Length1 <= length
wabaId*string
Length1 <= length
phoneNumberId*string
Length1 <= length
namespaceId?|null

Response Body

Success

application/json
  1. response
id*WhatsAppBusinessAccountId
Match^waba_[0-9a-hjkmnp-tv-z]{16,24}$
organizationId*string
namespaceId*|null
phoneNumber*string
phoneNumberId*string
displayName*string
whatsappBusinessAccountId*string
verificationStatus*string
Value in"pending""verified""failed""suspended"
credentialStatus*string
Value in"active""reconnect_required"
tokenExpiresAt*string|null
isDefault*boolean
webhookUrl*string|null
qualityRating*string
Value in"green""yellow""red""unknown"
messagingLimit*string|null
currentLimit*integer
Range0 <= value <= 9007199254740991
businessPortfolioId*string|null
businessAppConnectedAt*string|null
businessAppDisconnectedAt*string|null
businessAppDisconnectReason*|null
contactsSyncRequestedAt*string|null
historySyncStatus*|null
historySyncProgress*|null
isActive*boolean
createdAt*string
updatedAt*string
Example Request
import { 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"
}

Related documentation