Webhooks

Webhooks are used to send event data to an external system (i.e. your application). Using the API, you can set up webhooks and subscribe to events programatically.

A webhook belongs to a Store.

Find out how to implement webhooks, how to sign requests and which events are supported in the Webhooks help docs.
Read a step-by-step webhooks implementation tutorial in our Developer Guide.


The webhook object

Attributes


store_id

The ID of the store this webhook belongs to.


url

The URL that events will be sent to.


events

An array of events that will be sent.


last_sent_at

An ISO 8601 formatted date-time string indicating when the last webhook event was sent. Will be null if no events have been sent yet.


created_at

An ISO 8601 formatted date-time string indicating when the object was created.


updated_at

An ISO 8601 formatted date-time string indicating when the object was last updated.


test_mode

A boolean indicating if the object was created within test mode.

Webhook object

{ "type": "webhooks", "id": "1", "attributes": { "store_id": 6, "url": "https://mysite.com/webhook/", "events": [ "order_created", "order_refunded" ], "last_sent_at": "2022-11-22T07:38:06.000000Z", "created_at": "2022-06-07T08:32:47.000000Z", "updated_at": "2022-06-07T08:41:37.000000Z", "test_mode": false }, }

Create a webhook

Create a webhook.

Attributes


url

Required
A valid URL of the endpoint that should receive webhook events.


events

Required
An array of webhook event types that should be sent to the webhook endpoint.
See the list of available event types.


secret

Required
A string used by Lemon Squeezy to sign requests for increased security.
Learn about receiving signed requests.

Note: The secret is never returned in the API. To view the secret of a webhook, open the webhook in your dashboard.


test_mode

Set this to true if the webhook should be created in test mode.

Relationships


store

The store this webhook belongs to.

POST /v1/webhooks

curl -X "POST" "https://api.lemonsqueezy.com/v1/webhooks" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}' -d $'{ "data": { "type": "webhooks", "attributes": { "url": "https://mysite.com/webhooks/", "events": [ "order_created", "subscription_created", "subscription_updated", "subscription_expired" ], "secret": "SIGNING_SECRET" }, "relationships": { "store": { "data": { "type": "stores", "id": "1" } } } } }'

Returns

Returns a webhook object.

Response

{ "jsonapi": { "version": "1.0" }, "links": { "self": "https://api.lemonsqueezy.com/v1/webhooks/1" }, "data": { "type": "webhooks", "id": "1", "attributes": { "store_id": 1, "url": "https://mysite.com/webhooks/", "events": [ "order_created", "subscription_created", "subscription_updated", "subscription_expired" ], "last_sent_at": null, "created_at": "2022-06-07T08:32:47.000000Z", "updated_at": "2022-06-07T08:32:47.000000Z", "test_mode": false }, "relationships": { "store": { "links": { "related": "https://api.lemonsqueezy.com/v1/webhooks/1/store", "self": "https://api.lemonsqueezy.com/v1/webhooks/1/relationships/store" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/webhooks/1" } } }

Retrieve a webhook

Retrieves the webhook with the given ID.

GET /v1/webhooks/:id

curl "https://api.lemonsqueezy.com/v1/webhooks/1" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'

Returns

Returns a webhook object.

Response

{ "jsonapi": { "version": "1.0" }, "links": { "self": "https://api.lemonsqueezy.com/v1/webhooks/1" }, "data": { "type": "webhooks", "id": "1", "attributes": { "store_id": 1, "url": "https://mysite.com/webhooks/", "events": [ "order_created", "subscription_created", "subscription_updated", "subscription_expired" ], "last_sent_at": "2022-11-22T07:38:06.000000Z", "created_at": "2022-06-07T08:32:47.000000Z", "updated_at": "2022-06-07T08:32:47.000000Z", "test_mode": false }, "relationships": { "store": { "links": { "related": "https://api.lemonsqueezy.com/v1/webhooks/1/store", "self": "https://api.lemonsqueezy.com/v1/webhooks/1/relationships/store" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/webhooks/1" } } }

Update a webhook

Update a webhook.

Attributes


url

A valid URL of the endpoint that should receive webhook events.


events

An array of webhook event types that should be sent to the webhook endpoint.
See the list of available event types.


secret

A string used by Lemon Squeezy to sign requests for increased security.
Learn about receiving signed requests.

Note: The secret is never returned in the API. To view the secret of a webhook, open the webhook in your dashboard.

PATCH /v1/webhooks/:id

curl -X "PATCH" "https://api.lemonsqueezy.com/v1/webhooks/1" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}' -d $'{ "data": { "type": "webhooks", "id": "1", "attributes": { "events": [ "order_created", "order_refunded", "subscription_created", "subscription_updated", "subscription_expired" ] } } }'

Returns

Returns a webhook object.

Response

{ "jsonapi": { "version": "1.0" }, "links": { "self": "https://api.lemonsqueezy.com/v1/webhooks/1" }, "data": { "type": "webhooks", "id": "1", "attributes": { "store_id": 1, "url": "https://mysite.com/webhooks/", "events": [ "order_created", "order_refunded", "subscription_created", "subscription_updated", "subscription_expired" ], "last_sent_at": "2022-11-22T07:38:06.000000Z", "created_at": "2022-06-07T08:32:47.000000Z", "updated_at": "2022-06-07T08:41:37.000000Z", "test_mode": false }, "relationships": { "store": { "links": { "related": "https://api.lemonsqueezy.com/v1/webhooks/1/store", "self": "https://api.lemonsqueezy.com/v1/webhooks/1/relationships/store" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/webhooks/1" } } }

Delete a webhook

Delete a webhook with the given ID.

Returns

Returns a 204 No Content response on success.

DELETE /v1/webhooks/:id

curl -X "DELETE" "https://api.lemonsqueezy.com/v1/webhooks/1" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'

List all webhooks

Returns a paginated list of webhooks.

Parameters


store_id

Only return webhooks belonging to the store with this ID.

GET /v1/webhooks

curl "https://api.lemonsqueezy.com/v1/webhooks" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'
curl "https://api.lemonsqueezy.com/v1/webhooks?filter[store_id]=11" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'

Returns

Returns a paginated list of webhook objects ordered by created_at.

Response

{ "meta": { "page": { "currentPage": 1, "from": 1, "lastPage": 1, "perPage": 10, "to": 10, "total": 10 } }, "jsonapi": { "version": "1.0" }, "links": { "first": "https://api.lemonsqueezy.com/v1/webhooks?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=createdAt", "last": "https://api.lemonsqueezy.com/v1/webhooks?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=createdAt" }, "data": [ { "type": "webhooks", "id": "1", "attributes": { "store_id": 1, "url": "https://mysite.com/webhooks/", "events": [ "order_created", "subscription_created", "subscription_updated", "subscription_expired" ], "last_sent_at": "2022-11-22T07:38:06.000000Z", "created_at": "2022-06-07T08:32:47.000000Z", "updated_at": "2022-06-07T08:41:37.000000Z", "test_mode": false }, "relationships": { "store": { "links": { "related": "https://api.lemonsqueezy.com/v1/webhooks/1/store", "self": "https://api.lemonsqueezy.com/v1/webhooks/1/relationships/store" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/webhooks/1" } }, {...}, {...}, ] }