Agent Configuration Endpoint
The agent configuration endpoint lets you dynamically configure a conversation at the moment it
starts. When an agent has a configuration_endpoint set, Phonic sends a POST request to your
URL at the start of every conversation, and your endpoint returns configuration overrides for that
specific conversation.
This is primarily useful for inbound calls — for example, your endpoint can look up the inbound caller in your CRM and populate the welcome message with the caller’s information.
Setup
Add a configuration_endpoint to your agent (via the dashboard or the
Update Agent endpoint):
urlmust be a publicly routable HTTPS URL without embedded credentials.timeout_msmust be between1000and20000. Defaults to3000.
You can also set a configuration_endpoint on an individual custom phone number (see
Add Custom Phone Number and
Update Phone Number). For inbound calls to that number,
the phone number’s endpoint is used instead of the agent’s.
Request payload
Phonic sends a JSON body with the following fields:
The project the conversation belongs to. Contains name (string).
A subset of the Agent for this conversation. Contains name,
welcome_message, voice_id, additional_voice_ids, system_prompt, tools (tool names as
strings), tasks (objects with name and description), and boosted_keywords. null when the
conversation has no agent (for example, a WebSocket conversation started with a
configuration_endpoint in its config instead of an agent).
Template variables already provided for the conversation (for example, in the WebSocket config or
the outbound call request). Always includes system_conversation_timezone.
Unique ID for the conversation.
Caller’s phone number in E.164 format. Present for inbound and outbound phone calls.
Phone number that was called in E.164 format. Present for inbound and outbound phone calls.
Present when using SIP trunking with a custom phone number — the Twilio Call SID in your Twilio environment.
Response payload
Your endpoint returns a JSON object. Every field is optional — any field you return
overrides the agent’s configured value for that conversation, and any field you omit falls back to
the agent’s default. Return {} to make no changes. Fields set directly on the conversation (in the
WebSocket config or the outbound call request) take precedence over your endpoint’s response.
The response accepts the same configuration fields as the Create Agent endpoint — see it for descriptions of each field. The most commonly used fields are:
Message to play when the conversation starts. Can contain template variables. Ignored when
generate_welcome_message is true.
Instructions for the conversation. Can contain template variables.
Key-value pairs of template variables used in the welcome message and system prompt. See template variables.
The voice ID to use for the agent. See voices.
Built-in or custom tool names to make available to the assistant.
ISO 639-1 language code that sets the agent’s default language.
Additional ISO 639-1 language codes the agent should recognize and speak.
Arbitrary key-value metadata to associate with the conversation. Available to the system prompt as
the {{metadata}} template variable. If the system prompt uses {{metadata}}, the response must
include metadata. The welcome message can’t use {{metadata}}. See
the metadata variable.
The response is validated strictly: unknown fields are rejected. outbound_number_pool and
configuration_endpoint are not accepted, since they don’t apply once a conversation is
starting. agent and project are ignored.
Errors
If the endpoint call fails, the conversation ends instead of falling back to the agent’s configuration. The WebSocket is closed with one of these codes:
A voice_id or additional_voice_ids your organization can’t access also ends the conversation.
Example usage
Here’s an example of how to implement the endpoint: