> For the complete documentation index, see [llms.txt](https://kollect.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kollect.gitbook.io/docs/guides/best-practices.md). Agents can also search and read this documentation through its [MCP server](https://kollect.gitbook.io/docs/~gitbook/mcp).

# Best practices

Operational guidance for reliable **S2S** and **webhook** integrations.

***

## Security

* **Rotate secrets** if you suspect compromise; use **regenerate-secret** for webhook signing keys and re-issue API credentials per product policy.
* **Never** log raw API keys, secrets, or webhook signing secrets.
* **Verify** the webhook signature (`x-kollect-signature` or `x-kollect-signature-v2`) on **every** delivery before side effects.

***

## Request signing

* Sync servers with **NTP**; signature timestamps are rejected outside **±300 seconds** (this window is fixed in code, not configurable).
* Hash the **exact raw HTTP body** you send; avoid "pretty-print then sign" mismatches.

***

## Idempotency

* Use a **stable idempotency key per business transaction** (order id, cart id, or UUID stored with the order).
* Do **not** reuse keys across different customers or amounts.

***

## Interface selection

* Leave `interface` **unset** on `POST /sdk/server/create-payment` unless you have a specific reason to override it — it defaults to `kollect-server`, which is what gates outbound webhook delivery. Passing `kollect-app` or `kollect-sdk` explicitly will silently disable webhooks for that payment.

***

## Webhooks

* Respond in **under a few seconds** (Kollect uses a **10s** outbound timeout per attempt, up to 4 attempts with backoff).
* Return **2xx** after validation and **enqueue** fulfillment work — retries stop as soon as you return 2xx.
* Implement **idempotent** handlers keyed by **`eventId`** (preferred) or `paymentId` — delivery is at-least-once, so redelivery of an already-processed event is expected, not exceptional.
* Register the correct **`scope`** (`invoice_settlement` for S2S payments) — a webhook registered under the wrong scope never receives these events.

***

## Failure handling

* **429:** Retry with exponential backoff and respect `details` when present.
* **409:** Resolve idempotency conflicts; do not blindly retry with the same key and altered body.
* **5xx:** Retry create-payment only with the **same** idempotency key and unchanged body.

***

## Redis and infrastructure

* If idempotency or rate limiting returns **503**, involve platform ops; **Redis** may be required in production.

***

## Related pages

* [Rate limits](https://kollect.gitbook.io/docs/reference/rate-limits.md)
* [Error handling](https://kollect.gitbook.io/docs/reference/error-handling.md)
