send_code
Queue an assigned code to the participant who holds it, by email, SMS or both. SENDS A REAL MESSAGE — it leaves the platform and cannot be recalled. There is no address field: the recipient is whoever holds the code. confirm=true is REQUIRED; set it only after the user approved sending to that specific participant. both sends on each channel the participant has a usable address for. Account suppressions and rate limits are enforced server-side. Pass idempotency_key only if the user gave you one — retrying with the same key never sends twice; do not invent one. Requires the Send Message module enabled on the account — on 403 "module not enabled", do NOT retry; tell the user to contact Sweeppea support. When a send is refused, call fetch_messaging_usage first: it is what distinguishes module access, plan channels, an exhausted allowance, a sending pause and a missing 10DLC number. Direct sending is a SEPARATE account switch from the module: fetch_messaging_usage can report ModuleEnabled true while DirectMessageEnabled is false, and this call then returns 403 "Direct messages through the API are not enabled for your account yet" (observed in production 2026-09-30). That is account configuration, not a bug — do NOT retry; tell the user to contact Sweeppea support.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes | email, sms or both. both sends on each channel the participant has a usable address for | |
| confirm | Yes | Must be true. Set it ONLY after the user explicitly approved THIS action in this conversation, having been told what it does and that it cannot be taken back: a real email and/or SMS carrying this code goes out to the participant who holds it, and cannot be recalled. Never assume, never carry an approval over from a previous item, never set it to satisfy the schema. | |
| coupon_token | Yes | The code token (UUID v4) of a code already assigned to a participant | |
| idempotency_key | No | Optional, 8 to 64 characters [A-Za-z0-9_-]. Retrying with the same key never sends twice. Only pass one the user supplied |