Deployments

Manage Traffic

PATCH/v1/deployments/{slug}/traffic

Manage challenger models and traffic allocation for a deployment. This endpoint supports adding challengers for A/B testing, removing challengers, updating traffic percentages, and toggling shadow mode for silent scoring comparison.

Authentication: JWT token. Requires role: owner or admin.

Path Parameters

slugstringrequired

The deployment slug (e.g. dep_xK8m).

Body Parameters

actionstringrequired

The traffic management action to perform. One of:

  • add_challenger — Add a model as a challenger to receive a percentage of traffic
  • remove_challenger — Remove a challenger and redirect its traffic to the champion
  • update_traffic — Change the traffic percentage for an existing challenger
  • toggle_shadow — Enable or disable shadow mode
model_idstringconditional

Required for add_challenger. The model ID to add as a challenger.

challenger_idstringconditional

Required for remove_challenger and update_traffic. The challenger entry ID.

traffic_pctnumberconditional

Required for add_challenger and update_traffic. Percentage of traffic (1-50) to route to the challenger.

shadow_modebooleanconditional

Required for toggle_shadow. When true, challengers score requests silently without affecting the response.

Error Responses

401unauthorized

JWT is missing or expired.

404deployment_not_found

No deployment exists with the provided slug.

422invalid_traffic_config

Total challenger traffic would exceed 50%, or required parameters are missing for the action.

Manage Traffic
curl -X PATCH https://api.cali-br.com/v1/deployments/dep_xK8m/traffic \
  -H #a5d6ff">"Authorization: Bearer eyJhbGciOiJSUzI1NiIs..." \
  -H #a5d6ff">"Content-Type: application/json" \
  -d '{
    #a5d6ff">"action": "add_challenger",
    #a5d6ff">"model_id": "mod_nY5kT2Wq",
    #a5d6ff">"traffic_pct": 10
  }'
Response200
{
  "deployment_id": "dep_xK8m",
  "action": "add_challenger",
  "challenger": {
    "id": "ch_abc123",
    "model_id": "mod_nY5kT2Wq",
    "traffic_pct": 10,
    "is_active": true
  },
  "cache_version": 4
}