Skip to content

Can two API keys accidentally create duplicate tasks with the same request ID?

AISwapLab's creation request IDs are scoped to the account, not isolated by each API key. Reusing the same Idempotency-Key with the same normalized input can return the existing job, including when another permitted key belongs to that account. Reusing it with different input conflicts. Generate a distinct durable ID for each genuinely new approved task, and retain the original ID for network recovery.

RECOVER AND DELIVER API JOBSAISwapLab team · Editorial methodUpdated 3 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Allocate an ID when the user approves the task; Recover using the original request identity; Handle deliberate changes as a new approval.
Workflow diagram: Allocate an ID when the user approves the task → Recover using the original request identity → Handle deliberate changes as a new approval. Read the article for evidence and limits.

Separate a secret credential from the identity of the paid task

Rotating a credential should not create another media job by accident. The implementation looks up an existing request using the account owner and request key, then compares the normalized input fingerprint. Access and model-scope checks still apply; an account-wide namespace does not grant a key permission to every model. Different accounts do not share that namespace. A generic retry ID reused for unrelated users within one account can therefore collide even if their API keys differ.

What to do next

  1. 01

    Allocate an ID when the user approves the task

    Store an opaque application task ID, request payload and account owner before sending creation. Use a supported Idempotency-Key of 8–128 permitted characters. Avoid embedding names, emails or other sensitive content in it; uniqueness should come from task identity, not from a private description.

  2. 02

    Recover using the original request identity

    If a creation response is lost, retain the original key and input. Follow a known job ID where available; do not mint a new key merely because the network timed out. An idempotent replay returning the existing job is not a new generation and does not imply that the job has completed.

  3. 03

    Handle deliberate changes as a new approval

    If the user changes model, prompt, size or other normalized input, obtain the necessary quote and approval for that new task. Keep the earlier task's outcome separate. A 409 conflict should prompt inspection of the saved request, not automatic randomization of IDs to bypass the conflict.

A concrete example

Illustrative rotation: server key A submits task order-7f31a with one approved body. Its response is lost; key A is later rotated to key B under the same account. Reusing order-7f31a with the same supported input and permitted scope refers to the existing task. Reusing that value for a different image prompt conflicts. The application preserves that conflict instead of silently assigning another ID and potentially charging for work the user did not approve.

Request identity decisions

CaseExpected handling
Same account, same ID, same normalized inputReturn existing job when permitted
Same account, same ID, changed inputConflict; inspect original task
New approved taskNew durable ID
Different key, same accountNamespace is still account-wide

Before you call it ready

  • The application task ID is durable and account-aware.
  • Retries preserve the original normalized input and request key.
  • Credential rotation is not treated as a new paid task.

When to stop or choose another method

Stop automatic retries on an idempotency conflict. Compare the saved body and owner first; creating a fresh ID to suppress the error can turn a recovery attempt into a second purchase.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation