breakers
Configure circuit breakers for a project. Breakers evaluate metric rules and trigger actions as they trip and recover.
GET
/v1/projects/:project_id/breakers
List all breakers for a project
Auth:
User API key
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
project_id |
path | uuid | Yes | Project ID |
Responses
200
List of breakers
breakerscounthashupdated_at
Headers:
ETag: Weak ETag for conditional requests
304
Not modified (ETag match)
Example
Request
curl https://api.tripswitch.dev/v1/projects/PROJECT_ID/breakers \
-H "Authorization: Bearer YOUR_USER_API_KEY"
Response
{
"breakers": [
{
"id": "660e8400-e29b-41d4-a716-446655440001",
"name": "API Latency",
"metric": "api.latency_ms",
"kind": "p95",
"op": "gt",
"threshold": 500,
"window_ms": 60000,
"min_state_duration_ms": 60000,
"cooldown_ms": 300000,
"router_id": "550e8400-e29b-41d4-a716-446655440000"
}
],
"hash": "abc123",
"updated_at": "2024-01-15T10:30:00",
"count": 1
}
GET
/v1/projects/:project_id/breakers/:breaker_id
Get a single breaker
Auth:
User API key
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
project_id |
path | uuid | Yes | Project ID |
breaker_id |
path | uuid | Yes | Breaker ID |
Responses
200
Breaker details
breakerrouter_id
404
Breaker not found
Example
Request
curl https://api.tripswitch.dev/v1/projects/PROJECT_ID/breakers/BREAKER_ID \
-H "Authorization: Bearer YOUR_USER_API_KEY"
Response
{
"breaker": {
"id": "660e8400-e29b-41d4-a716-446655440001",
"name": "API Latency",
"metric": "api.latency_ms",
"kind": "p95",
"op": "gt",
"threshold": 500,
"window_ms": 60000,
"min_state_duration_ms": 60000,
"cooldown_ms": 0
},
"router_id": "550e8400-e29b-41d4-a716-446655440000"
}
POST
/v1/projects/:project_id/breakers
Create a single breaker
Auth:
User API key
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
project_id |
path | uuid | Yes | Project ID |
Request Body
kind
*
metric
*
op
*
threshold
*
actions
cooldown_ms
eval_interval_ms
half_open_backoff_cap_ms
half_open_backoff_enabled
half_open_confirmation_ms
half_open_indeterminate_policy
id
kind_params
metadata
min_count
min_state_duration_ms
name
window_ms
Responses
201
Breaker created
breakerrouter_id
409
Breaker with this ID already exists
422
Validation failed
Example
Request
curl -X POST https://api.tripswitch.dev/v1/projects/PROJECT_ID/breakers \
-H "Authorization: Bearer YOUR_USER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "API Latency",
"metric": "api.latency_ms",
"kind": "p95",
"op": "gt",
"threshold": 500,
"window_ms": 60000
}'
Response
{
"breaker": {
"id": "660e8400-e29b-41d4-a716-446655440001",
"name": "API Latency",
"metric": "api.latency_ms",
"kind": "p95",
"op": "gt",
"threshold": 500,
"window_ms": 60000,
"min_state_duration_ms": 60000,
"cooldown_ms": 0
},
"router_id": "550e8400-e29b-41d4-a716-446655440000"
}
PATCH
/v1/projects/:project_id/breakers/:breaker_id
Update a breaker
Auth:
User API key
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
project_id |
path | uuid | Yes | Project ID |
breaker_id |
path | uuid | Yes | Breaker ID |
Request Body
actions
cooldown_ms
eval_interval_ms
half_open_backoff_cap_ms
half_open_backoff_enabled
half_open_confirmation_ms
half_open_indeterminate_policy
kind
kind_params
metadata
metric
min_count
min_state_duration_ms
name
op
threshold
window_ms
Responses
200
Breaker updated
breaker
404
Breaker not found
422
Validation failed
Example
Request
curl -X PATCH https://api.tripswitch.dev/v1/projects/PROJECT_ID/breakers/BREAKER_ID \
-H "Authorization: Bearer YOUR_USER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"threshold": 750}'
Response
{
"breaker": {
"id": "660e8400-e29b-41d4-a716-446655440001",
"name": "API Latency",
"metric": "api.latency_ms",
"kind": "p95",
"op": "gt",
"threshold": 750,
"window_ms": 60000
}
}
PUT
/v1/projects/:project_id/breakers
Replace all breakers (bulk sync)
Auth:
User API key
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
project_id |
path | uuid | Yes | Project ID |
Request Body
breakers
*
Responses
200
Breakers replaced
changedcountduration_mshash
409
Guardrail blocked destructive change
412
Precondition failed (If-Match header mismatch)
422
Validation failed
Example
Request
curl -X PUT https://api.tripswitch.dev/v1/projects/PROJECT_ID/breakers \
-H "Authorization: Bearer YOUR_USER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"breakers": [
{"name": "API Latency", "metric": "api.latency_ms", "kind": "p95", "op": "gt", "threshold": 500}
]
}'
Response
{
"changed": true,
"count": 1,
"hash": "abc123",
"duration_ms": 45
}
DELETE
/v1/projects/:project_id/breakers/:breaker_id
Delete a breaker
Auth:
User API key
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
project_id |
path | uuid | Yes | Project ID |
breaker_id |
path | uuid | Yes | Breaker ID |
Responses
204
Breaker deleted
404
Breaker not found
Example
Request
curl -X DELETE https://api.tripswitch.dev/v1/projects/PROJECT_ID/breakers/BREAKER_ID \
-H "Authorization: Bearer YOUR_USER_API_KEY"
Response
(empty body, 204 No Content)
POST
/v1/projects/:project_id/breakers/state:batch
Get current state of multiple breakers
Auth:
User API key
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
project_id |
path | uuid | Yes | Project ID |
Request Body
breaker_ids
router_ids
Responses
200
Batch state lookup
states
422
Validation failed (must provide breaker_ids or router_ids)
Example
Response
{
"states": [
{
"breaker_id": "660e8400-e29b-41d4-a716-446655440001",
"state": "closed",
"evaluated_at_ms": 1705312300000,
"sample_count": 42,
"min_count": 10,
"window_ms": 60000,
"observed": true,
"threshold": 0.05,
"reason_code": null
},
{
"breaker_id": "660e8400-e29b-41d4-a716-446655440002",
"state": "open",
"evaluated_at_ms": 1705312300000,
"sample_count": 15,
"min_count": 10,
"window_ms": 60000,
"observed": true,
"threshold": 0.05,
"reason_code": "threshold_exceeded"
}
]
}
GET
/v1/projects/:project_id/breakers/:breaker_id/state
Get current state of a single breaker
Auth:
User API key
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
project_id |
path | uuid | Yes | Project ID |
breaker_id |
path | uuid | Yes | Breaker ID |
Responses
200
Breaker state lookup
breaker_idindeterminateindeterminate_reasonlast_eval_msnamenext_eval_msstatestate_since_ms
404
Breaker not found
Example
Request
curl https://api.tripswitch.dev/v1/projects/PROJECT_ID/breakers/BREAKER_ID/state \
-H "Authorization: Bearer YOUR_USER_API_KEY"
GET
/v1/projects/:project_id/breakers/state:stream
SSE stream of breaker state changes (SDK endpoint)
Auth:
User API key
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
project_id |
path | uuid | Yes | Project ID |
Responses
200
Server-Sent Events stream
Headers:
Cache-Control: no-cache
Connection: keep-alive
Content-Type: text/event-stream
Example
Request
curl -N https://api.tripswitch.dev/v1/projects/PROJECT_ID/breakers/state:stream \
-H "Authorization: Bearer YOUR_USER_API_KEY"
Response
event: state
data: {"breaker": "checkout", "state": "closed", "allow_rate": null}
event: state
data: {"breaker": "payment", "state": "open", "allow_rate": null}
: heartbeat
event: state
data: {"breaker": "checkout", "state": "open", "allow_rate": null}