Swarmz

Idempotency

How each endpoint behaves on retry — which carry an idempotency key, which are idempotent by state, and how to treat a terminated tenant.

Network calls fail and get retried. Every Platform API endpoint is designed so that a retry is safe, but the mechanism differs by endpoint. There are three patterns:

  • Keyed. A retry is recognized by an explicit key and returns the original result. create keys on (account, external_ref); topup keys on an idempotency_key you supply, scoped per tenant.
  • By state. The endpoint reads the tenant's current status and short-circuits if the work is already done — suspend, unsuspend, and terminate return already: true.
  • Naturally safe. plan overwrites, so re-sending is harmless; sso mints a fresh token each time; usage is a pure read.

Per-endpoint behavior

EndpointIdempotency keyOn retry
create(account, external_ref)Same tenant_id / dashboard_url; entitlements not overwritten
plannoneOverwrites entitlements; safe to re-send
topupidempotency_key (per tenant)No-op; returns current balances
ssononeFresh token each call
suspendby stateAlready-suspended → already: true
unsuspendby stateAlready-active → already: true
terminateby stateAlready-terminated or gone → already: true
usagen/aPure read

The post-terminate asymmetry

After terminate, expect 404 — not 410

terminate deletes the workspace row, so a later sso, plan, or topup against that id returns 404 tenant_not_found, not 410 terminated — there is no row left to mark as terminated. Treat 404 and 410 identically: the service is gone, do not retry.

On this page