Authentication and wallet binding
POST/GET/PATCH/DELETE/api/payments/scheduled accept supported merchant/internal keys or merchant/consumer sessions. Creating, editing or cancelling requires control of the actual payer, plus applicable consumer save step-up.
The payer’s Circle signing identity is server-resolved from bound records. EXTERNAL or unbound/retired consumer wallets are rejected; body payerWalletId is ignored. No default-payer fallback is allowed.
Create — POST /api/payments/scheduled
Receiver merchant aliases can resolve to the current wallet. Success returns
scheduledPayment, message and nextStep; the newly stored status is ACTIVE and the reference starts sched_.
Read — GET /api/payments/scheduled
OptionalpayerSCA and status query fields. Rows are filtered to the caller’s controlled payer addresses and ordered by nextRunAt. A foreign supplied payer is 403; an authenticated caller with no controlled addresses gets an empty list.
Success contains count and scheduledPayments. A list is not evidence that the scheduler ran.
Edit/cancel
PATCH JSON requiresreference plus one or more of amount, intervalDays, description, maxRuns. Only ACTIVE plans are editable. Description is capped at 500 characters; changing cadence recomputes nextRunAt; null maxRuns permits indefinite recurrence.
PATCH currently parses amount/interval/maxRuns differently from strict create validation. Supply well-formed decimals/integers; do not assume excess precision or coercible strings are rejected identically. This unchanged validation difference needs separate review if stronger guarantees are required.
DELETE JSON requires reference; the stored status becomes CANCELLED. Both mutations enforce payer control and applicable consumer step-up, and return scheduledPayment/message. Cancelling a plan is not proof that an already-created transfer was reversed.
Execute — POST /api/payments/scheduled/run
The runner uses active internal service-key authentication, not the merchant/session union. It processes eligible platform-wide schedules, rather than accepting a merchant reference as a harmless manual-pay request. Configure it privately through an owner-operated scheduler; never expose the service key to a browser. The runner invokes the payments rate-limit tier, claims due ACTIVE or stale PROCESSING rows, refuses null signing wallets/unknown tokens, and revalidates current consumer binding before fresh creation. It uses period-specific tracked PaymentLog IDs and advances the schedule on confirmation. These source controls are not a blanket proof of live crash safety or database contention. Success includescheckedAt, dueCount, executedCount, failedCount and per-row results. A skipped in-progress result is not a newly paid row. Inspect each result and its existing Circle transaction/receipt before another debit.
scheduled_payment.executed includes the reference, token amount, hash/explorer, run count/next deadline and resume/replay flags. Outbound notifications are unsigned/best-effort.

