Skip to main content

Configure webhooks

Configure webhooks in Logto Console to achieve seamless integration and receive real-time event notifications for your application. Enjoy easy configuration, enhanced security, and convenient health monitoring options.

Create a webhook​

Firstly, create a webhook endpoint that will be called by the Logto Agent. This endpoint should be implemented on your server and capable of receiving HTTP requests.

To create a new webhook in the Logto Console, follow these steps:

  1. Create webhook: Navigate to Console > Webhooks and click the "Create webhook" button.

  2. Name: Provide a name for the webhook. It is for your own reference to define the usage scenario.

  3. Endpoint URL: Enter the Endpoint URL, which is the URL of your server that will receive the webhook POST requests when the event occurs. For security reasons, the URL must be publicly accessible via HTTPS and should not be a local host URL.

    note:

    Your server should respond to the Logto webhook requests with a 2xx response (such as HTTP 200 "OK") right after receiving the request to notify that the request has been received.

    Waiting for the corresponding Webhook event's logic processing to complete before responding might cause the Webhook to timeout, and a timed-out request is retried.

    If an error occurs while processing an event you have already received, handle it on your own server. Return 408, 429, or a 5xx status only when you want Logto to send the request again.

  4. Event: In the modal that appears, select the desired events that will trigger this webhook. It is recommended to choose a smaller number of events that meet your requirements to avoid overwhelming the server reception. You can change the selected events at any time after creating the webhook.

    Create webhook
  5. Disable / Reactive: By default, the webhook is activated immediately after creation. If you want to suspend the webhook temporarily, you can disable or reactivate it using the "Three-Dots" menu located in the top-right corner of the header after creating it.

Secure webhook​

Once your server is ready to receive webhook requests, you may want to make sure that it can handle the requests securely. Logto generates a signature for each webhook request payload, which allows you to verify that the request comes from Logto.

After creating a new webhook, you have options to enhance its security:

  • Signing key: Logto generates a unique hash signature, known as the Signing Key, for each webhook. You can include this key as a request header in your endpoint implementation. Verifying the signing key ensures that the webhook payload originates from Logto and has not been tampered with by unauthorized sources. Read securing your webhooks to learn more about the code.
  • Custom header: You have the option to include custom headers in the webhook payload to provide additional context or metadata. This feature allows you to add relevant information that can assist in processing the webhook data effectively.

By utilizing the Signing Key and considering the inclusion of Custom Headers, you can enhance the security of your webhooks and ensure the integrity and authenticity of the received payloads.

Test webhook​

To test the connection between Logto and your services, simply click the "Send test payload" button. Logto will then send a sample payload for each selected event to your endpoint URL. These test requests contain anonymous data and are not logged in the recent request history.

This test ensures that your webhook is properly set up to receive and process payloads from Logto. It allows you to validate the integration before deploying the webhook in a live environment.

Monitor Webhook health status​

Logto provides convenient tools to monitor the health status of your webhooks and investigate any potential issues in detail:

  • Health status The webhook list in Logto displays the health status of each webhook, including the success rate and total number of requests made in the past 24 hours. This information gives you an overview of the webhook's performance. Deliveries that are still waiting for a retry are not counted as failures.
  • Independent request logs In the "Recent requests" section of each webhook, you can access the request logs for the past 48 hours. Each delivery is logged individually, allowing you to view the details of each request and investigate any potential errors or anomalies. A delivery that failed and is waiting for its next attempt shows as Retrying, together with the number of attempts made so far and the time of the next attempt.
  • Auto-retry When a delivery fails, Logto retries it for up to 24 hours. All attempts of a delivery are recorded in a single log entry, which is updated after each attempt, and carry the same deliveryId in the payload, so your endpoint can skip a delivery it has already processed.
  • Redelivery A delivery that has permanently failed can be sent again from its log entry.

By leveraging these monitoring features, you can effectively track the health of your webhooks, examine request logs, and ensure the reliability and performance of your webhook integrations.

Delivery and retries​

When an event occurs, Logto stores one delivery for each webhook that subscribes to the event, then sends the deliveries in the background. A stored delivery is not lost when Logto restarts, is redeployed, or crashes, and it waits while your endpoint is unavailable.

Each attempt reads the webhook's current endpoint URL, custom headers, and signing key, so changes you make to the webhook apply to deliveries that are still waiting. If you disable or delete a webhook, its waiting deliveries are not sent.

Retries​

Logto waits up to 10 seconds for your endpoint to respond. An attempt succeeds when the endpoint returns a 2xx status. Logto retries an attempt that fails with:

  • A network error, such as a refused connection or a DNS failure.
  • A timeout.
  • HTTP 408, 429, or any 5xx status.

Any other status, such as 400, 401, or 404, fails the delivery permanently without a retry.

Retries wait longer after each failed attempt, starting at 10 seconds and doubling up to 4 hours, and stop 24 hours after the event occurred. A delivery whose endpoint keeps failing is attempted at about these times after the event:

AttemptTime after the event
1Immediately
210 seconds
330 seconds
470 seconds
52.5 minutes
65 minutes
710.5 minutes
821 minutes
942.5 minutes
101.4 hours
112.8 hours
125.7 hours
139.7 hours
1413.7 hours
1517.7 hours
1621.7 hours

When the next attempt would fall after the 24-hour window ends, the delivery is logged as permanently failed. You can then redeliver it.

If your endpoint responds with a Retry-After header (in seconds or as an HTTP date), Logto waits at least that long before the next attempt, up to 4 hours. A Retry-After value shorter than the scheduled wait does not make the retry earlier.

note:

The per-webhook retries setting in the Management API is deprecated and has no effect. Every webhook uses the retry schedule above.

Delivery guarantees​

Logto delivers each event at least once while your endpoint recovers within the retry window: up to 24 hours, or until 10,000 deliveries are waiting for the webhook (within the 50,000 waiting deliveries allowed per tenant), whichever comes first. See Limits for what happens after that.

At-least-once delivery means your endpoint can receive the same delivery more than once, and deliveries can arrive late and out of order. Use the deliveryId to skip duplicates, and see handling out-of-order deliveries.

Limits​

To keep one slow endpoint or one busy tenant from delaying others, Logto applies these limits:

LimitValue
Requests in flight per webhook, on each Logto instance5
Requests in flight per tenant, on each Logto instance20
Requests in flight on each Logto instance100
Consecutive failures before a webhook's circuit opens5
Deliveries waiting to be sent per webhook10,000
Deliveries waiting to be sent per tenant50,000

Because Logto sends several requests at a time, your endpoint can receive requests for the same webhook concurrently.

  • Circuit breaker: After 5 consecutive failed attempts to a webhook, Logto pauses that webhook. Its waiting deliveries are held, and Logto sends one of them as a probe at each step of the retry schedule. When a probe succeeds, the remaining deliveries resume. Held deliveries still count against the 24-hour retry window.
  • Waiting delivery caps: When a webhook has 10,000 deliveries waiting, or a tenant has 50,000, new events for that webhook or tenant are not queued. Each of them is logged as a failed delivery right away, and you can redeliver it once your endpoint has caught up.

Redeliver a failed delivery​

You can send a permanently failed delivery again, for example after you fix an endpoint that was down for longer than the retry window:

  • Console: In the "Recent requests" section of the webhook, click Redeliver on a failed entry. Entries that are still retrying do not have this action.
  • Management API: Call POST /api/hooks/{id}/recent-logs/{logId}/redeliver, where {id} is the webhook ID and {logId} is the ID of the failed log entry. Logto responds with 202 and the logId of the new log entry that records the redelivery. See interact with Management API to learn how to call it.

A redelivery:

  • Sends the original request body, including its original deliveryId and createdAt, so your endpoint can deduplicate it against the earlier attempts.
  • Is signed with the webhook's current signing key and sent to its current endpoint URL.
  • Is recorded in a new log entry that references the failed entry in redeliveredFrom, and is retried on the same schedule as a new delivery.

The request body is rebuilt from the log entry, so fields that were masked or omitted in the log (such as secrets) are sent in the same sanitized form.

Logto rejects a redelivery with:

  • 404 when the webhook or the log entry does not exist, or the log entry belongs to another webhook.
  • 409 when a delivery or redelivery with the same deliveryId is already waiting or in progress.
  • 422 when the webhook is disabled, or the log entry is not a permanently failed delivery (for example, it is still retrying).
  • 429 when the webhook or tenant has reached its waiting delivery cap.

Recent requests cover the past 48 hours by default, so a delivery that fails at the end of its 24-hour retry window stays available for redelivery for at least another 24 hours.