routers API

routers

Manage routers that map router_id samples to one or more breakers (fan-in/fan-out).

GET /v1/projects/:project_id/routers

List all routers for a project

Auth: User API key

Parameters

Name In Type Required Description
project_id path uuid Yes Project ID

Responses

200 List of routers with breaker counts
routers
- Array of router objects

Example

Request
curl https://api.tripswitch.dev/v1/projects/PROJECT_ID/routers \
  -H "Authorization: Bearer YOUR_USER_API_KEY"
Response
{
  "routers": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "api-gateway",
      "mode": "static",
      "enabled": true,
      "created_by": "user",
      "breaker_count": 3,
      "inserted_at": "2024-01-15T10:30:00Z"
    }
  ]
}
GET /v1/projects/:project_id/routers/:router_id

Retrieve a router with linked breakers

Auth: User API key

Parameters

Name In Type Required Description
project_id path uuid Yes Project ID
router_id path uuid Yes Router ID

Responses

200 Router details with linked breakers
router
- Router object with breakers array
404 Router not found

Example

Request
curl https://api.tripswitch.dev/v1/projects/PROJECT_ID/routers/ROUTER_ID \
  -H "Authorization: Bearer YOUR_USER_API_KEY"
Response
{
  "router": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "api-gateway",
    "mode": "static",
    "enabled": true,
    "created_by": "user",
    "inserted_at": "2024-01-15T10:30:00Z",
    "breakers": [
      {"id": "660e8400-e29b-41d4-a716-446655440001", "name": "API Latency P95"}
    ]
  }
}
POST /v1/projects/:project_id/routers

Create a new router

Auth: User API key

Parameters

Name In Type Required Description
project_id path uuid Yes Project ID

Request Body

breaker_ids
array Breaker IDs to link on creation
mode
string Routing mode: static (default), canary, or weighted
name
string Human-readable router name

Responses

201 Router created
router
- Created router object with linked breakers
404 Project or breaker not found
422 Validation failed

Example

Request
curl -X POST https://api.tripswitch.dev/v1/projects/PROJECT_ID/routers \
  -H "Authorization: Bearer YOUR_USER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "api-gateway",
    "breaker_ids": ["660e8400-e29b-41d4-a716-446655440001", "660e8400-e29b-41d4-a716-446655440002"]
  }'
Response
{
  "router": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "api-gateway",
    "mode": "static",
    "enabled": true,
    "created_by": "user",
    "inserted_at": "2024-01-15T10:30:00Z",
    "breakers": [
      {"id": "660e8400-e29b-41d4-a716-446655440001", "name": "API Latency P95"},
      {"id": "660e8400-e29b-41d4-a716-446655440002", "name": "API Error Rate"}
    ]
  }
}
PATCH /v1/projects/:project_id/routers/:router_id

Update router properties

Auth: User API key

Parameters

Name In Type Required Description
project_id path uuid Yes Project ID
router_id path uuid Yes Router ID

Request Body

enabled
boolean Enable or disable routing
mode
string Routing mode: static, canary, or weighted
name
string New router name

Responses

200 Router updated
router
- Updated router object
404 Router not found
422 Validation failed

Example

Request
curl -X PATCH https://api.tripswitch.dev/v1/projects/PROJECT_ID/routers/ROUTER_ID \
  -H "Authorization: Bearer YOUR_USER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "primary-api-gateway", "enabled": false}'
Response
{
  "router": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "primary-api-gateway",
    "mode": "static",
    "enabled": false,
    "created_by": "user",
    "inserted_at": "2024-01-15T10:30:00Z"
  }
}
DELETE /v1/projects/:project_id/routers/:router_id

Delete a router (must unlink breakers first)

Auth: User API key

Parameters

Name In Type Required Description
project_id path uuid Yes Project ID
router_id path uuid Yes Router ID

Responses

204 Router deleted
404 Router not found
409 Router has linked breakers (unlink them first)

Example

Request
curl -X DELETE https://api.tripswitch.dev/v1/projects/PROJECT_ID/routers/ROUTER_ID \
  -H "Authorization: Bearer YOUR_USER_API_KEY"
Response
(empty body, 204 No Content)