# Idempotency

### How it works

Include an `Idempotency-Key` header with a unique value on any POST request:

```bash
curl -X POST https://zynta-lastmile-api.up.railway.app/api/v1/off-ramp \
  -H "x-api-key: sk_live_..." \
  -H "Idempotency-Key: txn-abc-123-unique" \
  -H "Content-Type: application/json" \
  -d '{"quoteId": "...", "recipientId": "..."}'
```

If you send the same request with the same idempotency key:

* **Same body** — returns the original response without creating a duplicate
* **Different body** — returns a `409 Conflict` error

### Key rules

* Keys must be unique per request — use UUIDs or a combination of your internal reference and timestamp
* Keys expire after **24 hours**
* Keys are scoped to your API key — different API keys can use the same idempotency key without conflict

{% hint style="danger" %}
**Always** use idempotency keys when creating transfers. A duplicate transfer means a duplicate payment.
{% endhint %}

### Generating good keys

```javascript
// UUID
const key = crypto.randomUUID();

// Deterministic (based on your internal data)
const key = `offramp-${invoiceId}-${Date.now()}`;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zynta.com/guides/idempotency.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
