Before you start
Create a custom metric for the outcome you want to compare. Assign the metric before you start the test so Cartesia evaluates calls from every version. You also need at least two versions of the same managed agent. Publish a change in the Playground or update the agent to create a version. Then list the agent’s versions and copy theirid values. You do not need to deploy managed versions before you add them to an allocation.
Split traffic between versions
CallPUT /agents/{agent_id}/traffic-allocation with one to five unique version IDs. Percentages can use up to two decimal places and must total 100.
Each successful PUT creates an immutable allocation revision. New calls use the latest revision. To inspect it, call GET /agents/{agent_id}/traffic-allocation.
Choose how phone calls are assigned
Setassignment_strategy based on how you want phone calls to reach the versions in your traffic split:
sticky_by_callerkeeps an external phone number on the same version while the traffic split stays the same. Cartesia uses the caller number for inbound calls and the destination number for outbound calls. This is the default.random_per_callassigns each new phone call separately. Calls from the same phone number can reach different versions, which helps when you test with only a few phone numbers.
assignment_strategy does not affect them.
When you create an allocation, omitting assignment_strategy uses sticky_by_caller. When you replace an active allocation, omitting the field preserves its current strategy. Set the field explicitly when you want to change strategies.
Supply variables for every version
Cartesia validates dynamic variables after it selects a version for a web session or batch recipient. If the selected version’s initial message needs a missing value, the web session ends or the batch recipient fails witherror_code: missing_dynamic_variables.
Supply the variables required by every version in the allocation. See Dynamic variables for request examples.
Move a change from staging to production
- Use Preview to test the draft without changing live calls.
- Before publishing the candidate, set the current production version to
100percent in the traffic allocation. - Publish the candidate, then update the allocation to send it a small percentage of live calls.
- Compare the results. Move the candidate to
100percent if it wins, or return the production version to100percent.
Compare results
GET /agents/calls returns the selected agent_version_id and the traffic_allocation_id used for each call. Group calls by agent_version_id, then use each call’s ID to compare its metric results.
GET /agents/{agent_id}/traffic-allocations to retrieve the targets and percentages for earlier revisions.
Change or end a test
Send anotherPUT request to change the percentages. To keep the winning version in use as you publish new versions, set its percentage to 100 and leave the allocation active. New versions receive no traffic until you update or clear the allocation.
To return to the default routing behavior, call DELETE /agents/{agent_id}/traffic-allocation. New calls then use the latest published version, including any versions that you publish later.
If the winning version is older, you can make it the published default before clearing the allocation. Get that version and pass its config to Update Agent. The update creates a new published version.
Clearing an allocation does not delete its history. It records an empty revision, and the current-allocation endpoint returns 404 until you create another allocation.