Follow these best practices to build reliable, low-latency integrations with the AgentPhone API.
Streaming is the single biggest improvement you can make to perceived voice latency. Instead of making the caller wait in silence for your full response, send an interim chunk immediately and let TTS start speaking while your server continues processing.
Content-Type: application/x-ndjson so TTS can start on the first chunk."interim": true is spoken immediately.If your webhook calls an LLM with tools (e.g., calendar lookup, database query, CRM search), the total round-trip can add up quickly: LLM decides to call a tool (~1-3s) + external API responds (~1-5s) + LLM summarises (~1-3s). Always stream {"text": "Let me check on that.", "interim": true} as your first NDJSON line so the caller hears something immediately while your tools run in the background.
See the Calls guide for the full streaming response format, tool-calling examples, and troubleshooting tips.
X-Webhook-Signature and X-Webhook-Timestamp headers to ensure requests are from AgentPhone.See Webhooks > Security for verification code examples.
200 OK quickly — process webhooks asynchronously if your handler needs to do heavy work. Slow responses trigger retries.X-Webhook-ID header for idempotency. Retries can cause the same event to be delivered multiple times.GET /v1/webhooks/deliveries to monitor delivery status.Most list endpoints support offset-based pagination with limit and offset parameters. Message endpoints use cursor-based pagination with before and after timestamps.
Always check hasMore before fetching the next page. Use cursor-based pagination for time-ordered data as it’s more efficient than offset-based.
GET /v1/calls/:id/transcript/stream delivers turns in real time as a Server-Sent Events stream. No polling needed. See Calls > Stream transcript (SSE).before/after) for loading message history.Retry-After header on 429 responses.429, 500, 502).details array for field-level errors.See the Error Handling page for the full error response format and code examples.