Subscribe through the API

Let an integration add and remove its own webhooks with an API key.

On this page

These endpoints let a tool subscribe a URL to one event (a pattern often called REST hooks). Check the key with GET /me, subscribe, and unsubscribe when the integration is turned off.

Subscribe#

POST/hooks

Subscribing, unsubscribing and sample events all need the key's creator to have developer settings (owners and co-owners have them). Otherwise they answer 403.

Body propertyRules
targetUrlRequired, up to 2,000 characters. https on a public host.
eventRequired. object.action, where object is an object slug or *, and action is created, updated, deleted, restored or *.
descriptionOptional, up to 200 characters. The default is Added through the API.
cURL
curl --fail-with-body "$JEMERO_URL/hooks" \
  -H "Authorization: Bearer $JEMERO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "targetUrl": "https://example.com/webhooks/jemero", "event": "people.created" }'
Node.js
const response = await fetch(`${process.env.JEMERO_URL}/hooks`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.JEMERO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    targetUrl: 'https://example.com/webhooks/jemero',
    event: 'people.created',
  }),
});
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
const { id } = await response.json();
console.log(id);
Python
import os
import requests

response = requests.post(
    f"{os.environ['JEMERO_URL']}/hooks",
    headers={"Authorization": f"Bearer {os.environ['JEMERO_API_KEY']}"},
    json={
        "targetUrl": "https://example.com/webhooks/jemero",
        "event": "people.created",
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["id"])
Response 201
{ "id": "9798f500-8d92-4623-8782-335e4d89a8c6" }

Store the id; you need it to unsubscribe, and there is no endpoint that lists your subscriptions.

Unsubscribe#

DELETE/hooks/{id}
cURL
curl --fail-with-body -X DELETE "$JEMERO_URL/hooks/$HOOK_ID" \
  -H "Authorization: Bearer $JEMERO_API_KEY"

The answer is 204. An unknown ID, or a webhook that was created in Settings, answers 404 Hook not found.

Revoking an API key deletes the subscriptions it created. An expired key's subscriptions are not deleted: unsubscribe, revoke the key, or delete them in Settings.

Sample events#

GET/hooks/sample

Returns example events built from the object's three newest records, for tools that need to show sample data while someone sets up a step. Pass event as above.

cURL
curl --fail-with-body "$JEMERO_URL/hooks/sample?event=companies.created" \
  -H "Authorization: Bearer $JEMERO_API_KEY"

The answer is an array in the payload shape, with webhookId set to sample. The date is the time of your request, and there is no changes list, even for updated.

  • With object *, the samples are People.
  • With action *, the samples are labelled created.
  • An unknown object, or one with no records, gives [].
  • An invalid event answers 400 Unknown event.