Oktopost

Quickstart

Create a webhook, receive your first event, and verify its signature.

This guide walks you through receiving your first webhook from Oktopost. You need your API credentials (see Authentication) and a publicly accessible HTTPS URL.

1. Set Up an Endpoint

Create an HTTPS endpoint that accepts POST requests and returns a 2xx status code within 5 seconds. Keep the raw request body as text; you'll need it to verify the signature. See Endpoint Requirements.

2. Create a Webhook

Pick an event from the Event Catalog and register your endpoint:

curl -X POST "https://api.oktopost.com/v2/webhook" \
  -u ACCOUNT_ID:API_KEY \
  -d event="newInboxItemAssignment" \
  -d name="Slack Assignment Notification" \
  -d url="https://example.com/webhooks/oktopost" \
  -d isEnabled=1

The response includes a Secret. Store it securely.

{
	"Result": true,
	"Webhook": {
		"Id": "0WA000000000001",
		"Event": "newInboxItemAssignment",
		"Url": "https://example.com/webhooks/oktopost",
		"IsEnabled": 1,
		"Secret": "a1b2c3d4e5f6..."
	}
}

3. Verify the Signature

Each request includes an X-Oktopost-Secret header: the hex-encoded HMAC-SHA1 of the raw body, keyed with your webhook Secret. Compare it before you parse the JSON:

const crypto = require('crypto');

function verifyWebhook(rawBody, signature, secret) {
  const expectedSignature = crypto
    .createHmac('sha1', secret)
    .update(rawBody)
    .digest('hex');

  return signature === expectedSignature;
}

See Verify Webhook Signatures for the full details.

4. Trigger the Event

Perform the subscribed action in Oktopost, such as assigning an inbox item. Your endpoint receives a JSON array of payloads. See Payloads for the format.

Failed deliveries are retried up to 3 times. Make your handler idempotent so a retried delivery doesn't get processed twice.

5. Monitor Deliveries

Use the Webhook Log endpoint to confirm deliveries and troubleshoot failures.