{"openapi":"3.1.0","info":{"title":"cron402 API","version":"0.1.0","description":"Cron-as-a-service for AI agents. Schedule webhook calls and pay per run in USDC on Base via the x402 protocol.\n\n## Payment\nPaid endpoints are x402 resources. Send an unauthenticated request; you receive `402 Payment Required` with payment instructions in the `PAYMENT-REQUIRED` header. Sign an EIP-3009 USDC transfer (0.008 USD per run unless noted) with any x402 client and retry the identical request.\n\n## Management auth\npause/resume/delete require two headers signed by the payer key:\n- `x-cron402-timestamp`: unix ms, valid ±5 minutes\n- `x-cron402-signature`: EIP-712 signature over ManageJob { action, jobId, timestamp }, domain { name: \"cron402\", version: \"1\" }\n\n## Limits\nMin interval 1 minute · max 1000 active jobs per wallet · logs kept last 100 runs / 30 days.","contact":{"name":"cron402","url":"https://github.com/userdefault13/ai-cron-site"},"license":{"name":"MIT"}},"servers":[{"url":"https://cron402-api.user-defaults.workers.dev"}],"tags":[{"name":"jobs","description":"Create and inspect cron jobs"},{"name":"billing","description":"Prepaid run credits"},{"name":"management","description":"Wallet-signed job control"}],"paths":{"/v1/crons":{"post":{"tags":["jobs"],"summary":"Create a cron job ($0.008, includes 1 run credit)","description":"Schedules a recurring webhook call. The target URL is called on schedule with up to 3 attempts per run.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"schedule":{"type":"string","minLength":9,"maxLength":64},"target":{"type":"object","properties":{"url":{"type":"string","format":"uri","maxLength":2048},"method":{"type":"string","enum":["GET","POST"],"default":"POST"},"headers":{"type":"object","additionalProperties":{"type":"string","maxLength":256}},"body":{"type":"string","maxLength":16384}},"required":["url"],"additionalProperties":false},"maxRuns":{"type":"integer","minimum":1,"maximum":10000},"notifyUrl":{"type":"string","format":"uri","maxLength":2048,"description":"Optional webhook that receives a POST after every execution with the run result"}},"required":["schedule","target"],"additionalProperties":false}}}},"responses":{"201":{"description":"Job created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"statusUrl":{"type":"string"},"credits":{"type":"integer"}},"required":["id","statusUrl","credits"],"additionalProperties":false}}}},"400":{"description":"Invalid request body or cron schedule","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}},"402":{"description":"Payment required to create a job — 402 Payment Required with x402 instructions in the PAYMENT-REQUIRED header. Pay with any x402 client (e.g. @x402/fetch + a USDC wallet on Base) and retry the identical request.","content":{"application/json":{"schema":{"type":"object"}}}},"429":{"description":"Active job limit reached for payer wallet","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}}}}},"/v1/crons/topup/{pack}":{"post":{"tags":["billing"],"summary":"Add prepaid run credits ($0.008 × pack size)","description":"Packs: 1 → $0.008, 10 → $0.08, 100 → $0.80. Permissionless: any wallet may fund any job. Reactivates exhausted/paused jobs.","parameters":[{"name":"pack","in":"path","required":true,"schema":{"type":"string","enum":["1","10","100"]}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"jobId":{"type":"string","format":"uuid","description":"Job to credit"}},"required":["jobId"],"additionalProperties":false}}}},"responses":{"200":{"description":"Credits added","content":{"application/json":{"schema":{"type":"object","properties":{"jobId":{"type":"string"},"runsAdded":{"type":"integer"},"credits":{"type":"integer"}},"required":["jobId","runsAdded"],"additionalProperties":false}}}},"400":{"description":"jobId missing or malformed","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}},"402":{"description":"Payment required for credit pack — 402 Payment Required with x402 instructions in the PAYMENT-REQUIRED header. Pay with any x402 client (e.g. @x402/fetch + a USDC wallet on Base) and retry the identical request.","content":{"application/json":{"schema":{"type":"object"}}}},"404":{"description":"Job not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}}}}},"/v1/crons/{id}":{"get":{"tags":["jobs"],"summary":"Job status, credits, and last 20 executions (free)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Job view with execution log","content":{"application/json":{"schema":{"allOf":[{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"payerAddress":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"},"schedule":{"type":"string","description":"Standard 5-field cron expression (UTC)"},"target":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"method":{"type":"string"}},"required":["url","method"],"additionalProperties":false},"credits":{"type":"integer","description":"Remaining prepaid runs"},"status":{"type":"string","enum":["active","paused","exhausted","deleted"]},"nextRunAt":{"type":"integer","nullable":true,"description":"Unix ms of next scheduled fire"},"createdAt":{"type":"integer"}},"required":["id","payerAddress","schedule","target","credits","status","nextRunAt","createdAt"],"additionalProperties":false}],"properties":{"executions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"number","description":"Execution row id"},"jobId":{"type":"string","format":"uuid"},"runAt":{"type":"integer","description":"Unix ms when the run was attempted"},"ok":{"type":"integer","minimum":0,"maximum":1,"description":"1 if the webhook returned a 2xx status"},"statusCode":{"type":"integer","nullable":true,"description":"HTTP status of the last attempt"},"error":{"type":"string","nullable":true,"description":"Error summary from the last attempt"},"durationMs":{"type":"integer","description":"Duration of the successful/last attempt in ms"}},"required":["id","jobId","runAt","ok","statusCode","error","durationMs"],"additionalProperties":false}}},"required":["id","payerAddress","schedule","target","credits","status","nextRunAt","createdAt","executions"]}}}},"404":{"description":"Job not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}}}},"delete":{"tags":["management"],"summary":"Delete a job (wallet-signed)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"x-cron402-timestamp","in":"header","required":true,"description":"Unix milliseconds; must be within ±5 minutes of server time","schema":{"type":"integer"}},{"name":"x-cron402-signature","in":"header","required":true,"description":"EIP-712 signature from payer key over ManageJob { action, jobId, timestamp }, domain { name: \"cron402\", version: \"1\" }, primaryType \"ManageJob\"","schema":{"type":"string"}}],"responses":{"200":{"description":"Job deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"id":{"type":"string"},"status":{"const":"deleted"}}}}}},"401":{"description":"Missing signature headers","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}},"403":{"description":"Invalid signature or wrong payer","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}},"404":{"description":"Job not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}}}}},"/v1/crons/{id}/pause":{"post":{"tags":["management"],"summary":"Pause a job (wallet-signed)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"x-cron402-timestamp","in":"header","required":true,"description":"Unix milliseconds; must be within ±5 minutes of server time","schema":{"type":"integer"}},{"name":"x-cron402-signature","in":"header","required":true,"description":"EIP-712 signature from payer key over ManageJob { action, jobId, timestamp }, domain { name: \"cron402\", version: \"1\" }, primaryType \"ManageJob\"","schema":{"type":"string"}}],"responses":{"200":{"description":"Job paused"},"401":{"description":"Missing signature headers","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}},"403":{"description":"Invalid signature or wrong payer","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}},"404":{"description":"Job not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}}}}},"/v1/crons/{id}/resume":{"post":{"tags":["management"],"summary":"Resume a paused/exhausted job (wallet-signed, requires credits)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"x-cron402-timestamp","in":"header","required":true,"description":"Unix milliseconds; must be within ±5 minutes of server time","schema":{"type":"integer"}},{"name":"x-cron402-signature","in":"header","required":true,"description":"EIP-712 signature from payer key over ManageJob { action, jobId, timestamp }, domain { name: \"cron402\", version: \"1\" }, primaryType \"ManageJob\"","schema":{"type":"string"}}],"responses":{"200":{"description":"Job active again"},"400":{"description":"No credits; top up first","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}},"401":{"description":"Missing signature headers","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}},"403":{"description":"Invalid signature or wrong payer","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}},"404":{"description":"Job not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"issues":{"type":"object","additionalProperties":{}}},"required":["error"],"additionalProperties":false}}}}}}},"/health":{"get":{"tags":["jobs"],"summary":"Liveness probe (free)","responses":{"200":{"description":"Service healthy","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"service":{"const":"cron402-api"},"version":{"type":"string"}}}}}}}}}},"x-402-network":"eip155:8453"}