API reference for transfer variable callbacks
1. API overview
When the variable assignment mode of the transfer configuration is callback mode (CALLBACK), the system initiates an HTTP POST request to the customer-configured callbackUrl before the transfer to retrieve transfer variables, such as the called number and skill group ID. Implement the callback service as described in this document.
Item | Description |
Request method |
|
Content-Type |
|
Accept |
|
URL | The |
Timeout | The |
2. Request description
2.1 Request headers
Header | Type | Required | Description |
| String | Yes | Fixed value: |
| String | Yes | Fixed value: |
| String | Yes | The current timestamp in milliseconds, used for signature verification. |
| String | Yes | The authentication signature. |
2.2 Request body
Field name | Type | Required | Description |
| String | Yes | The unique call identifier. |
| String | No | The external business ID on the customer side. This field is not sent when it is empty. |
| String | Yes | The calling number. |
| String | Yes | The called number. |
Request body example:
{
"callId": "100025530001^105980150002",
"outId": "biz-order-20260831001",
"caller": "18612345678",
"callee": "4006007006"
}
Request body example without outId:
{
"callId": "100025530001^105980150002",
"caller": "18612345678",
"callee": "4006007006"
}
3. Response description
3.1 Response requirements
The HTTP status code must be 200.
The response body must not be empty and must be in JSON format.
3.2 Response body
Field name | Type | Required | Description |
| Boolean | Yes | Indicates whether transfer is allowed. This field must be a JSON Boolean (
|
| String | No | All fields except |
3.3 Variable value constraints
Constraint | Limit | Handling |
Maximum length of a single variable value | 150 characters | The excess is truncated and a warning log is written. |
Maximum total length of all variable values | 150 characters | The whole response is invalidated and treated as a callback failure if this limit is exceeded. |
Fields with | — | Automatically skipped and not added to the variable map. |
3.4 Response examples
Allow transfer:
{
"canTransfer": true,
"calledNumber": "057188889999",
"transferType": "SKILL_GROUP",
"transferBizId": "9000",
"customerId": "C20260831"
}
In this response, calledNumber, transferType, transferBizId, and customerId are injected as transfer variables. You can reference them in SIP Headers or a called-number template by using ${calledNumber}, ${transferType}, and similar placeholders.
Reject transfer:
{
"canTransfer": false
}
4. Authentication signature
The system passes timestamp and auth in HTTP headers. Use the following algorithm to verify that the request source is valid.
Signature algorithm:
auth = MD5Hex( aliyunUid + callId + timestamp )
Parameter | Source | Description |
| Customer | The Alibaba Cloud account UID. |
| Request body | The unique call identifier. |
| Request header | A timestamp in milliseconds. |
Java verification example:
import org.apache.commons.codec.digest.DigestUtils;
public boolean verifyAuth(String auth, Long aliyunUid, String callId, String timestamp) {
String expected = DigestUtils.md5Hex(String.valueOf(aliyunUid) + callId + timestamp);
return expected.equals(auth);
}
5. curl examples
5.1 Request that includes outId
curl -X POST 'https://your-callback-server.com/transfer/variables' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'timestamp: 1725091200000' \
-H 'auth: a3f5b8c2d1e4f6a7b9c0d2e3f5a6b8c9' \
-d '{
"callId": "100025530001^105980150002",
"outId": "biz-order-20260831001",
"caller": "18612345678",
"callee": "4006007006"
}'
5.2 Request that does not include outId
curl -X POST 'https://your-callback-server.com/transfer/variables' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'timestamp: 1725091200000' \
-H 'auth: e7d2a1b3c5f8e0d4a6b9c2f1e3d5a7b0' \
-d '{
"callId": "100025530001^105980150002",
"caller": "18612345678",
"callee": "4006007006"
}'
5.3 Expected responses
Allow transfer (HTTP 200):
{
"canTransfer": true,
"calledNumber": "057188889999",
"transferType": "SKILL_GROUP",
"transferBizId": "9000"
}
Reject transfer (HTTP 200):
{
"canTransfer": false
}
6. Exception handling
The system treats the following conditions as callback failures and rejects the transfer. The AI continues the conversation with the customer.
Scenario | Description |
HTTP status code is not 200 | The response returns any non-200 status code, such as 4xx or 5xx. |
Response body is empty | The response returns an empty string or has no body. |
| The JSON does not contain |
| The value is the string |
Request times out | The request exceeds the configured timeout. The default is 500 ms. |
Total variable length exceeds the limit | The total length of all variable values still exceeds 150 characters after truncation. |
7. Notes
Response time: Return from the callback service within 500 ms whenever possible. A timeout causes the transfer to fail.
Idempotence: The same call can trigger multiple callbacks because of retries or other reasons. We recommend that the server implement idempotence.
canTransfertype: This field must be a native JSON Boolean (trueorfalse). String values are not accepted.Variable names: Variable names must match the
${variable}placeholders in the SIP Headers and called-number templates of the transfer configuration.Network Security: The callback URL cannot point to an internal network address unless the address is included in a whitelist. Otherwise, SSRF protection blocks the request.