Skip to main content
An integration that connects to many workspaces, or a team that keeps its setup in code, can manage webhook endpoints through the API instead of in Settings → Webhooks. They are the same endpoints: one created through the API shows up in Settings, and the other way round. Each request acts on the endpoints of the workspace the API key belongs to, so an integration that connects to several workspaces needs a key for each.

Look up the event IDs

An endpoint subscribes to events by ID, not by name. The event pages in the sidebar show each event’s name and payload but not its ID, so List webhook events (GET /webhooks/events) is where the IDs come from:
Each item pairs an event’s ID with its name. Two of them are shown here:
With pageSize=100 the whole catalog fits in one page today; if the response’s pagination.hasNextPage is true, ask for the next page. An event’s ID is the same in every workspace, so you can look the IDs up once and keep them in your code.

Create an endpoint

Send the https URL that receives the deliveries, and the IDs of the events, to Create a webhook endpoint (POST /webhooks/endpoints). This one subscribes to placement.created for an invoicing sync:
The secret is how your receiver checks that a delivery comes from Spott. The API returns it only here and when you rotate it, so put it in your secret store right away. Verify webhook deliveries explains how your receiver uses it.

List and read endpoints

List webhook endpoints (GET /webhooks/endpoints) returns the workspace’s endpoints a page at a time: pass the pagination.cursor of a response as cursor to get the next page, until it is null. Retrieve a webhook endpoint (GET /webhooks/endpoints/{id}) returns one. Neither includes the secret. An endpoint whose events is null receives every event. Only Settings → Webhooks can set that; to narrow it down through the API, send a list of events.

Change an endpoint

Update a webhook endpoint (PATCH /webhooks/endpoints/{id}) changes only the fields you send. The events you send replace all the endpoint’s events, so to add or remove one, read the endpoint first, edit its list, and send the whole list back. Leave out any event that List webhook events no longer returns, or the request fails. The endpoint above subscribes to placement.created. To also get placement.updated, send both:
To stop deliveries for a while, send "disabled": true, and false to start them again. The endpoint keeps its ID and its secret. Whichever change comes last wins, made through the API or in Settings.

Rotate the secret

Rotate a secret when it may have leaked, when someone who knew it leaves, or on a fixed schedule, with Rotate the secret of a webhook endpoint (POST /webhooks/endpoints/{id}/secret/_rotate). A rotation does not have to cost a single delivery. For a while after you rotate, the overlap, Spott signs every delivery with both the old and the new secret. Your receiver needs only one of them: one that still has the old secret and one that already has the new secret both pass. So you can switch your receivers over at any moment during the overlap, one server at a time if you deploy that way.
1

Rotate

overlapMs sets how long the old secret keeps working; this example keeps it for one hour:
2

Store the new secret

Put it in your secret store straight away. As on create, the API cannot return it again.
3

Deploy it to your receivers

Do this before the overlap ends. Until then, deliveries pass with either secret.
4

Let the overlap end

After that, deliveries are signed only with the new secret, and the old one no longer works. There is nothing to clean up.
Make the overlap longer than your slowest deploy, approvals included. Leave overlapMs out and the old secret keeps working for 24 hours.

When the secret has leaked

Send "overlapMs": 0 to stop the old secret at once. From then on, deliveries fail your signature check until your receivers have the new secret: your receiver turns them away, they count as failed deliveries, and Spott tries them again later. So deploy the new secret as fast as you can. That stops only the secret you are replacing. If you rotated shortly before, the secret from before that rotation keeps working until its own overlap ends.

Delete an endpoint

Delete a webhook endpoint (DELETE /webhooks/endpoints/{id}) removes it, and deliveries to it stop. If you create a new endpoint for the same URL, it gets a new ID and a new secret, so update your receiver with that secret.

Troubleshooting