Update PSTN Number Mappings

Link PSTN numbers to WhatsApp numbers and set who answers their incoming calls, for up to 500 numbers per request.

Sets, for many PSTN numbers in one request, which WhatsApp number each one is linked to and who answers its incoming calls: a team member or an AI agent. It does the same as editing a PSTN channel in the app (Channels → PSTN number → Edit channel details), for up to 500 numbers at a time.

Endpoint

POST https://public.doubletick.io/v1/call/pstn-mappings

Authentication

Pass your API key in the Authorization header.

HeaderValue
Authorization<your-api-key>
Content-Typeapplication/json

The API key's user needs permission to add channels, the same permission needed to edit a PSTN channel in the app.

📘

NOTE

If you do not have your DoubleTick API Key, you can obtain it by following this guide link.


Request Body

ParameterTypeRequiredDescription
mappingsarray of objectsYesOne object per PSTN number, 1 to 500 objects. Each object is described below.

Mapping Object

FieldTypeRequiredDescription
pstnNumberstringYesYour PSTN number, connected in your organization (e.g. +911234567890).
whatsappNumberstringYesYour WhatsApp number, connected in your organization, to link this PSTN number to. Calls on the PSTN number are logged in the customer's chat on this WhatsApp number (e.g. +919000000001).
agentNumberstringNoPhone number of the team member who should answer this number's incoming calls. Must match exactly one active member of your organization, and that member must have access to this PSTN number.
aiAgentNamestringNoExact name of the AI agent that should answer this number's incoming calls. The AI agent must be set up for voice calls.

🚧

Routing

Send at most one of agentNumber and aiAgentName in a mapping. If you send neither, only the linked WhatsApp number changes and the number keeps the incoming call routing it already has.

All phone numbers take the country code, with or without the leading +, 7 to 15 digits (e.g. +919876543210 or 919876543210).


Example Request

curl --request POST \
  --url https://public.doubletick.io/v1/call/pstn-mappings \
  --header 'Authorization: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "mappings": [
      {
        "pstnNumber": "+911234567890",
        "whatsappNumber": "+919000000001",
        "agentNumber": "+919812345678"
      },
      {
        "pstnNumber": "+911234567891",
        "whatsappNumber": "+919000000001",
        "aiAgentName": "Sales Agent"
      },
      {
        "pstnNumber": "+911234567892",
        "whatsappNumber": "+919000000002"
      }
    ]
  }'

Example Response

{
  "total": 3,
  "updated": 1,
  "unchanged": 1,
  "failed": 1,
  "results": [
    {
      "index": 0,
      "pstnNumber": "+911234567890",
      "status": "UPDATED"
    },
    {
      "index": 1,
      "pstnNumber": "+911234567891",
      "status": "UNCHANGED"
    },
    {
      "index": 2,
      "pstnNumber": "+911234567892",
      "status": "FAILED",
      "code": "WHATSAPP_NUMBER_NOT_FOUND",
      "message": "This WhatsApp number is not connected in your organization"
    }
  ]
}

📘

NOTE

A 200 means the request was read, even when some or all mappings failed. Check the counts and results to see what happened to each mapping.


Response Fields

FieldTypeDescription
totalnumberNumber of mappings in the request.
updatednumberMappings saved.
unchangednumberMappings that were already in place, so nothing was written.
failednumberMappings not saved.
resultsarrayOne entry per mapping, in the order sent.
results[].indexnumberPosition of the mapping in the request, starting at 0.
results[].pstnNumberstringThe pstnNumber as you sent it.
results[].statusstringUPDATED, UNCHANGED or FAILED.
results[].codestringOnly when FAILED: why (see Mapping Error Codes).
results[].messagestringOnly when FAILED: a readable reason.

Mapping Error Codes

These come back inside results for a mapping that failed. The other mappings in the request are still saved.

CodeDescription
INVALID_FIELDSA number is missing or not 7 to 15 digits, or both agentNumber and aiAgentName were sent. The message names the field.
DUPLICATE_PSTN_NUMBERThe same pstnNumber appears earlier in the request. Only the first mapping for a number is applied.
PSTN_NUMBER_NOT_FOUNDThe PSTN number is not connected in your organization.
PSTN_NUMBER_AMBIGUOUSThe PSTN number is connected more than once in your organization. Contact support.
WHATSAPP_NUMBER_NOT_FOUNDThe WhatsApp number is not connected in your organization.
WHATSAPP_NUMBER_AMBIGUOUSThe WhatsApp number is connected more than once in your organization. Contact support.
AGENT_NOT_FOUNDNo active team member of your organization has this agentNumber.
AGENT_AMBIGUOUSMore than one team member has this agentNumber. Contact support.
AGENT_NO_ACCESSThe team member does not have access to this PSTN number. Give them access to the PSTN channel, then send the mapping again.
AI_AGENT_NOT_FOUNDNo AI agent with this name is set up for voice calls in your organization.
AI_AGENT_AMBIGUOUSMore than one AI agent has this name. Rename one and try again.
AI_AGENT_CANNOT_TAKE_CALLSThis AI agent cannot answer incoming calls yet. Choose another AI agent or a team member, or contact support.
AI_AGENT_NOT_SUPPORTED_ON_NUMBERThis PSTN number does not support AI agents. Route it to a team member instead.
CHANGED_DURING_SAVEThe PSTN number was disconnected or removed while the request was running. Send the mapping again.

Error Responses

Status CodeDescription
400mappings is missing or empty, has more than 500 objects, an entry is not an object, an entry has a field the API does not know, or a field value is not a string. Nothing is saved.
401Invalid or missing API key.
403The API key's user does not have permission to add channels.
429Rate limit exceeded — 10 requests/minute per org, check the Retry-After header.
500The save failed and nothing was written. The same request can be sent again.

Things to Know

  • Up to 500 mappings per request. Split a longer list into several requests.
  • Each mapping is checked on its own. A failed mapping does not stop the others, and nothing is written for a failed mapping.
  • Sending the same request again is safe: mappings already in place come back UNCHANGED, so you only need to fix and resend the failed ones.
  • If you send neither agentNumber nor aiAgentName, the number's incoming call routing is kept as it is. This API never clears it.
  • agentNumber must match exactly one active member of your organization by phone number, and the member must have access to the PSTN number.
  • aiAgentName must match the AI agent's name exactly.
  • Changes apply from the next incoming call. Nothing needs to be restarted.
  • This endpoint only changes mappings. To place calls, use Initiate Agent Call or Initiate AI Bot Call.

Did this page help you?