# ZipCrunch SMS API > REST/JSON API for sending SMS and MMS, tracking message status, receiving replies, and managing media, > opt-outs and webhooks. Base URL: https://sms.zipcrunch.io/api/v1 - OpenAPI 3.1 spec: https://sms.zipcrunch.io/api/v1/openapi.json - Interactive reference (Swagger UI): https://sms.zipcrunch.io/ - Human docs: https://vaspiandocs.com (ZipCrunch SMS API) - Support: support@vaspian.com ## Rules for agents writing integration code - Authenticate every request with the header `Authorization: Bearer ` (`X-API-Key: ` also works). Keep the key server-side: never put it in browser/mobile code, URLs, logs or commits. Read it from an env var. - Send and expect JSON (`Content-Type: application/json`), except raw media uploads. - Phone numbers: US/Canada only. Any common format is accepted in requests ("+17165550100", "7165550100", "(716) 555-0100"); responses always use E.164 ("+17165550100"). - Times are ISO 8601 UTC strings ("2026-11-09T15:00:00Z"). - IDs: messages are "msg_" + 16 hex chars, incoming messages "in_" + 16 hex chars, media "med_" + digits. Treat them as opaque strings. - Errors always look like {"error": {"code": "...", "message": "..."}} with a matching HTTP status. Branch on error.code, not on message text. - Do NOT automatically retry POST /messages on a timeout or 5xx: the text may already have gone out. Look it up first (GET /messages?referenceId=...) — so always send a unique referenceId per message. - Writes take up to ~15 seconds to appear in reads (opt-outs, media lists, cancellations; webhook settings are immediate). When verifying a change, poll for a few seconds instead of failing immediately. - Never call POST /messages/cancel-all unless the user explicitly wants to stop EVERY unsent message on the account (it also cancels just-sent messages still in the queue). Use DELETE /messages/{id} for one message. - Messaging must respect consent and opt-outs. A 422 recipient_opted_out is final; don't work around it. ## Send a message POST /messages { "to": "+17165559999", // string, or array of up to 100 numbers (required) "body": "Hello", // required unless media is given "from": "+17165550000", // optional: one of the account's numbers "media": ["med_123", "https://example.com/a.png"], // optional, makes it MMS (max 10, 1 MB total) "subject": "Receipt", // optional MMS subject "referenceId": "order-8812", // optional, your ID (max 100 chars) — strongly recommended "sendAt": "2026-11-10T15:00:00Z", // optional, schedule for later "callbackUrl": "https://crm.example.com/sms-events", // optional per-message webhook (https only; see Webhooks) "unicode": true, // optional, for emoji / non-Latin text "concatenate": true // optional, default true (long messages rejoined on the phone) } 201 Created: {"messages": [{"id": "msg_00000002b799f85f", "status": "queued", "to": "+17165559999", "from": "+17165550000", "referenceId": "order-8812", "scheduledAt": null, "error": null}]} - One entry per recipient. With several recipients some entries can have status "failed" while the request is 201. - If every recipient fails the response is 422 with error.code set (e.g. recipient_opted_out, invalid_from) and the per-recipient detail in error.messages. Example (curl): curl https://sms.zipcrunch.io/api/v1/messages -H "Authorization: Bearer $SMS_API_KEY" \ -H "Content-Type: application/json" -d '{"to":"+17165559999","body":"Hello","referenceId":"test-1"}' Example (JavaScript, Node 18+ / any fetch runtime): const res = await fetch("https://sms.zipcrunch.io/api/v1/messages", { method: "POST", headers: { Authorization: `Bearer ${process.env.SMS_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ to: "+17165559999", body: "Hello", referenceId: crypto.randomUUID() }), }); const data = await res.json(); if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message}`); Example (Python, requests): r = requests.post("https://sms.zipcrunch.io/api/v1/messages", headers={"Authorization": f"Bearer {os.environ['SMS_API_KEY']}"}, json={"to": "+17165559999", "body": "Hello", "referenceId": str(uuid.uuid4())}, timeout=30) data = r.json() if not r.ok: raise RuntimeError(f"{data['error']['code']}: {data['error']['message']}") ## Message status GET /messages/{id} → {"id", "status", "to", "from", "referenceId", "sentAt", "error", "replies": [Inbound...]} GET /messages?referenceId=order-8812 → {"messages": [...]} (referenceId is required here; there is no list-all) status values: - scheduled — accepted for a future sendAt (only on the send response; lookups show queued) - queued — accepted, waiting to send - processing — being sent - sent — handed to the carrier (use the delivery webhook for handset delivery) - held — held by the account; contact support - cancelled — cancelled before sending - failed — see error.code error.code values on failed messages: invalid_from (sending number invalid/unassigned/not provisioned; occasionally transient — retry once), no_sending_number, recipient_opted_out, invalid_to, empty_message, message_too_long, account_suspended, send_failed, carrier_failed, invalid_send_at. ## Cancel DELETE /messages/{id} → 200 with the message, status "cancelled". 409 not_cancellable if already sent. POST /messages/cancel-all with {"confirm": true} → {"cancelled": true|false}. Dangerous; see rules above. ## Replies (inbound) GET /inbound?unread=true&since=ISO&until=ISO&messageId=msg_...&referenceId=...&page=1&pageSize=50 → {"messages": [{"id": "in_...", "from", "to", "body", "receivedAt", "inReplyTo": "msg_...", "referenceId"}], "page", "pageSize"} pageSize is 1–100 (default 50). De-duplicate by id. Replies to a message also appear in GET /messages/{id} → replies. unread=true is a consume-once queue: a reply stops being "unread" as soon as any request returns it (including GET /messages/{id} for the message it answers). Poll it from ONE place only, and for reliable processing prefer GET /inbound?since= and remember the ids you've handled. ## Media (for MMS) POST /media — three ways: 1. Raw file: Content-Type: image/png (etc), body = file bytes, optional ?filename=logo.png&tag=x 2. JSON {"url": "https://..."} — the service downloads it (422 media_fetch_failed if it can't) 3. JSON {"content": "", "filename": "logo.png", "tags": ["x"]} → 201 {"id": "med_31386552", "filename", "size", "contentType", "tags", "createdAt"} GET /media?filename=*logo*&page=1&pageSize=50 → {"media": [...], "page", "pageSize"} (* is a wildcard) GET /media/{id}/content → the file bytes, with its Content-Type DELETE /media/{id} → 204 Attach with POST /messages {"media": ["med_31386552"]}. ## Opt-outs GET /opt-outs → {"optOuts": [{"number", "createdAt"}]} POST /opt-outs {"numbers": ["+17165559999"]} (or {"number": "..."}) → {"results": [{"number", "added", "error"}]} DELETE /opt-outs/{number} → 204 (only with a compliant basis to message the number again) ## Webhooks Events are POSTed to your https URL as JSON, signed. Three types; set each one you want: outbound → event "message.sent" (handed to the carrier, or failed) delivery → event "message.delivery" (handset delivery receipt) inbound → event "message.received" (a reply / incoming text, emoji preserved) GET /webhooks → {"delivery": {"url", "enabled"}, "inbound": {...}, "outbound": {...}, "signed": true, "signingSecret": "whsec_..."} PUT /webhooks/{type} {"url": "https://...", "enabled": true} → {"type", "url", "enabled", "signingSecret"} (setting url also enables unless "enabled": false) DELETE /webhooks/{type} → 204 (turns it off) POST /webhooks/{type}/test → sends a sample event (with "test": true) right now: {"delivered", "status", "durationMs", "error", "event"} POST /webhooks/rotate-secret → {"signingSecret"} (the old secret stops working immediately) GET /webhooks/deliveries?limit=50 → recent delivery attempts: [{"at", "eventId", "eventType", "attempt", "host", "status", "ok", "durationMs", "result"}] Per-message: POST /messages {"callbackUrl": "https://..."} sends ALL of that message's events (sent, delivery AND replies to it) to callbackUrl INSTEAD of the account's webhooks (same format, same signature). Replies to such a message do not reach the inbound webhook; they still appear in GET /inbound. Event body: {"id": "evt_…", "type": "message.received", "createdAt": "2026-11-10T02:14:54.000Z", "data": {…}} message.sent: {"messageId", "referenceId", "from", "to", "status": "sent"|"failed", "sentAt", "carrier", "segments"} message.delivery: {"messageId", "referenceId", "from", "to", "status", "delivered", "errorCode", "reportedAt"} status: delivered | undelivered | expired | rejected | deleted | accepted | unknown message.received: {"id": "in_…", "from", "to", "body", "receivedAt", "inReplyTo": "msg_…"|null, "referenceId"} Headers: ZipCrunch-Event-Id, ZipCrunch-Event-Type, ZipCrunch-Signature: t=,v1= Verify: v1 == hex(HMAC-SHA256(signingSecret, t + "." + rawBody)); compare in constant time; reject if |now - t| > 300 s. Use the raw request body bytes, not re-serialized JSON. Respond 2xx within 10 seconds. Anything else (or a timeout) is retried: 30s, 1m, 2m, 5m, 10m, 30m, 1h, 2h, 4h, 8h (11 attempts over ~16 hours), then dropped. Deliveries can repeat and arrive out of order: dedupe on the event id and order by the timestamps in data. Python verification: import hmac, hashlib, time def verify(raw: bytes, header: str, secret: str) -> bool: parts = dict(p.split("=", 1) for p in header.split(",")) if abs(time.time() - int(parts["t"])) > 300: return False mac = hmac.new(secret.encode(), parts["t"].encode() + b"." + raw, hashlib.sha256).hexdigest() return hmac.compare_digest(mac, parts["v1"]) Node verification: const crypto = require("node:crypto"); function verify(raw /* Buffer */, header, secret) { const p = Object.fromEntries(header.split(",").map((x) => x.split("="))); if (Math.abs(Date.now() / 1000 - Number(p.t)) > 300) return false; const mac = crypto.createHmac("sha256", secret).update(p.t + ".").update(raw).digest("hex"); return mac.length === p.v1.length && crypto.timingSafeEqual(Buffer.from(mac), Buffer.from(p.v1)); } ## Errors 400 invalid_request | invalid_json | invalid_phone_number | confirmation_required — fix the request (message says what) 401 missing_api_key | invalid_api_key 404 not_found — no such endpoint/message/media, or not owned by this key 405 method_not_allowed 409 not_cancellable 413 too_large · 415 unsupported_media_type 409 webhook_not_set (test before setting a url) 422 send failures (codes above) | media_fetch_failed | media_rejected | webhook_rejected | not_removed 429 rate_limited — honor Retry-After (seconds) 502 upstream_error / upstream_unavailable · 504 upstream_timeout — retry reads with backoff; for sends, look up by referenceId before retrying ## All endpoints POST /messages send an SMS or MMS GET /messages/{id} message status (and replies) GET /messages?referenceId=… messages by your reference DELETE /messages/{id} cancel a scheduled message POST /messages/cancel-all cancel every unsent message ({"confirm": true}) GET /inbound incoming messages POST /media upload media GET /media list media GET /media/{id}/content download media DELETE /media/{id} delete media GET /opt-outs list opted-out numbers POST /opt-outs add opted-out numbers DELETE /opt-outs/{number} remove an opted-out number GET /webhooks webhook settings and signing secret PUT /webhooks/{type} set a webhook (delivery | inbound | outbound) DELETE /webhooks/{type} turn a webhook off POST /webhooks/{type}/test send a sample event to your URL now POST /webhooks/rotate-secret new signing secret GET /webhooks/deliveries recent webhook delivery attempts Every response carries an X-Request-Id header; quote it to support@vaspian.com when asking about a request.