Webhooks

Receive an HTTP request from onefold when a user authorizes your application, signs in, changes, is blocked, or leaves, and handle deliveries, retries and replays.

A webhook tells your server when something happens to a user of your application, so you do not have to poll. onefold sends an HTTP POST to an endpoint you register, signed so you can prove it came from onefold.

Set up an endpoint

Create a handler

Expose an https URL on your server that accepts a POST with a JSON body. The URL must be reachable from the public internet; onefold does not deliver to private or loopback addresses.

Register it

On the application's Webhooks tab, add the URL and choose the events to receive.

Store the signing secret

The portal shows the endpoint's signing secret, which starts with eitozx_whsec_. Keep it on your server. Each endpoint has its own secret; it is not your client secret.

Verify each delivery

Check the signature before you act on a delivery. See Verify webhooks.

Which event to use

Every event concerns your own application and the people who hold a grant with it. You are never told about a person who has not authorized your application.

You want to know thatSubscribe to
A new user authorized your applicationconsent.granted
A user signed in to your applicationuser.login
A user's username or profile changedprofile.updated
A user removed your application, or their authorization ended for another reasonconsent.revoked
A user was blocked from your application, or the block was liftedaccess.blocked, access.unblocked
A user's account was taken out of service, or a hold on it was releasedprofile.disabled, profile.restored
A user is now known by another subsubject.changed, then profile.succeeded or profile.merged
Your application's plan or limits changedentitlements.updated

Use consent.granted for new users

A person becomes a user of your application when they approve its scopes, and consent.granted is sent at that moment. There is no event for an account being created: an account that has not authorized your application is not yours to hear about.

Webhook events lists every event with its payload.

Deliveries

  • Acknowledge quickly. Respond with any 2xx status within 10 seconds. Do slow work after you respond.
  • Failures are retried. A non-2xx response, a timeout or a connection error is retried up to five times, after 30 seconds, then 1, 2, 4 and 8 minutes.
  • Redirects are not followed. A 3xx response counts as a failure.
  • Delivery is at least once. The same delivery can arrive more than once, and events can arrive out of order. Make your handler idempotent.
  • A delivery can arrive late. If onefold cannot attempt a delivery when the event happens, it keeps the delivery and attempts it once it can, up to 72 hours after the event.
  • A delivery older than 72 hours is not sent. It is closed as expired.
  • Disabling an endpoint closes what was waiting for it. A delivery that has not been delivered when you disable its endpoint is closed as endpoint_disabled and is not sent, including after you enable the endpoint again. Replay it if you still want it.

Two headers identify a delivery:

HeaderStays the same across
X-Webhook-DeliveryRetries of one delivery
X-Webhook-Event-IdRetries, and a later replay of the same event

Deduplicate on X-Webhook-Event-Id to process each event once.

Delivery history and replay

The Webhooks tab lists each endpoint's deliveries with their status, response code and number of attempts. A failed delivery that will be attempted again is marked as retrying. A delivery that will not be attempted again shows why:

Shown asReasonMeaning
Retries exhaustedretries_exhaustedEvery attempt failed
Expired before deliveryexpiredIt was not delivered within 72 hours of the event
Endpoint was disabledendpoint_disabledIts endpoint was disabled while it was waiting
Test sendsingle_attemptIt was a test delivery that failed; a test is sent once
Never deliveredpre_recovery_migrationAn older delivery that was never delivered and is not sent now

From there you can replay a delivery, which sends the same event again as a new delivery with the same X-Webhook-Event-Id.

Test an endpoint

The Test button sends one sample delivery to the endpoint, signed like a real one. It is sent once, with no retries.

A test delivery's body is a sample, not a real event. It contains event, test (true), application_id and endpoint_id. Real deliveries carry only the event's own fields, with the event name in the X-Webhook-Event header.

Events are a notification, not the record

A delivery can be delayed, and a delivery that is closed for one of the reasons above is never sent. Treat a webhook as a prompt to act, and read current state from the management API when it matters.

On this page