Routes API
Routes connect sources to destinations.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/organizations/{orgId}/routes | List routes |
| POST | /api/organizations/{orgId}/routes | Create route |
| GET | /api/organizations/{orgId}/routes/{id} | Get route |
| PATCH | /api/organizations/{orgId}/routes/{id} | Update route |
| DELETE | /api/organizations/{orgId}/routes/{id} | Delete route |
Route Object
json
{
"id": "rte_abc123",
"name": "GitHub to Slack",
"description": "Forward GitHub events to Slack",
"sourceId": "src_xyz789",
"destinationIds": ["dst_slack1", "dst_slack2"],
"transformId": "tfm_format123",
"filterId": "flt_pushonly456",
"enabled": true,
"source": {
"id": "src_xyz789",
"name": "GitHub"
},
"destinations": [
{"id": "dst_slack1", "name": "Slack #dev"},
{"id": "dst_slack2", "name": "Slack #alerts"}
],
"transform": {
"id": "tfm_format123",
"name": "Slack Formatter"
},
"filter": {
"id": "flt_pushonly456",
"name": "Push Events Only"
},
"eventsRouted": 1523,
"lastEventAt": "2024-01-15T10:30:00Z",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}List Routes
http
GET /api/organizations/{orgId}/routesQuery Parameters
| Parameter | Type | Description |
|---|---|---|
| page | number | Page number (default: 1) |
| pageSize | number | Items per page (default: 20, max: 100) |
| enabled | boolean | Filter by enabled status |
| sourceId | string | Filter by source |
| destinationId | string | Filter by destination |
Example
bash
curl https://api.webhookrelay.com/api/organizations/org_123/routes \
-H "Authorization: Bearer YOUR_TOKEN"Response
json
{
"data": [
{
"id": "rte_abc123",
"name": "GitHub to Slack",
"sourceId": "src_xyz789",
"destinationIds": ["dst_slack1"],
"enabled": true,
"eventsRouted": 1523,
"source": {"id": "src_xyz789", "name": "GitHub"},
"destinations": [{"id": "dst_slack1", "name": "Slack #dev"}]
}
],
"pagination": {
"total": 5,
"page": 1,
"pageSize": 20
}
}Create Route
http
POST /api/organizations/{orgId}/routesRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Display name |
| sourceId | string | Yes | Source ID to listen to |
| destinationIds | string[] | Yes | Array of destination IDs |
| description | string | No | Optional description |
| transformId | string | No | Transform to apply |
| filterId | string | No | Filter to evaluate |
| enabled | boolean | No | Active status (default: true) |
Example
bash
curl -X POST https://api.webhookrelay.com/api/organizations/org_123/routes \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "GitHub to Slack",
"sourceId": "src_xyz789",
"destinationIds": ["dst_slack1", "dst_slack2"],
"transformId": "tfm_format123",
"filterId": "flt_pushonly456"
}'Response
json
{
"id": "rte_new123",
"name": "GitHub to Slack",
"sourceId": "src_xyz789",
"destinationIds": ["dst_slack1", "dst_slack2"],
"transformId": "tfm_format123",
"filterId": "flt_pushonly456",
"enabled": true,
"eventsRouted": 0,
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}Get Route
http
GET /api/organizations/{orgId}/routes/{id}Example
bash
curl https://api.webhookrelay.com/api/organizations/org_123/routes/rte_abc123 \
-H "Authorization: Bearer YOUR_TOKEN"Response
Returns the full route object with expanded source, destinations, transform, and filter.
Update Route
http
PATCH /api/organizations/{orgId}/routes/{id}Request Body
All fields are optional. Only provided fields are updated.
| Field | Type | Description |
|---|---|---|
| name | string | Display name |
| destinationIds | string[] | Array of destination IDs |
| description | string | Optional description |
| transformId | string | Transform ID (null to remove) |
| filterId | string | Filter ID (null to remove) |
| enabled | boolean | Active status |
WARNING
The sourceId cannot be changed after creation. Create a new route instead.
Example
bash
curl -X PATCH https://api.webhookrelay.com/api/organizations/org_123/routes/rte_abc123 \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"enabled": false,
"filterId": null
}'Response
Returns the updated route object.
Delete Route
http
DELETE /api/organizations/{orgId}/routes/{id}INFO
Deleting a route does not delete the source, destinations, transform, or filter.
Example
bash
curl -X DELETE https://api.webhookrelay.com/api/organizations/org_123/routes/rte_abc123 \
-H "Authorization: Bearer YOUR_TOKEN"Response
204 No ContentRoute Statistics
Get statistics for a route:
http
GET /api/organizations/{orgId}/routes/{id}/statsQuery Parameters
| Parameter | Type | Description |
|---|---|---|
| period | string | Time period: 1h, 24h, 7d, 30d |
Response
json
{
"eventsRouted": 1523,
"eventsFiltered": 234,
"deliveriesSucceeded": 1489,
"deliveriesFailed": 34,
"avgLatency": 245,
"period": "24h"
}Error Responses
400 Bad Request
Invalid source or destination:
json
{
"error": "Bad Request",
"message": "Source with ID src_invalid not found",
"code": "INVALID_SOURCE"
}404 Not Found
Route not found:
json
{
"error": "Not Found",
"message": "Route with ID rte_xyz not found",
"code": "RESOURCE_NOT_FOUND"
}409 Conflict
Duplicate route:
json
{
"error": "Conflict",
"message": "A route with this source and destinations already exists",
"code": "DUPLICATE_ROUTE"
}