Skip to content

    API reference

    Subscriptions

    A subscription is a webhook your code creates and removes through the API, one event per subscription, in the REST-hook style. The Zapier app uses these; any other integration can too. To set up a webhook by hand instead, see Webhooks.

    Each subscription is delivered exactly like a webhook, with the same body, headers, retries and URL rules (see Webhook deliveries). It appears in Settings → Integrations → Webhooks beside the webhooks added there, named after the event, such as "API · Stock changed".

    Subscribe to an event

    POST /hooks — needs read

    Subscribes a URL to one event.

    JSON body

    Field Type Required Description
    targetUrl string Yes Where to deliver. target_url is accepted too. Must follow the URL rules.
    event string Yes One of the six event types.

    Subscribing a URL to an event it already has an active subscription for returns that subscription with 200 instead of creating another, so retries are safe.

    An organization can hold 50 subscriptions made through the API, paused and switched-off ones included.

    The signing secret is never returned here. If you want to verify signatures, an Owner or Admin can issue one with New secret on the subscription in Settings → Integrations → Webhooks. That button isn't offered on subscriptions the Zapier app made.

    A subscription stops delivering if the person who created the API key stops being an Owner or Admin, and is removed if your URL answers 410 Gone.

    Example

    bash
    curl -X POST https://app.simpleinventory.io/api/v1/hooks \
      -H "Authorization: Bearer $SIMPLE_INVENTORY_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"targetUrl": "https://hooks.example.com/simple-inventory", "event": "inventory.updated"}'
    

    Response: 201 Created (200 OK if it already exists)

    json
    {
      "data": {
        "id": 41,
        "event": "inventory.updated",
        "targetUrl": "https://hooks.example.com/simple-inventory"
      }
    }
    

    targetUrl comes back in the normalized form it was stored in.

    Errors

    Status Code When
    400 validation_error event is missing, or event, targetUrl or target_url isn't a string.
    400 invalid_event The event isn't one of the six event types.
    400 invalid_target_url The URL is missing or breaks the URL rules.
    409 hook_limit_reached The organization already has 50 subscriptions made through the API.

    Unsubscribe

    DELETE /hooks/{id} — needs read

    Removes a subscription made with POST /hooks, along with its delivery log. It works even while the organization's integrations are paused. Webhooks added in Settings can't be removed here.

    Example

    bash
    curl -X DELETE https://app.simpleinventory.io/api/v1/hooks/41 \
      -H "Authorization: Bearer $SIMPLE_INVENTORY_API_KEY"
    
    json
    {
      "data": { "deleted": true }
    }
    

    Errors

    Status Code When
    404 not_found No subscription made through the API has this ID in this organization.