QivunaDevelopers

Idempotency keys

A network error after you sent sendMessage leaves you not knowing whether the message went out. Send an Idempotency-Key and retry with the same key: you get the first answer again instead of a second message.

Usage#

POST https://bots.qivuna.com/v1/sendMessage
Authorization: Bot 7123456789:qvb1_…
Idempotency-Key: upd-1044-reply
Content-Type: application/json

{"chat_id": 4503600212045337, "text": "Your order is confirmed."}

Behaviour#

SituationAnswer
First request with a keyRuns normally. A successful (2xx) answer is stored.
Same key, same request, within 1 hourThe stored answer, byte for byte, with its status. Nothing runs again. The X-Request-Id header is new.
Same key, different request409 idempotency_mismatch.
Same key while the first request is still running409 idempotency_in_progress at once. Retry shortly with the same key.
The first request was refused (4xx, 5xx)Nothing is stored: a retry runs again and may succeed.

When to retry#

The SDKs add a generated key to every write and retry exactly these cases.