Trigger Inbox onboarding
This article covers the core queue model of the Trigger Inbox API: create an inbox, send a message, lease it, and acknowledge it. It uses Webhooks by Zapier as the trigger so you can run the full lifecycle without connecting an external app. Follow the steps individually to understand each part of the flow, or skip to the complete script at the bottom to run everything at once. Once you understand this pattern, the app tutorial covers connecting to apps like Slack or Gmail using the user’s app connection.Before you begin
Node.js 18 or later, installed and available asnode.
Step 1: Get an access token
The Trigger Inbox API requires an access token to authenticate your requests. For local testing, use SDK client credentials. The webhook trigger used in this guide does not require an app connection, so SDK client credentials are all you need to follow along. 1. Install the Zapier Platform CLI: If you already have the Zapier Platform CLI installed, skip to step 2.client_id and client_secret. Copy both values.
3. Exchange your credentials for an access token:
access_token value from the response:
SDK credentials are for testing only. For production applications that act on behalf of your users, use JWT authentication.
Step 2: Create the inbox
The webhook trigger requires two randomly generated values, a hook code and a seed, that form your unique webhook URL. 1. Generate webhook codes and create the inbox:Step 3: Wait for active
A new inbox starts ininitializing while Zapier sets up the trigger subscription. Do not send events or lease messages until the status is active.
1. Poll until the inbox is active:
Step 4: Send a test event
1. Send an HTTP POST to your webhook URL:Step 5: Lease messages
Leasing claims a batch of messages and locks them for exclusive processing. No other consumer can claim them during the lease. If you do not acknowledge within the lease duration, the messages return to the queue automatically. 1. Poll until messages are available:| Field | Description |
|---|---|
lease_id | Required to acknowledge or release the batch. |
leased_until | When the lease expires. Messages return to the queue after this time if not acknowledged. |
results[] | The leased messages. |
results[].payload | The event data. Contains your POST body plus a querystring field that Zapier adds automatically. This field is empty ({}) if no query parameters were sent. |
results[].message_attributes.lease_count | How many times this message has been leased. Use this to identify repeatedly failing messages. |
results[].message_attributes.possible_duplicate_data | true if Zapier detected a possible duplicate delivery. |
inbox_attributes | Current inbox status. |
lease_id from the response:
Step 6: Acknowledge messages
Acknowledging permanently removes messages from the queue. Only acknowledge after processing succeeds. 1. Acknowledge using thelease_id from Step 5:
"status": "acked".
If processing fails, do not acknowledge. Let the lease expire and the messages will return to the queue automatically. To return them immediately, use release messages.The Trigger Inbox API uses at-least-once delivery. Build idempotent processing and check the message
id before acting on a payload."message_ids": ["id1", "id2"] to the request body alongside lease_id.
Step 7: Confirm the inbox is empty
After acknowledging, confirm there are no remaining messages. 1. Attempt to lease with a limit of 1:"lease_id": null and "results": [].
Step 8: Delete the test inbox
In production, inboxes are long-lived. Create them once and run the lease-process-acknowledge cycle continuously. Delete an inbox only when decommissioning an integration entirely. For this tutorial, delete the test inbox to cancel the trigger subscription. 1. Delete the inbox:deleting until Zapier finishes removing the inbox and any remaining messages on the backend, but you can treat the inbox as effectively gone as soon as you get a 202 response.
Complete script
Complete Step 1 first to get your access token, then setTOKEN and run the script: