Claude Code one-off routine: fire one Sume run once, rerun safely
A one-off routine auto-disables after firing. If you rerun it, send the same Sume Idempotency-Key so a repeat doesn't create a second paid run.

A one-off Claude Code routine fires a single time at a chosen moment and then disables itself. If it fails and you rerun it, the saved prompt runs again, so any Sume call inside needs to be safe to repeat. Sume's Format run endpoint accepts an Idempotency-Key: the same key with the same body returns 200 with idempotency_hit: true instead of creating a second run.
Routine behavior is on Anthropic's routines page, read on 2026-10-03; the key semantics are in Sume's Calling a Format.
What does one-off mean?
The routines page says a one-off run auto-disables once it fires, and that a re-run counts against the limits shared with Run now and API fires, 30 per hour per routine. Reruns are therefore normal after an infrastructure error. Also remember that a green status means the session exited cleanly, not that the task worked.
What does the key do on Sume?
POST /v1/formats/{handle}/{slug}/runs takes Idempotency-Key. A repeat with the same body returns 200 and idempotency_hit: true with the original run; a different body under the same key returns 409. Pick a key that names the job, not the attempt.
| Request | Result |
|---|---|
| New key | Run created |
| Same key, same body | 200 with idempotency_hit: true |
| Same key, different body | 409 |
How do I build the key?
Derive it from the thing being made, so every attempt of the routine arrives at the same value. This helper does that and runs offline.
import hashlib, json
def run_key(product_id, brief):
body = json.dumps({'p': product_id, 'b': brief}, sort_keys=True)
return 'launch-' + hashlib.sha256(body.encode()).hexdigest()[:24]
k1 = run_key('sku-17', 'autumn launch, 15s')
k2 = run_key('sku-17', 'autumn launch, 15s')
assert k1 == k2
print(k1)What else should the routine do?
Keep the saved prompt short and explicit about what counts as done: the run receipt shows status, and a Format run that finished with a degraded outcome is not the same as one that finished clean. If the routine cannot confirm the receipt, it should say so in its final message rather than report success, and leave the key unchanged for the next attempt. Retrying with the same key and body costs nothing extra; changing either can.
- Send
generation_spend_cap_usdon the run, at most $500, and nevernull. - Check the receipt and
outcomebefore saying it worked. - If the run is long, stop and let a webhook or a later check pick up the result.
- If the key returned
409, change the body back, not the key.
Sources
Related posts
More in Developers
- Claude Code routine 403 host_not_allowed: allow Sume's hosts
A routine's curl to api.sume.com fails with 403 and x-deny-reason host_not_allowed on Trusted network. Which hosts to add, and why the connector is exempt.
- Claude Code routines run hourly at most: use a Sume webhook
A routine's minimum schedule interval is one hour, so a polling loop wastes runs. Submit the Sume job once and let the terminal webhook trigger the next step.
- Claude Code routine skips approvals: cap Sume calls with script_run
A routine can use every tool without asking. Sume's script_run bounds a batch of calls with max_calls and max_paid_calls, so one run cannot fan out.
- Where to keep a Sume API key in a Claude Code routine
Environment variables are readable by anyone using the environment. On Pro and Max an API credential hides the key from Claude. What changes on Team plans.
Written by Sume