Orbitoads
Browse documentation

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.

Markdown

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

EndpointHeader
POST /v1/campaignsrequired
POST /v1/campaigns/{ad_id}/copyrequired
POST /v1/campaigns/bulkrequired
POST /v1/campaigns/{ad_id}/budgetrequired
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.

Example
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 $KEY
Example
import 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 twice

What happens on a repeat

SituationResponse
First request with this keyRuns normally.
Same key, same request, first one finishedThe stored response, unchanged, with the header Idempotent-Replayed: true. Nothing runs again.
Same key, same request, first one still running409 IDEMPOTENCY_IN_PROGRESS + Retry-After. Retry shortly.
Same key, different body or endpoint422 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 5xxThe 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

MethodRouteParametersRequest contentResponse codes
POST/api/v1/campaignsIdempotency-Keyapplication/json · CreateSingleRequest | CreateBatchRequest202, 400, 401, 403, 404, 409, 422, 429, 503
POST/api/v1/campaigns/{ad_id}/copyad_id, account_id, Idempotency-Keyapplication/json · CopyRequest202, 400, 401, 403, 404, 409, 422, 429
POST/api/v1/campaigns/bulkIdempotency-Keyapplication/json · BulkRequest202, 400, 401, 403, 404, 409, 422, 429
POST/api/v1/campaigns/{ad_id}/budgetad_id, account_id, Idempotency-Keyapplication/json · BudgetRequest200, 400, 401, 403, 404, 409, 422, 429

Source · Data source

Schema fields and limits · Retrying a single operation

FieldDocumented value
Idempotency-KeyUUID
200 / 202Idempotent-Replayed: true
409IDEMPOTENCY_IN_PROGRESS, Retry-After
422IDEMPOTENCY_KEY_REUSED

Source · Data source

Reference revision

Pro Panel
Pro Panel