Skip to main content
API reference

Webhook Endpoints

Generated HTTP reference for the 10 operations the published OpenAPI document describes under webhook-endpoints.

8 min read
View MarkdownEdit on GitHub

Webhook Endpoints

This page is generated from the published OpenAPI document. It is complete with respect to that document and says nothing about surfaces the document does not describe yet. See what is generated here for what that means.

Base URL: https://api.codespar.dev

Every operation below requires a Bearer token. See Authentication.

GET /v1/webhook-endpoints

List triggers

Query parameters

NameTypeRequiredDescription
beforestringno
eventstringno
limitintegerno
server_idstringno
status"active" | "paused" | "error"no

Responses

StatusBodyDescription
200objectOK
400objectBad Request — the body or query did not match the schema.

Response 200

FieldTypeRequiredDescription
next_beforestring,nullyes
triggersarray of Triggeryes

Example response

{
  "triggers": [
    {
      "id": "trg_0000000000000000",
      "org_id": "org_0000000000000000",
      "name": "Example",
      "event": "string",
      "webhook_url": "https://example.com/hook",
      "status": "string",
      "total_runs": 0,
      "created_at": "2026-01-15T12:00:00.000Z",
      "signing_enabled": true
    }
  ]
}

Example request

curl -X GET https://api.codespar.dev/v1/webhook-endpoints \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

POST /v1/webhook-endpoints

Subscribe a webhook to an event

Request body

FieldTypeRequiredDescription
eventstringyes
namestringyes
server_idstringno
webhook_urlstring (uri)yes

Responses

StatusBodyDescription
201TriggerCreatedOK
400objectBad Request — the body or query did not match the schema.

Example request

curl -X POST https://api.codespar.dev/v1/webhook-endpoints \
  -H "Authorization: Bearer $CODESPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "name": "Example",
       "event": "string",
       "server_id": "srv_0000000000000000",
       "webhook_url": "https://example.com/hook"
     }'

POST /v1/webhook-endpoints/deliveries/{delivery_id}/redeliver

Queue a delivery to be sent again

Path parameters

NameTypeRequiredDescription
delivery_idstringyesDelivery id as decimal digits, the string form of the bigserial column. Up to 19 digits, which is the width of a signed 64 bit maximum; anything else is refused with 400 invalid_delivery_id before the database is touched.

Responses

StatusBodyDescription
202objectAccepted
400objectdelivery_id is not 1 to 19 decimal digits.
404objectNo delivery with that id whose webhook endpoint belongs to the caller's organization and project.

Response 202

FieldTypeRequiredDescription
event_idstringyes
redelivery_idstringyesId of the NEW pending delivery row, bigint as string.
trigger_idstringyes
trigger_statusstringyesStatus of the endpoint the delivery belongs to, read before the insert. Check it: the drain only claims rows whose endpoint is active, so a redelivery queued against a paused or error endpoint sits there until a patch reactivates it.

Example response

{
  "redelivery_id": "redelivery_0000000000000000",
  "trigger_id": "trg_0000000000000000",
  "event_id": "event_0000000000000000",
  "trigger_status": "string"
}

Example request

curl -X POST https://api.codespar.dev/v1/webhook-endpoints/deliveries/{delivery_id}/redeliver \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

POST /v1/webhook-endpoints/retry-pending

Drain the retry queue for this project

Responses

StatusBodyDescription
200objectOK

Response 200

FieldTypeRequiredDescription
deadintegeryesAttempts that failed on the last allowed attempt and were dead lettered.
deliveredintegeryes
failedintegeryesAttempts that failed and are scheduled for another retry.
redispatchedintegeryes
scannedintegeryesRows the claim actually took, which is also the ceiling on the four counters below.

Example response

{
  "scanned": 0,
  "redispatched": 0,
  "delivered": 0,
  "failed": 0,
  "dead": 0
}

Example request

curl -X POST https://api.codespar.dev/v1/webhook-endpoints/retry-pending \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

GET /v1/webhook-endpoints/{id}

Read one webhook endpoint

Path parameters

NameTypeRequiredDescription
idstringyesEndpoint id, trg_ followed by a 16 character nanoid, as minted by the create call.

Responses

StatusBodyDescription
200objectOK
404objectNo webhook endpoint with that id in the caller's organization and project.

Response 200

FieldTypeRequiredDescription
created_atstring (date-time)yes
eventstringyesThe event name this endpoint subscribes to, dot separated lowercase.
idstringyes
last_run_atstring,null (date-time)yesTimestamp of the last DELIVERED attempt, on the same rule as total_runs.
namestringyes
org_idstringyes
project_idstring,nullyesNullable in the row type this response is serialized from; a later migration sets the column NOT NULL, so an endpoint created since then always carries one.
server_idstring,nullyes
signing_enabledbooleanyesWhether a signing secret exists. The secret itself is never read back: the serializer drops the vault reference and reports only this boolean.
statusstringyesactive, paused or error. Left as an open string because the column is text with no CHECK constraint: active and paused are what a patch may set, and error is what the dispatcher writes on its own when an endpoint auto-pauses after enough consecutive dead deliveries.
total_runsintegeryesDeliveries that landed. A failed or dead attempt does not count, which is why this can sit at 0 while the deliveries listing is full of rows.
webhook_urlstringyes

Example response

{
  "id": "obj_0000000000000000",
  "org_id": "org_0000000000000000",
  "name": "Example",
  "event": "string",
  "webhook_url": "https://example.com/hook",
  "status": "string",
  "total_runs": 0,
  "created_at": "2026-01-15T12:00:00.000Z",
  "signing_enabled": true
}

Example request

curl -X GET https://api.codespar.dev/v1/webhook-endpoints/{id} \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

DELETE /v1/webhook-endpoints/{id}

Delete a webhook endpoint

Path parameters

NameTypeRequiredDescription
idstringyesEndpoint id, trg_ followed by a 16 character nanoid, as minted by the create call.

Responses

StatusBodyDescription
204No Content
404objectNo webhook endpoint with that id in the caller's organization and project.
503objectThe signing secret could not be purged, so nothing was deleted. Retriable.

Example request

curl -X DELETE https://api.codespar.dev/v1/webhook-endpoints/{id} \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

GET /v1/webhook-endpoints/{id}/deliveries

List recent delivery attempts

Path parameters

NameTypeRequiredDescription
idstringyesEndpoint id, trg_ followed by a 16 character nanoid, as minted by the create call.

Query parameters

NameTypeRequiredDescription
limitintegernoRows to return. Clamped into the range 1 to 200: a larger or smaller value is reduced or raised rather than refused, and a value that does not parse as a number falls back to 50.

Responses

StatusBodyDescription
200objectOK
404objectNo webhook endpoint with that id in the caller's organization and project.

Response 200

FieldTypeRequiredDescription
deliveriesarray of objectyes

Example response

{
  "deliveries": [
    {
      "id": "obj_0000000000000000",
      "trigger_id": "trg_0000000000000000",
      "event_id": "event_0000000000000000",
      "attempt": 0,
      "status": "string",
      "created_at": "2026-01-15T12:00:00.000Z"
    }
  ]
}

Example request

curl -X GET https://api.codespar.dev/v1/webhook-endpoints/{id}/deliveries \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

GET /v1/webhook-endpoints/{id}/deliveries/{delivery_id}

Inspect one delivery attempt

Path parameters

NameTypeRequiredDescription
delivery_idstringyesDelivery id as decimal digits, the string form of the bigserial column. Up to 19 digits, which is the width of a signed 64 bit maximum; anything else is refused with 400 invalid_delivery_id before the database is touched.
idstringyesEndpoint id, trg_ followed by a 16 character nanoid, as minted by the create call.

Responses

StatusBodyDescription
200objectOK
400objectdelivery_id is not 1 to 19 decimal digits.
404objectEither no such webhook endpoint in the caller's organization and project, or no delivery with that id belonging to it. Both answer the same code, on purpose.

Response 200

FieldTypeRequiredDescription
deliveryobjectyes
eventobjectyes
requestobjectyes
responseobjectyes

Example response

{
  "delivery": {
    "id": "obj_0000000000000000",
    "trigger_id": "trg_0000000000000000",
    "event_id": "event_0000000000000000",
    "attempt": 0,
    "status": "string",
    "created_at": "2026-01-15T12:00:00.000Z"
  },
  "request": {
    "headers": {
      "Content-Type": "string",
      "X-CodeSpar-Event": "string",
      "X-CodeSpar-Event-Id": "xcodesparevent_0000000000000000",
      "X-CodeSpar-Trigger-Id": "xcodespartrigger_0000000000000000",
      "X-CodeSpar-Attempt": "string"
    },
    "body": "string"
  },
  "response": {},
  "event": {
    "id": "obj_0000000000000000",
    "source": "string",
    "event_type": "string",
    "payload": {},
    "received_at": "2026-01-15T12:00:00.000Z"
  }
}

Example request

curl -X GET https://api.codespar.dev/v1/webhook-endpoints/{id}/deliveries/{delivery_id} \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

GET /v1/webhook-endpoints/{id}/dlq

List dead lettered deliveries

Path parameters

NameTypeRequiredDescription
idstringyesEndpoint id, trg_ followed by a 16 character nanoid, as minted by the create call.

Query parameters

NameTypeRequiredDescription
limitintegernoRows to return. Clamped into the range 1 to 200: a larger or smaller value is reduced or raised rather than refused, and a value that does not parse as a number falls back to 50.

Responses

StatusBodyDescription
200objectOK
404objectNo webhook endpoint with that id in the caller's organization and project.

Response 200

FieldTypeRequiredDescription
dead_lettersarray of objectyes

Example response

{
  "dead_letters": [
    {
      "id": "obj_0000000000000000",
      "event_id": "event_0000000000000000",
      "attempt": 0,
      "created_at": "2026-01-15T12:00:00.000Z"
    }
  ]
}

Example request

curl -X GET https://api.codespar.dev/v1/webhook-endpoints/{id}/dlq \
  -H "Authorization: Bearer $CODESPAR_API_KEY"

POST /v1/webhook-endpoints/{id}/rotate-secret

Mint a new signing secret for a webhook endpoint

Path parameters

NameTypeRequiredDescription
idstringyesEndpoint id, trg_ followed by a 16 character nanoid, as minted by the create call.

Responses

StatusBodyDescription
200objectOK
404objectNo webhook endpoint with that id in the caller's organization and project.
503objectThe new secret could not be persisted, so no rotation occurred and the previous secret is still in force. Retriable.

Response 200

FieldTypeRequiredDescription
secretstringyesThe new signing secret in plaintext, 32 random bytes as hex, shown EXACTLY ONCE. Later reads expose only signing_enabled, and a lost secret is replaced by rotating again.
signing_enabledtrueyes
trigger_idstringyes

Example response

{
  "trigger_id": "trg_0000000000000000",
  "signing_enabled": true,
  "secret": "string"
}

Example request

curl -X POST https://api.codespar.dev/v1/webhook-endpoints/{id}/rotate-secret \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
Webhook Endpoints | CodeSpar