Skip to content

Destinations API

Destinations are endpoints where webhooks get delivered.

Endpoints

MethodPathDescription
GET/api/organizations/{orgId}/destinationsList destinations
POST/api/organizations/{orgId}/destinationsCreate destination
GET/api/organizations/{orgId}/destinations/{id}Get destination
PATCH/api/organizations/{orgId}/destinations/{id}Update destination
DELETE/api/organizations/{orgId}/destinations/{id}Delete destination

Destination Object

json
{
  "id": "dst_xyz789",
  "name": "Production API",
  "url": "https://api.yourapp.com/webhooks",
  "description": "Main webhook handler",
  "headers": {
    "Authorization": "Bearer sk_live_xxx",
    "X-Custom-Header": "value"
  },
  "retryPolicy": {
    "maxRetries": 5,
    "initialDelay": 1000,
    "maxDelay": 60000,
    "backoffMultiplier": 2
  },
  "enabled": true,
  "successRate": 98.5,
  "avgLatency": 245,
  "deliveriesCount": 5230,
  "lastDeliveryAt": "2024-01-15T10:30:00Z",
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

List Destinations

http
GET /api/organizations/{orgId}/destinations

Query Parameters

ParameterTypeDescription
pagenumberPage number (default: 1)
pageSizenumberItems per page (default: 20, max: 100)
enabledbooleanFilter by enabled status
searchstringSearch by name or URL

Example

bash
curl https://api.webhookrelay.com/api/organizations/org_123/destinations \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

json
{
  "data": [
    {
      "id": "dst_xyz789",
      "name": "Production API",
      "url": "https://api.yourapp.com/webhooks",
      "enabled": true,
      "successRate": 98.5,
      "avgLatency": 245,
      "deliveriesCount": 5230
    }
  ],
  "pagination": {
    "total": 3,
    "page": 1,
    "pageSize": 20
  }
}

Create Destination

http
POST /api/organizations/{orgId}/destinations

Request Body

FieldTypeRequiredDescription
namestringYesDisplay name
urlstringYesDelivery URL (HTTPS recommended)
descriptionstringNoOptional description
headersobjectNoCustom headers to include
retryPolicyobjectNoRetry configuration
enabledbooleanNoActive status (default: true)

Retry Policy

FieldTypeDefaultDescription
maxRetriesnumber5Max retry attempts
initialDelaynumber1000First retry delay (ms)
maxDelaynumber60000Max delay between retries (ms)
backoffMultipliernumber2Exponential backoff multiplier

Example

bash
curl -X POST https://api.webhookrelay.com/api/organizations/org_123/destinations \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production API",
    "url": "https://api.yourapp.com/webhooks/handler",
    "headers": {
      "Authorization": "Bearer sk_live_xxx",
      "X-Source": "webhookrelay"
    },
    "retryPolicy": {
      "maxRetries": 5,
      "initialDelay": 1000,
      "maxDelay": 300000
    }
  }'

Response

json
{
  "id": "dst_new123",
  "name": "Production API",
  "url": "https://api.yourapp.com/webhooks/handler",
  "headers": {
    "Authorization": "Bearer sk_live_xxx",
    "X-Source": "webhookrelay"
  },
  "retryPolicy": {
    "maxRetries": 5,
    "initialDelay": 1000,
    "maxDelay": 300000,
    "backoffMultiplier": 2
  },
  "enabled": true,
  "successRate": null,
  "avgLatency": null,
  "deliveriesCount": 0,
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

Get Destination

http
GET /api/organizations/{orgId}/destinations/{id}

Example

bash
curl https://api.webhookrelay.com/api/organizations/org_123/destinations/dst_xyz789 \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

Returns the full destination object.

Update Destination

http
PATCH /api/organizations/{orgId}/destinations/{id}

Request Body

All fields are optional. Only provided fields are updated.

FieldTypeDescription
namestringDisplay name
urlstringDelivery URL
descriptionstringOptional description
headersobjectCustom headers (replaces existing)
retryPolicyobjectRetry configuration
enabledbooleanActive status

Example

bash
curl -X PATCH https://api.webhookrelay.com/api/organizations/org_123/destinations/dst_xyz789 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://api.yourapp.com/webhooks/v2/handler",
    "retryPolicy": {
      "maxRetries": 10
    }
  }'

Response

Returns the updated destination object.

Delete Destination

http
DELETE /api/organizations/{orgId}/destinations/{id}

WARNING

Deleting a destination removes it from all routes. Deliveries are preserved for history.

Example

bash
curl -X DELETE https://api.webhookrelay.com/api/organizations/org_123/destinations/dst_xyz789 \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

204 No Content

Destination Health

Get health metrics for a destination:

http
GET /api/organizations/{orgId}/destinations/{id}/health

Response

json
{
  "successRate": 98.5,
  "avgLatency": 245,
  "p50Latency": 180,
  "p95Latency": 450,
  "p99Latency": 890,
  "totalDeliveries": 5230,
  "successfulDeliveries": 5152,
  "failedDeliveries": 78,
  "lastDeliveryAt": "2024-01-15T10:30:00Z",
  "lastSuccessAt": "2024-01-15T10:30:00Z",
  "lastFailureAt": "2024-01-15T09:15:00Z",
  "status": "healthy"
}

Status Values

StatusDescription
healthySuccess rate > 95%
degradedSuccess rate 80-95%
failingSuccess rate < 80%
unknownNo recent deliveries

Error Responses

400 Bad Request

Invalid URL:

json
{
  "error": "Bad Request",
  "message": "Invalid URL format",
  "code": "INVALID_URL"
}

404 Not Found

Destination not found:

json
{
  "error": "Not Found",
  "message": "Destination with ID dst_xyz not found",
  "code": "RESOURCE_NOT_FOUND"
}

Released under the MIT License.