Idempotency
Assign a new Idempotency-Key to each create, copy, bulk request or budget change. Keep the same key and body on retries. A conflicting operation is rejected if it reuses the identifier.
Networks fail in the worst place: after your request reached us, before the answer reached you. Retrying a top-up blindly could move money twice; retrying a create could launch the same campaign twice. An Idempotency-Key makes the retry safe.
Where it is required
| Endpoint | Header |
|---|---|
POST /v1/campaigns | required |
POST /v1/campaigns/{ad_id}/copy | required |
POST /v1/campaigns/bulk | required |
POST /v1/campaigns/{ad_id}/budget | required |
Other writes (PATCH, pause/resume, DELETE, media) | optional — they are safe to repeat on their own |
Without the header these return 400 IDEMPOTENCY_KEY_REQUIRED.
How to use it
Generate a new random value — a UUID — for each operation, and send the same value every time you retry that operation.
KEY=$(uuidgen)
curl -X POST https://orbitoads.pro/api/v1/campaigns/90412/budget \
-H "X-API-Key: $ORBITO_API_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: $KEY" \
-d '{"account_id":53,"action":"add","amount":5}'
# timed out? run exactly the same command again, with the same $KEYimport uuid, requests
def add_budget(ad_id, account_id, amount):
key = str(uuid.uuid4()) # one per operation
for attempt in range(3):
try:
return requests.post(
f"https://orbitoads.pro/api/v1/campaigns/{ad_id}/budget",
headers={"X-API-Key": API_KEY, "Idempotency-Key": key},
json={"account_id": account_id, "action": "add", "amount": amount},
timeout=30,
)
except requests.Timeout:
continue # same key → never added twiceWhat happens on a repeat
| Situation | Response |
|---|---|
| First request with this key | Runs normally. |
| Same key, same request, first one finished | The stored response, unchanged, with the header Idempotent-Replayed: true. Nothing runs again. |
| Same key, same request, first one still running | 409 IDEMPOTENCY_IN_PROGRESS + Retry-After. Retry shortly. |
| Same key, different body or endpoint | 422 IDEMPOTENCY_KEY_REUSED. A new operation needs a new key. |
| First request ended in a 4xx (bad input, plan, queue full…) | The key is released: fix the request and send it with the same key. |
| First request ended in a 5xx | The 5xx is stored and replayed — the change may have reached Telegram, and the key exists to stop it running twice. Check the campaign with GET, then use a new key if you still want to act. |
“Same request” means the same method, path and JSON body (key order doesn’t matter).
Details
- Keys are scoped to your API key — two integrations can’t collide.
- Keys are kept for 24 hours. After that the same value starts a new operation.
- Any string of 8–255 characters works; a UUID is the right default.
- If we can’t record the key, the operation doesn’t run and you get
503 IDEMPOTENCY_UNAVAILABLE— retry with the same key.
The full advertising contract requires a dedicated provider credential for this workspace. Use your Orbito API key for client calls. Account orders, provisioning and external billing are separate workflows.
Implementation notes
One identifier per operation
Create, copy, bulk and budget operations require Idempotency-Key. Use a new random value of 8–255 characters for each operation and reuse it for its retries. Keys last 24 hours per API key and bind method, path and JSON content.
Concurrent and changed retries
Completed calls replay with Idempotent-Replayed: true. A pending duplicate returns 409 and Retry-After. Reusing a key for a different request returns 422. A 4xx validation failure releases the key. After a stored 5xx read the actual object before issuing a fresh operation.
Operations and fields
Idempotency-Key Idempotent-Replayed 409 IDEMPOTENCY_IN_PROGRESS 422 IDEMPOTENCY_KEY_REUSED
- Idempotency-Key
- Idempotent-Replayed
- 409 IDEMPOTENCY_IN_PROGRESS
- 422 IDEMPOTENCY_KEY_REUSED
Request example
GET /api/v1/tasks/{id} HTTP/1.1 Host: orbitoads.pro X-API-Key: {key}
Schema fields and limits
This table follows the public v1 contract. Parameter and field names are case-sensitive. For each operation, the HTTP response codes distinguish a successful result, input validation and access checks. The linked specification defines the full request and response shapes.
Protocol reference
| Method | Route | Parameters | Request content | Response codes |
|---|---|---|---|---|
| POST | /api/v1/campaigns | Idempotency-Key | application/json · CreateSingleRequest | CreateBatchRequest | 202, 400, 401, 403, 404, 409, 422, 429, 503 |
| POST | /api/v1/campaigns/{ad_id}/copy | ad_id, account_id, Idempotency-Key | application/json · CopyRequest | 202, 400, 401, 403, 404, 409, 422, 429 |
| POST | /api/v1/campaigns/bulk | Idempotency-Key | application/json · BulkRequest | 202, 400, 401, 403, 404, 409, 422, 429 |
| POST | /api/v1/campaigns/{ad_id}/budget | ad_id, account_id, Idempotency-Key | application/json · BudgetRequest | 200, 400, 401, 403, 404, 409, 422, 429 |
Source · Data source
Schema fields and limits · Retrying a single operation
| Field | Documented value |
|---|---|
| Idempotency-Key | UUID |
| 200 / 202 | Idempotent-Replayed: true |
| 409 | IDEMPOTENCY_IN_PROGRESS, Retry-After |
| 422 | IDEMPOTENCY_KEY_REUSED |
Source · Data source
Reference revision