---
title: "Idempotency"
description: "Retry anything that spends money, without spending it twice."
---

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

# Idempotency

Every route that spends money, holds inventory, sends mail or adds a record to
the CRM requires an `Idempotency-Key` header. The key is checked at the edge, so
a missing or malformed one never reaches business logic.

```http
Idempotency-Key: 8f2a1c40-4a1e-4a7e-9a0f-2f1c0b7a91d3
```

Keys are free-form text between 8 and 255 characters. A UUID is a good default
because it is unique without coordination, but anything stable and unguessable
works.

> **One key per intention, not per attempt**
>
> Generate the key when you decide to do something, and reuse it for every retry
> of that same thing. A key generated per HTTP call defeats the entire mechanism:
> a timeout you retry with a fresh key is how a traveler gets charged twice.

## What replaying does

1. **Step 1**

   ### Same key, same body

   You get the original result back. The work is not repeated: no second order, no
   second charge, no second email. This is what makes a network timeout safe to
   retry.
2. **Step 2**

   ### Same key, different body

   409, with a code naming the conflict — `COMMERCE_IDEMPOTENCY_CONFLICT` when
   creating an order, `BOOKING_SELECTION_IDEMPOTENCY_CONFLICT` when holding a
   selection, `CRM_IDEMPOTENCY_CONFLICT` in the CRM. The platform cannot tell which
   of the two requests you meant, so it refuses both rather than guessing.
3. **Step 3**

   ### New key

   A new operation, every time. Reusing a key across two genuinely different
   bookings is the one mistake this header cannot protect you from.

## Routes that require a key

| Route | What it does |
| --- | --- |
| `POST /booking/selections` | Holds an offer with the supplier |
| `POST /booking/quotes` | Freezes price, payment terms and policy |
| `POST /booking/trips/{travelersTripId}/insurance-quotes` | Requests insurance quotes |
| `POST /commerce/orders` | Creates an order from quotes |
| `POST /commerce/orders/{orderId}/actions` | Submits checkout, creates a payment link |
| `POST /commerce/orders/{orderId}/payments` | Takes a payment |
| `POST /commerce/orders/{orderId}/confirmation-emails` | Sends confirmation mail |
| `POST /commerce/payment-methods/actions` | Stores or links a card |
| `POST /commerce/external-payments` | Records or reverses a payment taken elsewhere |
| `POST /crm/travelers` | Adds a traveler |
| `POST /crm/travelers/import` | Adds up to 200 travelers |
| `POST /crm/travelers/{travelerId}/invitation` | Invites a traveler by email or SMS |
| `POST /crm/travelers/{travelerId}/merge` | Merges a duplicate traveler |
| `POST /crm/notes` | Adds a note |
| `POST /crm/tasks` | Adds a task, or a template's tasks |

Everything not in this table is either safe to repeat — reads, and the
last-write-wins updates — or guarded by state, like a segment that can only be
approved once or a traveler that changes only with the
[revision](https://docs.nicer.travel/developers/crm#idempotency-keys-and-revisions) you read.

Source: https://docs.nicer.travel/developers/idempotency/index.mdx
