API reference

Webhook subscriptions

Addresses the books' events are sent to as they happen, signed, with each delivery and its tries.

Guides: Webhooks

List the addresses the books send events to

GET/v1/webhook_subscriptions

client.webhookSubscriptions.list()

The addresses these books send their events to, the newest first.

Parameters

NameTypeDescription
enabledQueryboolean or null

Only those switched on (true) or off (false).

limitQueryinteger

Page size, 1–200.

Default 50
cursorQuerystring or null

The next_cursor of the previous page.

Response

200WebhookSubscriptionPage

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl "https://api.ledgerit.ai/v1/webhook_subscriptions" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN"

Send the books' events to an address

POST/v1/webhook_subscriptions· Idempotent

client.webhookSubscriptions.create()

Send these books' events to an https address. Every event from now on that it wants is POSTed to it, signed with its secret (read it with GET /webhook_subscriptions/{id}/secret), and retried until the address answers 2xx.

Request body

WebhookSubscriptionCreate

Response

201WebhookSubscriptionOut

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl -X POST "https://api.ledgerit.ai/v1/webhook_subscriptions" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"url":"…"}'

Get a webhook subscription

GET/v1/webhook_subscriptions/{subscription_id}

client.webhookSubscriptions.get()

One webhook subscription.

Parameters

NameTypeDescription
subscription_idPath · Requiredstring

An id that starts with whsub_.

Response

200WebhookSubscriptionOut

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl "https://api.ledgerit.ai/v1/webhook_subscriptions/{subscription_id}" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN"

Change a webhook subscription, or switch it off and on

PATCH/v1/webhook_subscriptions/{subscription_id}

client.webhookSubscriptions.update()

Change a subscription's address, description or events, or switch it off and on. Only the fields sent change.

Parameters

NameTypeDescription
subscription_idPath · Requiredstring

An id that starts with whsub_.

Request body

WebhookSubscriptionUpdate

Response

200WebhookSubscriptionOut

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl -X PATCH "https://api.ledgerit.ai/v1/webhook_subscriptions/{subscription_id}" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

Delete a webhook subscription

DELETE/v1/webhook_subscriptions/{subscription_id}

client.webhookSubscriptions.delete()

Stop sending events to an address, for good. Its deliveries still waiting go with it.

Parameters

NameTypeDescription
subscription_idPath · Requiredstring

An id that starts with whsub_.

Response

204No content

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl -X DELETE "https://api.ledgerit.ai/v1/webhook_subscriptions/{subscription_id}" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN"

List what was sent to a subscription

GET/v1/webhook_subscriptions/{subscription_id}/deliveries

client.webhookSubscriptions.listDeliveries()

What has been sent to a subscription, and what is waiting, the newest first: each event, how many tries, and why the last one failed.

Parameters

NameTypeDescription
subscription_idPath · Requiredstring

An id that starts with whsub_.

statusQuerystring or null

Only pending or delivered deliveries.

One of pending, delivered
limitQueryinteger

Page size, 1–200.

Default 50
cursorQuerystring or null

The next_cursor of the previous page.

Response

200WebhookDeliveryPage

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl "https://api.ledgerit.ai/v1/webhook_subscriptions/{subscription_id}/deliveries" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN"

Get the secret a subscription's deliveries are signed with

GET/v1/webhook_subscriptions/{subscription_id}/secret

client.webhookSubscriptions.getSecret()

The secret a subscription's deliveries are signed with, to check the LedgerIt-Signature header against.

Parameters

NameTypeDescription
subscription_idPath · Requiredstring

An id that starts with whsub_.

Response

200WebhookSecret

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl "https://api.ledgerit.ai/v1/webhook_subscriptions/{subscription_id}/secret" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN"

Send a test event to a subscription

POST/v1/webhook_subscriptions/{subscription_id}/test· Idempotent

client.webhookSubscriptions.test()

Send a webhook.test event to this subscription alone, to see its address answer. It is queued like any delivery and listed with them.

Parameters

NameTypeDescription
subscription_idPath · Requiredstring

An id that starts with whsub_.

Response

201WebhookDeliveryOut

Errors

400
The request was malformed or a parameter is invalid.
401
No valid credential was sent.
403
The credential or the member's role does not allow this.
404
No such resource in this ledger.
409
A conflicting request, e.g. one with the same Idempotency-Key still running.
422
A well-formed request a business rule refused.
429
Too many requests; retry after the Retry-After header.
500
Something failed on our side; the request_id identifies it.

Example

curl
curl -X POST "https://api.ledgerit.ai/v1/webhook_subscriptions/{subscription_id}/test" \
  -H "Authorization: Bearer $LEDGERIT_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)"

Objects

The objects these operations take and return.

WebhookSubscriptionPage

NameTypeDescription
dataRequiredarray of WebhookSubscriptionOut
has_moreRequiredboolean
next_cursorRequiredstring or null

WebhookSubscriptionCreate

NameTypeDescription
descriptionstring or null

What it is for.

event_typesarray of string

The events to send: types such as entry.posted, or families such as entry.*. Empty sends every event.

Default []
urlRequiredstring

An https address.

WebhookSubscriptionOut

NameTypeDescription
created_atRequiredstring (date-time)
descriptionRequiredstring or null

What it is for, as its maker put it.

disabled_reasonRequiredstring or null

Why it is off: person when someone switched it off, failing when its deliveries failed for three days. Null while it is on.

One of person, failing
enabledRequiredboolean

Whether events are being sent to it.

event_typesRequiredarray of string

The event types and families it is sent. Empty: every event.

failing_sinceRequiredstring (date-time) or null

The first failure since a delivery last landed. Null while deliveries land.

idRequiredstring

An id that starts with whsub_.

updated_atRequiredstring (date-time)
urlRequiredstring

The https address events are POSTed to.

WebhookSubscriptionUpdate

NameTypeDescription
descriptionstring or null

What it is for. An empty string clears it.

enabledboolean or null

Switch it off, or back on. Back on, the deliveries that waited are sent at once.

event_typesarray of string or null

The events to send: types such as entry.posted, or families such as entry.*. Empty sends every event.

urlstring or null

A new https address.

WebhookDeliveryPage

NameTypeDescription
dataRequiredarray of WebhookDeliveryOut
has_moreRequiredboolean
next_cursorRequiredstring or null

WebhookSecret

NameTypeDescription
secretRequiredstring

What each delivery is signed with: the LedgerIt-Signature header is the HMAC-SHA256 of <t>.<body> under it.

WebhookDeliveryOut

NameTypeDescription
attemptsRequiredinteger

Times it has been tried.

created_atRequiredstring (date-time)
delivered_atRequiredstring (date-time) or null
event_idRequiredstring

The event, and the id of the body sent.

event_typeRequiredstring

What happened, such as entry.posted.

idRequiredstring

An id that starts with dlv_.

last_errorRequiredstring or null

Why the last try failed, such as HTTP 500.

next_attempt_atRequiredstring (date-time) or null

When it is tried next, while pending.

statusRequiredstring

pending until the address answers 2xx, then delivered.

One of pending, delivered