Authorization: Bearer, and
every /rest/2 call asks Mocean for JSON, since the default is XML.
- Errors. Mocean answers many failures with HTTP 202 and a body
status, and the same number means different things per API: 1 is a bad token for SMS but throttling for Verify. The plugin throws core’sApiErrorwith the HTTP status the body status means: 429 throttled (retried with backoff), 401 bad token, 402 out of credit, 503 system down, 500 system error, 400 for a bad request. Some failures come as real HTTP 400/404 with the same{ status, err_msg }body; those keep their HTTP status. The original code is onerror.body.status. Error messages are URL-decoded and have phone numbers masked; request bodies are never kept. - Sends report per receiver.
sms.sendreturns one row per receiver with its ownstatusandmsgid; a failed row (28 invalid number) does not fail the others.voice.dialdoes the same incalls[]. - Costs. Sends, verify requests and resends, calls and WhatsApp messages
spend credit and are
destructive.lookup.requestalso spends prepaid credit but only returns data, so it staysreadlike other metered reads. - Numbers and prices.
priceandcredit_deductedcome back as numbers although the reference says strings; status codes on voice routes can come back as strings.mocean_mccandmocean_mncgo together (either one alone answers status 46). - Scheduling is Malaysia time.
mocean_scheduleisYYYY-MM-DD hh:mm:ssin GMT+8. - Downloads.
voice.recordingandwhatsapp.downloadMediareturn the file (base64 with its type and size). A status answer instead of a file becomes an error. - Callbacks are not received. Delivery reports, inbound SMS, call events,
WhatsApp events and asynchronous number lookups go to URLs you host; Mocean
does not sign them, and this plugin has no webhooks. The number lookup
result arrives as a
PUTtomocean_nl_url; delivery reports arrive as aPUTtomocean_dlr_url. - WhatsApp and voice need a WhatsApp Business sender or voice enabled on the Mocean account; without it those routes answer 401 or 403.
- 20 typed API operations
Setup
1
Install
2
Add the plugin
corsair.ts
multiTenancy: true, scope calls with corsair.withTenant(id). See Quick start for KEK + Hub keys, and Multi-tenancy for account isolation.3
Choose authentication
- API Key (Recommended)
Store the Mocean API key before the first call: More: API Key
pnpm corsair setup --plugin=mocean --tenant=acme api_key=<your-key> (leave out --tenant without multiTenancy), or pass it as key in the plugin options. With Hub, each tenant enters their own key on the connect page. See API key auth.4
Connect a tenant
Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see Connect / OAuth.
Example API calls
Read the account balanceWhat’s next
API reference
Every
mocean.api.* operation with input and output types.Connect / OAuth
createLink, Hub delivery, and tenant connect flows.
Use with agents
Expose this plugin’s operations as MCP tools.