> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Mocean API reference

> API reference for the Mocean plugin in Corsair: every `mocean.api.*` operation with its input and output types, taken from the plugin's Zod schemas.

> [!NOTE]
>
> **New to Corsair?** See [API access](https://docs.corsair.dev/concepts/api.md), [authentication](https://docs.corsair.dev/concepts/auth.md), and [error handling](https://docs.corsair.dev/concepts/error-handling).

## Account

### balance

`account.balance`

Read the account credit balance

**Risk:** `read`

```ts theme={null}
await corsair.mocean.api.account.balance({});
```

**Input:** *empty object*

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `status` | `number \| string` | Yes | — |
| `value` | `number` | Yes | — |

***

### pricing

`account.pricing`

List per-destination prices for SMS, number lookup or verify, optionally for one MCC/MNC pair

**Risk:** `read`

```ts theme={null}
await corsair.mocean.api.account.pricing({ mocean_mcc: '502', mocean_mnc: '13', mocean_type: 'sms' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_mcc` | `string` | No | Only pricing for this Mobile Country Code; needs mocean\_mnc. |
| `mocean_mnc` | `string` | No | One Mobile Network Code; sent together with mocean\_mcc. |
| `mocean_type` | `sms \| number-lookup \| verify` | No | Defaults to 'sms'. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `status` | `number \| string \| null` | No | — |
| `destinations` | `object[]` | Yes | — |

> [accordion] destinations full type
>
> ```ts theme={null}
> {
>   country?: string | null,
>   operator?: string | null,
>   mcc?: string | null,
>   mnc?: string | null,
>   price?: number | string | null,
>   currency?: string | null
> }[]
> ```

***

## Lookup

### request

`lookup.request`

Look up a number's original and current carrier and porting status, paid from prepaid credit; synchronous without a callback URL

**Risk:** `read`

```ts theme={null}
await corsair.mocean.api.lookup.request({ mocean_to: '60123456789' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_to` | `string` | Yes | The phone number to look up, with country code. |
| `mocean_nl_url` | `string` | No | Callback URL for the async result. Omit it to get the full result synchronously. |

`POST /rest/2/nl`. Synchronous without `mocean_nl_url`; with it, Mocean
sends the result as a `PUT` to that URL, which the plugin does not receive.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `status` | `number \| string` | Yes | — |
| `msgid` | `string \| null` | No | — |
| `to` | `string \| null` | No | — |
| `current_carrier` | `object \| null` | No | — |
| `original_carrier` | `object \| null` | No | — |
| `ported` | `string \| null` | No | — |

> [accordion] current\_carrier full type
>
> ```ts theme={null}
> {
>   country?: string | null,
>   name?: string | null,
>   network_code?: string | number | null,
>   mcc?: string | null,
>   mnc?: string | null
> } | null
> ```

> [accordion] original\_carrier full type
>
> ```ts theme={null}
> {
>   country?: string | null,
>   name?: string | null,
>   network_code?: string | number | null,
>   mcc?: string | null,
>   mnc?: string | null
> } | null
> ```

***

## Sms

### reportConversion

`sms.reportConversion`

Tell Mocean whether a sent SMS reached the user (conversion tracking for OTP routes)

**Risk:** `write`

```ts theme={null}
await corsair.mocean.api.sms.reportConversion({ mocean_msgid: 'cust20013050311050614001', mocean_delivered: true });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_msgid` | `string` | Yes | The msgid from the send response. |
| `mocean_delivered` | `boolean` | Yes | true when the user received the message (for example, used the OTP). |
| `mocean_timestamp` | `string` | No | When it happened; defaults to the submission time. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `status` | `number \| string` | Yes | — |
| `err_msg` | `string \| null` | No | — |

***

### send

`sms.send`

Send an SMS to up to 500 receivers, charged per destination; the response has a status and msgid per receiver

**Risk:** `destructive`

```ts theme={null}
await corsair.mocean.api.sms.send({ mocean_from: 'Acme', mocean_to: '60123456789 60198765432', mocean_text: 'Your order has shipped.' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_from` | `string` | Yes | The Sender ID shown on the recipient handset. |
| `mocean_to` | `string` | Yes | Receiver phone numbers with country code, separated by commas or spaces, up to 500. |
| `mocean_text` | `string` | Yes | The message content; every receiver gets the same text. |
| `mocean_udh` | `string` | No | User Data Header, e.g. 0605040B8423F0. |
| `mocean_coding` | `number` | No | DCS coding scheme: 1 for 7-bit, 2 for 8-bit, 3 for UCS2. |
| `mocean_dlr_mask` | `number` | No | Set to 1 to request delivery reports. Defaults to 0. |
| `mocean_dlr_url` | `string` | No | Required when mocean\_dlr\_mask is 1: the delivery report callback URL. |
| `mocean_schedule` | `string` | No | Send later, in Malaysia time (GMT+8). A wrong format is rejected by the gateway. |
| `mocean_mclass` | `number` | No | Set to 1 with mocean\_alt\_dcs to send a Flash SMS. |
| `mocean_alt_dcs` | `number` | No | Set to 1 with mocean\_mclass to send a Flash SMS. |
| `mocean_charset` | `ISO-8859-1 \| ISO-8859-7 \| UTF-8 \| Windows-1252` | No | The character set used in mocean\_text. |
| `mocean_validity` | `number` | No | How long the message stays deliverable, in seconds. |

`POST /rest/2/sms` with a form-encoded body. Mocean answers HTTP 202 with
`{ messages: [{ status, receiver, msgid }] }`; each row can fail on its own.
A request with no receiver answers HTTP 400 with the same shape.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `messages` | `object[]` | Yes | — |

> [accordion] messages full type
>
> ```ts theme={null}
> {
>   status: number | string,
>   receiver?: string | null,
>   msgid?: string | null,
>   err_msg?: string | null
> }[]
> ```

***

### status

`sms.status`

Read a sent message's final status (success, failed, expired, pending or not found) and the credit it took

**Risk:** `read`

```ts theme={null}
await corsair.mocean.api.sms.status({ mocean_msgid: 'cust20013050311050614001' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_msgid` | `string` | Yes | The msgid from the send response. |

`GET /rest/2/report/message`. `message_status` is 1 success, 2 failed,
3 expired, 4 pending, 5 not found (an unknown msgid answers 5, not an
error).

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `status` | `number \| string` | Yes | — |
| `message_status` | `number \| null` | No | — |
| `msgid` | `string \| null` | No | — |
| `credit_deducted` | `number \| string \| null` | No | — |

***

## Templates

### create

`templates.create`

Create a WhatsApp message template and submit it to Meta for review

**Risk:** `write`

```ts theme={null}
await corsair.mocean.api.templates.create({ name: 'order_ready', language: 'en_US', category: 'UTILITY', components: [{ type: 'BODY', text: 'Your order {{1}} is ready', example: { body_text: [['1042']] } }] });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | Template name. |
| `language` | `string` | Yes | Language code, e.g. en\_US. |
| `category` | `AUTHENTICATION \| MARKETING \| UTILITY` | Yes | — |
| `allowCategoryChange` | `boolean` | No | Let Meta pick the category under its guidelines. |
| `message_send_ttl_seconds` | `number` | No | Time to live of an authentication message, in seconds. |
| `parameter_format` | `POSITIONAL \| NAMED` | No | — |
| `components` | `object[]` | Yes | Header, body, footer and buttons, as in the Meta template API. |

> [accordion] components full type
>
> ```ts theme={null}
> {
>   type: string
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| number \| null` | No | — |
| `name` | `string \| null` | No | — |
| `language` | `string \| null` | No | — |
| `category` | `string \| null` | No | — |
| `status` | `string \| null` | No | — |
| `components` | `any[] \| null` | No | — |

***

### delete

`templates.delete`

Delete a WhatsApp message template, every language of it or one by ID; cannot be undone

**Risk:** `destructive`

```ts theme={null}
await corsair.mocean.api.templates.delete({ name: 'order_ready', hsm_id: '5653923468721315' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | Template name; deletes every language of it. |
| `hsm_id` | `string` | No | Template ID, to delete only that one language. |

`DELETE /template/whatsapp/message_templates?name=...&hsm_id=...`. Without
`hsm_id` every language of the template is deleted.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `success` | `string \| boolean \| null` | No | — |

***

### edit

`templates.edit`

Edit a WhatsApp message template; Meta reviews it again

**Risk:** `write`

```ts theme={null}
await corsair.mocean.api.templates.edit({ templateId: '5653923468721315', name: 'order_ready', language: 'en_US', category: 'UTILITY', components: [{ type: 'BODY', text: 'Order {{1}} is ready for pickup' }] });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `templateId` | `string` | Yes | The WhatsApp template ID. |
| `name` | `string` | Yes | Template name. |
| `language` | `string` | Yes | Language code, e.g. en\_US. |
| `category` | `AUTHENTICATION \| MARKETING \| UTILITY` | Yes | — |
| `allowCategoryChange` | `boolean` | No | Let Meta pick the category under its guidelines. |
| `message_send_ttl_seconds` | `number` | No | Time to live of an authentication message, in seconds. |
| `parameter_format` | `POSITIONAL \| NAMED` | No | — |
| `components` | `object[]` | Yes | Header, body, footer and buttons, as in the Meta template API. |

> [accordion] components full type
>
> ```ts theme={null}
> {
>   type: string
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| number \| null` | No | — |
| `name` | `string \| null` | No | — |
| `language` | `string \| null` | No | — |
| `category` | `string \| null` | No | — |
| `status` | `string \| null` | No | — |
| `components` | `any[] \| null` | No | — |

***

### get

`templates.get`

Read one WhatsApp message template

**Risk:** `read`

```ts theme={null}
await corsair.mocean.api.templates.get({ templateId: '5653923468721315' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `templateId` | `string` | Yes | The WhatsApp template ID. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| number \| null` | No | — |
| `name` | `string \| null` | No | — |
| `language` | `string \| null` | No | — |
| `category` | `string \| null` | No | — |
| `status` | `string \| null` | No | — |
| `components` | `any[] \| null` | No | — |

***

### list

`templates.list`

List WhatsApp message templates, filtered by name, status, category or language

**Risk:** `read`

```ts theme={null}
await corsair.mocean.api.templates.list({ limit: 20, status: 'APPROVED' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `limit` | `number` | No | — |
| `after` | `string` | No | paging.cursors.after from the previous page, for the next page. |
| `before` | `string` | No | paging.cursors.before from a page, for the page before it. |
| `category` | `AUTHENTICATION \| MARKETING \| UTILITY` | No | — |
| `content` | `string` | No | Search the template text. |
| `language` | `string` | No | — |
| `name` | `string` | No | — |
| `name_or_content` | `string` | No | — |
| `quality_score` | `string` | No | GREEN, YELLOW, RED or UNKNOWN |
| `status` | `string` | No | Review status: APPROVED, PENDING, REJECTED, ... |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object[] \| null` | No | — |
| `paging` | `object \| null` | No | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   name?: string | null,
>   language?: string | null,
>   category?: string | null,
>   status?: string | null,
>   components?: any[] | null
> }[] | null
> ```

> [accordion] paging full type
>
> ```ts theme={null}
> {
>   cursors?: {
>     before?: string | null,
>     after?: string | null
>   } | null,
>   next?: string | null
> } | null
> ```

***

## Verify

### check

`verify.check`

Check the code a user gave you against a verify request; Mocean allows three wrong attempts

**Risk:** `write`

```ts theme={null}
await corsair.mocean.api.verify.check({ mocean_reqid: 'moceanq5672285037', mocean_code: '123456' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_reqid` | `string` | Yes | The reqid of the verify request. |
| `mocean_code` | `string` | Yes | The PIN the user gave you. |

`POST /rest/2/verify/check`. An expired or unknown reqid answers HTTP 404
with body status 17; a wrong code is status 16.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `reqid` | `string \| null` | No | — |
| `status` | `number \| string` | Yes | — |

***

### request

`verify.request`

Send a verification code by SMS, charged per attempt; keep the reqid for check and resend

**Risk:** `destructive`

```ts theme={null}
await corsair.mocean.api.verify.request({ mocean_to: '60123456789', mocean_brand: 'Acme', mocean_code_length: 6, mocean_pin_validity: 300 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_to` | `string` | Yes | Receiver phone number with country code, e.g. 60123456789. |
| `mocean_brand` | `string` | Yes | The company or application name shown to the user; the gateway rejects a brand it considers too long (body status 9). |
| `mocean_from` | `string` | No | The SMS Sender ID. |
| `mocean_code_length` | `4 \| 6` | No | The verification code length. Defaults to 4 or the account setting. |
| `mocean_pin_validity` | `number` | No | Seconds the code stays valid, 60-3600. Defaults to 300 or the account setting. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `reqid` | `string \| null` | No | — |
| `status` | `number \| string` | Yes | — |
| `to` | `string \| null` | No | — |
| `is_number_reachable` | `string \| null` | No | — |
| `resend_number` | `string \| null` | No | — |

***

### requestTelegram

`verify.requestTelegram`

Send a verification code to a Telegram chat through your bot; keep the reqid for check

**Risk:** `destructive`

```ts theme={null}
await corsair.mocean.api.verify.requestTelegram({ mocean_to: '123456789', mocean_from: 'acme_bot', mocean_brand: 'Acme' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_to` | `string` | Yes | The Telegram chat ID that gets the code. |
| `mocean_from` | `string` | Yes | Your Telegram bot username that sends the code. |
| `mocean_brand` | `string` | Yes | The company or application name shown to the user. |
| `mocean_code_length` | `4 \| 6` | No | — |
| `mocean_pin_validity` | `number` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `reqid` | `string \| null` | No | — |
| `status` | `number \| string` | Yes | — |
| `to` | `string \| null` | No | — |
| `is_number_reachable` | `string \| null` | No | — |
| `resend_number` | `string \| null` | No | — |

***

### resend

`verify.resend`

Resend the code of a verify request by SMS, charged per attempt

**Risk:** `destructive`

```ts theme={null}
await corsair.mocean.api.verify.resend({ mocean_reqid: 'moceanq5672285037' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_reqid` | `string` | Yes | The reqid of the verify request to resend. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `reqid` | `string \| null` | No | — |
| `status` | `number \| string` | Yes | — |
| `to` | `string \| null` | No | — |
| `is_number_reachable` | `string \| null` | No | — |
| `resend_number` | `string \| null` | No | — |

***

## Voice

### dial

`voice.dial`

Call one or more numbers and run a Mocean Command flow (say, play, collect, record, dial), charged per call

**Risk:** `destructive`

```ts theme={null}
await corsair.mocean.api.voice.dial({ mocean_to: '60123456789', mocean_command: [{ action: 'say', language: 'en-US', text: 'Your code is 1 2 3 4' }] });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_to` | `string` | Yes | Number(s) to call with country code, separated by commas or spaces. |
| `mocean_command` | `object[]` | Yes | Mocean Command (MC) objects run in order, e.g. \[\{ action: "say", language: "en-US", text: "Hello" }]. |
| `mocean_from` | `string` | No | Caller ID (number of origin). |
| `mocean_event_url` | `string` | No | Webhook that receives call status events. |

`POST /rest/2/voice/dial`. `mocean_command` is sent as one JSON string
field, as Mocean expects.

> [accordion] mocean\_command full type
>
> ```ts theme={null}
> {
>   action: string
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `status` | `number \| string \| null` | No | — |
| `calls` | `object[] \| null` | No | — |

> [accordion] calls full type
>
> ```ts theme={null}
> {
>   status: number | string,
>   receiver?: string | number | null,
>   session_uuid?: string | null,
>   call_uuid?: string | null,
>   err_msg?: string | null
> }[] | null
> ```

***

### hangup

`voice.hangup`

Hang up a call in progress

**Risk:** `destructive`

```ts theme={null}
await corsair.mocean.api.voice.hangup({ mocean_call_uuid: 'xxx-xxx-xxx-xxx' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_call_uuid` | `string` | Yes | The call\_uuid from voice.dial. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `status` | `number \| string` | Yes | — |
| `session_uuid` | `string \| null` | No | — |
| `call_uuid` | `string \| null` | No | — |

***

### recording

`voice.recording`

Download the audio recording of a call

**Risk:** `read`

```ts theme={null}
await corsair.mocean.api.voice.recording({ mocean_call_uuid: 'xxx-xxx-xxx-xxx' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_call_uuid` | `string` | Yes | The call\_uuid from voice.dial. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `contentBase64` | `string` | No | The file, base64-encoded. Missing when the file came back as text or contentOmitted is set. |
| `text` | `string` | No | The file as text, in place of contentBase64, when it is a text file (CSV, JSON, Markdown, XML and the like) in UTF-8. |
| `contentType` | `string` | Yes | Media type of the file, for example application/pdf. |
| `byteLength` | `number` | Yes | Size of the file in bytes. |
| `filename` | `string` | No | The file name, when known. |
| `contentOmitted` | `not_requested \| over_limit` | No | Set when the content was left out: the caller did not ask for it, or the file was over the limit. |
| `fileId` | `string` | No | Where the host saved the file. Over the limit it comes in place of the content; a host that keeps every file sets it beside the content too. On Corsair it is a Files id (fil\_…): pass it to another app wherever that app takes a file URL, or read a text file or PDF with files.read\_text. |

***

## Whatsapp

### downloadMedia

`whatsapp.downloadMedia`

Download media a WhatsApp user sent to your business number

**Risk:** `read`

```ts theme={null}
await corsair.mocean.api.whatsapp.downloadMedia({ mocean_from: '60111111111', mocean_media_id: '1234567890' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_from` | `string` | Yes | Your WhatsApp Business sender number that received the media. |
| `mocean_media_id` | `string` | Yes | The media ID from the inbound message. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `contentBase64` | `string` | No | The file, base64-encoded. Missing when the file came back as text or contentOmitted is set. |
| `text` | `string` | No | The file as text, in place of contentBase64, when it is a text file (CSV, JSON, Markdown, XML and the like) in UTF-8. |
| `contentType` | `string` | Yes | Media type of the file, for example application/pdf. |
| `byteLength` | `number` | Yes | Size of the file in bytes. |
| `filename` | `string` | No | The file name, when known. |
| `contentOmitted` | `not_requested \| over_limit` | No | Set when the content was left out: the caller did not ask for it, or the file was over the limit. |
| `fileId` | `string` | No | Where the host saved the file. Over the limit it comes in place of the content; a host that keeps every file sets it beside the content too. On Corsair it is a Files id (fil\_…): pass it to another app wherever that app takes a file URL, or read a text file or PDF with files.read\_text. |

***

### send

`whatsapp.send`

Send a WhatsApp message (text, media, template, interactive, location or contacts) from your business number

**Risk:** `destructive`

```ts theme={null}
await corsair.mocean.api.whatsapp.send({ mocean_from: '60111111111', mocean_to: '60123456789', mocean_content: { type: 'text', text: 'Your order has shipped.' } });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `mocean_from` | `string` | Yes | Your registered WhatsApp Business sender number. |
| `mocean_to` | `string` | Yes | Receiver number with country code, or a Business Scoped User ID. |
| `mocean_event_url` | `string` | No | Webhook that receives delivery events. |
| `mocean_content` | `object` | Yes | The message, e.g. \{ type: "text", text: "Hello" }. |

> [accordion] mocean\_content full type
>
> ```ts theme={null}
> {
>   type: string
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `status` | `number \| string` | Yes | — |
| `message_id` | `string \| null` | No | — |
| `err_msg` | `string \| null` | No | — |

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.