> ## Documentation Index
> Fetch the complete documentation index at: https://docs.useshipd.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Receive customer events

> Create an endpoint, publish with a scoped credential, and verify durable event receipt.

## Overview

Connect a public HTTPS receiver, publish an application event, and inspect its delivery. You need a beta-enabled organization, an existing project and environment, project admin or owner access for setup, and Node.js 24 or later for the receiver example.

## Create the endpoint

Open your project’s **Settings → Webhooks** (also available through **Integrations → Manage webhooks**). Select the environment, click **Add endpoint**, enter a name and your public HTTPS `/shipd` URL, then click **Create endpoint**. Private networks, redirects, credentials in URLs, and URL fragments are unsupported.

Select **All event types** before your first publish, or choose previously published event types. The selector uses retained event history; click **Refresh events** to load new types. Existing subscriptions remain selectable after history expires. To subscribe to a specific type before publishing it, use `eventWebhook/create` with `eventTypes: ["order.completed"]` in the [API reference](https://docs.useshipd.com/reference/customer-events.md#api).

Save the signing secret immediately in your secret manager: it is shown once. This secret verifies incoming requests; it is separate from the credential used to publish events.

## Run a durable receiver

Use the complete [Node.js receiver example](https://github.com/alasti-company/useshipd.com/tree/main/examples/webhook-receiver). From its directory:

```sh Run the receiver theme={null}
export SHIPD_WEBHOOK_SECRET='your endpoint signing secret'
INBOX_DB=./inbox.sqlite PORT=3000 node receiver.mjs
```

Expose `/shipd` through your HTTPS reverse proxy, preserving the exact request body. Keep the SQLite file on durable storage. The example verifies the raw bytes before JSON parsing, rejects timestamps outside five minutes, compares signature bytes in constant time, and accepts the previous-signature header during rotation. It commits a unique event-ID inbox row before returning `204`; duplicate deliveries return `204` without creating another job.

Process inbox rows asynchronously. Apply business effects idempotently and mark completion transactionally; use event IDs as idempotency keys for external services. See the example README for storage and worker requirements.

## Send a test

Send a test from the endpoint’s actions, then open **Delivery history**. A queued test or HTTP `202` receipt means acceptance, not a successful HTTP delivery. Wait for **delivered** and inspect the HTTP attempt result. History refreshes every five seconds while open. The receiver should contain one `shipd.webhook.test` event with `test: true`.

## Create a publish-only credential

Under organization **Settings → Service accounts**, create an account and choose **Create token**. Grant only `customer_event:publish` (API scopes: `{ "customer_event": ["publish"] }`), bind it to this project and environment, and set an expiry. Store the `shipd_sa_…` token on your server. SDK keys cannot publish; never expose the publisher credential or signing secret in browser code. See [service account setup](https://docs.useshipd.com/enterprise/service-accounts.md).

## Publish and inspect

Set `SHIPD_API_URL=https://api.useshipd.com`, `SHIPD_PUBLISH_TOKEN` to the scoped token, and `SHIPD_ENVIRONMENT_ID` to your environment ID.

```sh Publish an order event theme={null}
curl --fail-with-body "$SHIPD_API_URL/api/v1/rpc/event/publish" \
  -H "Authorization: Bearer $SHIPD_PUBLISH_TOKEN" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: order-123-completed' \
  --data "{\"environmentId\":\"$SHIPD_ENVIRONMENT_ID\",\"type\":\"order.completed\",\"data\":{\"orderId\":\"ord_123\"}}"
```

The `202` response contains `data.eventId`, `data.matchedEndpoints`, and `data.acceptedAt`. Retry the same logical publish with the same key and body to get the original receipt. A changed body under that key returns `409`. Publish keys last 24 hours; keep your own durable producer record for longer reconciliation.

Find the event in **Delivery history**, inspect attempts, and verify its ID in the receiver inbox. Repeating the publish must return the same event ID; repeating delivery must leave a single inbox row. `matchedEndpoints: 0` is accepted without delivery units: no receiver is called, and adding a subscription later does not deliver that old event. It still uses ingestion capacity.

Delivery is at least once and unordered. A receiver `2xx` confirms storage, not completion of your business workflow. Use event versions or reconcile current application state when processing out of order. See [delivery guarantees, retries, retention, and limits](https://docs.useshipd.com/reference/customer-events.md).

## Inspect through the API

Use a separate read-authorized server credential (`SHIPD_INSPECTION_TOKEN`), rather than widening the publish-only token. Set `SHIPD_EVENT_ID` from the publish receipt and `SHIPD_DELIVERY_ID` from the delivery list.

```sh Inspect delivery and attempts theme={null}
curl --fail-with-body "$SHIPD_API_URL/api/v1/rpc/eventWebhook/deliveries" \
  -H "Authorization: Bearer $SHIPD_INSPECTION_TOKEN" \
  -H 'Content-Type: application/json' \
  --data "{\"environmentId\":\"$SHIPD_ENVIRONMENT_ID\",\"eventId\":\"$SHIPD_EVENT_ID\"}"

curl --fail-with-body "$SHIPD_API_URL/api/v1/rpc/eventWebhook/attempts" \
  -H "Authorization: Bearer $SHIPD_INSPECTION_TOKEN" \
  -H 'Content-Type: application/json' \
  --data "{\"environmentId\":\"$SHIPD_ENVIRONMENT_ID\",\"deliveryId\":\"$SHIPD_DELIVERY_ID\"}"
```

Results appear under `data`; delivery status is `pending`, `delivered`, `failed`, or `cancelled`. Attempts contain HTTP status, duration, and sanitized errors, without customer payloads. Use `eventWebhook/usage` to check effective organization-wide limits; it additionally requires billing-read access.

## Operate the endpoint

Use **Pause endpoint** to stop queued delivery and **Resume endpoint** to resume retained work. Delete cancels queued work; in-flight requests may still finish. URLs are immutable: create and test a replacement endpoint, then retire the old one. If your endpoint allowance prevents overlap, coordinate the interruption before deleting the old endpoint.

Use **Rotate signing secret**, save the new secret once, and update the receiver within the 24-hour overlap. During overlap the old receiver can verify `x-shipd-signature-previous`. A second rotation is unavailable until the overlap ends.

Manual redelivery of completed or failed events creates a new delivery for the same event ID and reserves another delivery unit; automatic retries are included. Test deliveries and their redeliveries are free. Only retained events can be redelivered, so recover failures before retention expires.

Project transfer removes endpoints and customer payloads before ownership changes. Configure new endpoints in the destination organization; source usage stays charged. For disabled-rollout and archived-environment behavior, see the [reference](https://docs.useshipd.com/reference/customer-events.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.