# Salesloft webhooks in production: duplicates, ordering, retries and timeouts

Agent skill: `npx skills add hookdeck/webhook-skills --skill salesloft-webhooks` ([details](https://hookdeck.com/webhooks/salesloft/skill))

This guide covers the problems Salesloft webhooks cause in production and how to handle each one. What Salesloft sends is on the [Salesloft webhooks](/webhooks/salesloft) overview, every event type is on [Salesloft webhook events](/webhooks/salesloft/events), and signature verification code is on [Verify Salesloft webhooks](/webhooks/salesloft/verify).

## At a glance

| Problem | What to do | With Event Gateway |
| --- | --- | --- |
| [Timeouts](#timeouts) | Respond at once; process in a background job | Accepts the delivery at once, then queues it for your service |
| [Duplicates](#duplicates) | Key on event type, resource ID and `updated_at`; upsert | Can drop repeats based on fields you choose |
| [Ordering](#ordering) | Compare `updated_at`, or fetch current state from the API | Logs every delivery and attempt, so you can see arrival order when debugging |
| [Retries](#retries) | Reconcile with Salesloft's cursor polling | Accepts deliveries while your service is down and replays them |
| [Choosing events](#choosing-events) | Subscribe per event; check scopes and permissions | Filters and routes by the event header |
| [Testing](#testing) | Forward deliveries to localhost; capture real bodies | Forwards to localhost and replays past deliveries |
| [Other limits](#other-limits) | Answer `link_swap` from your own service; don't rely on the token in the payload | Handles every event except `link_swap` |

## Salesloft webhook timeouts and slow handlers {#timeouts}

Respond straight away, then do the work in a background job.

**Why it happens:** Salesloft doesn't publish how long it waits for a response, or which responses it treats as failing. A handler that writes to a CRM or calls other services before responding risks using up one of very few retries.

**Fix it in your handler:**

1. Verify the signature, store the event and return `200`.
2. Process the event from a queue. See [why to process webhooks asynchronously](/webhooks/guides/why-implement-asynchronous-processing-webhooks).
3. Keep calls to other services out of the request path.

`link_swap` is the exception, because Salesloft waits for your answer. See [other limits](#other-limits).

**With Event Gateway:** Hookdeck accepts each Salesloft delivery immediately, then queues it and delivers it to your service at a rate you set, with its own retries. Your handler can take as long as it needs without failing a Salesloft attempt.

## Duplicate Salesloft webhooks {#duplicates}

Salesloft documents no event ID, so nothing marks a repeat. Build your own key, and write updates as upserts.

**Why it happens:** Salesloft retries a failing webhook, so a handler that finished its work and then failed to respond can receive the same event again. Salesloft's docs list two delivery headers, and neither identifies the delivery.

**Fix it in your handler:**

1. Build an idempotency key from `x-salesloft-event`, the resource `id` and a field that changes with each update. Salesloft's API objects carry `updated_at`, but only `link_swap` has a published webhook body, so confirm the field on a captured delivery.
2. Write updates as upserts keyed on the Salesloft resource ID, so a repeat changes nothing.
3. Make each handler [idempotent](/webhooks/guides/implement-webhook-idempotency): the same result however many times it runs.

**With Event Gateway:** Hookdeck's [deduplication](/docs/deduplication) can drop repeated deliveries based on the header and body fields you choose.

## Out-of-order Salesloft webhooks {#ordering}

Salesloft doesn't document delivery order, so don't depend on it. Compare `updated_at`, or fetch the resource when order matters.

**Why it happens:** A retried delivery arrives at least 15 seconds after the original, and by then a newer event for the same resource may have been delivered. Applied in arrival order, the older copy overwrites the newer one. For more on the general problem, see [Webhook Ordering: Why It's Hard and How to Handle It](/webhooks/guides/webhook-ordering-why-its-hard-and-how-to-handle-it).

**Fix it in your handler:**

1. Store the `updated_at` of the version you last applied, and skip anything older once you've confirmed the field in your captured deliveries.
2. When your next step depends on current state, fetch the resource from the Salesloft API.
3. Expect a `_deleted` event to arrive before a late retry of an earlier update, and don't recreate the record.

**With Event Gateway:** Hookdeck logs every delivery and attempt, so you can see the order things arrived in when you debug a problem. It doesn't reorder events for you.

## Salesloft webhook retries {#retries}

Salesloft retries a failing webhook three more times, 15 seconds apart, then marks it as failed. Plan on reconciling from the API after any longer outage.

**Why it happens:** Those retries cover about 45 seconds, plus however long each attempt takes, so a deploy or restart can outlast them. Salesloft's docs describe no later redelivery and no way to resend a failed delivery. Its own guides also describe polling as a way to read changes, sorted on `updated_at`.

**Fix it in your handler:**

1. Keep the endpoint available during deploys, and respond quickly so slow requests don't count against you.
2. Run a scheduled sync that asks for changes since your last cursor, as in Salesloft's [cursor poller guide](https://developers.salesloft.com/docs/platform/guides/building-an-efficient-cursor-poller/): `sort=updated_at&sort_direction=ASC&updated_at[gt]=...`.
3. Check that subscriptions are still `enabled` by listing them through the Webhook Subscriptions API.

**With Event Gateway:** Hookdeck accepts each delivery as soon as it arrives and stores it, so Salesloft's attempts succeed even during your downtime. Hookdeck then delivers with [automatic retries](/docs/retries) you configure and lets you replay anything that still fails.

## Choosing Salesloft events {#choosing-events}

Each subscription covers one `event_type`, so subscribe only to what you use, and check its scope and permissions first.

**Why it happens:** Most events need a read scope, such as `people:read` or `calls:read`, and `email_with_body_and_subject_updated` needs `email_contents`. Some also need user permissions, such as View Team Calls or View All People. Salesloft warns that without the correct permissions "the corresponding data will not be available".

**Fix it in your handler:**

1. Pick events from [the event list](/webhooks/salesloft/events), and request only the scopes they need.
2. Authorize with a user who has the matching permissions.
3. Route on `x-salesloft-event`, since the body has no documented type field, and acknowledge any value you don't handle.
4. If subscriptions share a URL, use one `callback_token` across them, or map each event to its own token.

**With Event Gateway:** Hookdeck can filter and route deliveries on the `x-salesloft-event` header, so each service receives only the events it handles.

## Testing Salesloft webhooks {#testing}

Forward real deliveries to your machine, and treat the first one of each type as your fixture.

**Why it's awkward:** Salesloft documents no test event, so you have to trigger each one by changing data in Salesloft. It publishes no body for any event except `link_swap`. It says each event delivers the resource's object, so the API reference is a guide to the fields, but not proof of the webhook body.

**How to test:**

1. Run `hookdeck listen 3000 salesloft --path /webhooks/salesloft` and use the URL it prints as the `callback_url`.
2. Create a person or add a call in Salesloft and watch the request arrive.
3. Save the headers and raw body of the first delivery of each type, and write your handler's tests from those.
4. Delete test subscriptions when you've finished.

**With Event Gateway:** The same CLI forwards to localhost, and Hookdeck keeps the headers and raw body of every request, so you can replay a real delivery against your handler as many times as you need.

## Other Salesloft webhook limits {#other-limits}

`link_swap` isn't a notification, so it can't go through a queue, and two smaller limits affect how you trust a delivery.

**`link_swap` needs your response.** When an email is sent, Salesloft posts the email's links to your URL and waits for you to answer, so the new links can go into the email before it leaves. Your response is a JSON object whose `links` map has each old link as a key and its new link as the value. Salesloft doesn't say what happens to the email if your response is slow, an error or missing that map, so test this and ask Salesloft before you depend on it.

**The `callback_token` may not be in the body.** The subscription schema says Salesloft sends the `callback_token` in the payload of each event, but the published `link_swap` body has no such field, and no page says where it sits. Verify the `x-salesloft-signature` header instead, which covers the whole body.

**Nothing limits replay.** Salesloft documents no timestamp, so a captured request still verifies if it's sent again. Idempotent handlers limit the damage.

**Fix it in your handler:**

1. Answer `link_swap` synchronously, from your own service, with the replacement links, and give it its own URL if your other events go through a queue.
2. Verify the signature on `link_swap` as you do for any other event. The guide gives it the same header and scheme.
3. Rely on the signature header rather than a token in the body.

**With Event Gateway:** Hookdeck verifies the signature on the other events and queues them. It answers each delivery itself, and [can't return your service's response](/docs/sources#custom-responses) to Salesloft, so your replacement links wouldn't reach the email. Keep the `link_swap` subscription pointed directly at your own service.