> For the complete documentation index, see [llms.txt](https://mava.gitbook.io/mava-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mava.gitbook.io/mava-docs/webhooks-and-api/api/send-message-or-private-note.md).

# Send Message or Private Note

### Endpoint

```
PUT /api/message
```

### Authentication

* Requires API token authentication
* Subject to rate limiting

### Behavior

You can send two types of messages:

* **External** **messages:** visible to the customer and delivered through the ticket's integration channel (e.g. email, Discord, Telegram).
* **Internal** **notes:** private messages only visible to your support team inside the Mava dashboard.

&#x20; If no messageType is specified, the message defaults to an **External** **Message**.

### Request Body

| Field                    | Type   | Required             | Description                                                                                              |
| ------------------------ | ------ | -------------------- | -------------------------------------------------------------------------------------------------------- |
| `ticketId`               | string | Yes                  | The ID of the ticket to send the message to                                                              |
| `content`                | string | No\*                 | The text content of the message                                                                          |
| `messageType`            | string | No                   | The type of message to send. Accepted values: ExternalMessage, InternalNote. Defaults to ExternalMessage |
| `attachments`            | array  | No\*                 | A list of file attachments to include with the message                                                   |
| `attachments[].fileName` | string | Yes (if attachments) | The display name of the file                                                                             |
| `attachments[].url`      | string | Yes (if attachments) | The publicly accessible URL of the file                                                                  |
| `attachments[].fileType` | string | Yes (if attachments) | The MIME type of the file (e.g. image/png, application/pdf)                                              |

\*Either content or attachments must be provided.

#### Valid Values

* **`messageType`**: `"ExternalMessage"`, `"InternalNote"` — Defaults to "`ExternalMessage"`

### Response

**Success (200)**

```json
{
"message": { ... },
"ticket": { ... },
"sender": { ... }
}
```

**Bad Request (400)**

Returned when required fields are missing or the ticket is not found.

```json
{
"error": "Content or attachments are required"
}
{
"error": "Ticket not found"
}
```

**Unauthorized (401)**

Returned when the API key is missing or invalid.

**Too Many Requests (429)**

Returned when the rate limit is exceeded. The API allows up to 90 requests per 30 seconds per API key.

**Internal Server Error (500)**

### Code Examples

**Curl**

```bash
curl -X POST https://app.mava.app/api/message \
    -H "x-auth-token: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "ticketId": "TICKET_ID",
      "content": "Thanks for reaching out! We will look into this right away.",
      "messageType": "ExternalMessage"
    }'
```

**NodeJS**

```javascript
const response = await fetch("https://app.mava.app/api/message", {
    method: "POST",
    headers: {
      "x-auth-token": "YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      ticketId: "TICKET_ID",
      content: "Thanks for reaching out! We will look into this right away.",
      messageType: "ExternalMessage",
    }),
  });
 const data = await response.json();
```

**Schema**

```json
{
    "ticketId": "string",
    "content": "string",
    "messageType": "ExternalMessage | InternalNote",
    "attachments": [
      {
        "fileName": "string",
        "url": "string",
        "fileType": "string"
      }
    ]
  }
```

**Sending an Internal Note**

To send a message that is only visible internally to your team, set messageType to InternalNote:

<pre class="language-json"><code class="lang-json"><strong>{
</strong>"ticketId": "TICKET_ID",
"content": "Customer has been flagged as a premium user, prioritise this ticket.",
"messageType": "InternalNote"
}
</code></pre>
