# Write to the support team

`POST /api/v1/support-requests/{supportRequest}/messages`

Add a message to a request you opened. Whatever its status, including solved, the request goes back to to_handle.

Files are sent as multipart form data, in a field called files that is repeated once per file. At most 5 files, each at most 10 MB, of the types jpg, jpeg, png, gif, webp, heic, pdf, txt and log. A file that breaks any of these answers 422 on files or on files.0, files.1 and so on, and nothing is kept.

## Parameters

- `supportRequest` (uuid, required): The id of the request. One belonging to another account answers 404.
- `body` (string, required): What you want to say, up to 20,000 characters. A body left empty answers 422.
- `files` (file, optional): Files to send with the message. Repeat the field once per file, up to 5.

## Returns

The message object that was written. A request of another account answers 404.

- `data` (object): The message.
- `data.type` (string): Always support_message.
- `data.id` (string): The id of the message.
- `data.attributes` (object): Everything the message holds.
- `data.attributes.kind` (string): message when the person who asked wrote it, reply when the support team did. An internal note is never shown here.
- `data.attributes.author_name` (string): The name of the person who wrote it.
- `data.attributes.is_support_team` (boolean): Whether the support team wrote it.
- `data.attributes.body` (string): What was written, as plain text.
- `data.attributes.attachments` (array): The files sent with it. An empty list when there are none.
- `data.attributes.attachments[]` (object): One file.
- `data.attributes.attachments[].id` (uuid): The id of the file, which the download address takes.
- `data.attributes.attachments[].name` (string): The name the file had when it was sent.
- `data.attributes.attachments[].mime_type` (string): The type of the file, such as image/png.
- `data.attributes.attachments[].size_in_bytes` (integer): How large the file is, in bytes.
- `data.attributes.created_at` (timestamp): When it was written, as a count of seconds since 1970.

## Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in `X-RateLimit-Remaining`.

## Request

```sh
curl https://my.monicahq.com/api/v1/support-requests/7c1e4a92-5b3d-4f08-a6e1-93d2c8b05f17/messages \
  -X POST \
  -H "Authorization: Bearer $MONICA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
      "body": "Thank you, Jim. Could you also move the one for the Scranton Business Park meeting?"
  }'
```

```javascript
const response = await fetch('https://my.monicahq.com/api/v1/support-requests/7c1e4a92-5b3d-4f08-a6e1-93d2c8b05f17/messages', {
  method: 'POST',
  headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    body: 'Thank you, Jim. Could you also move the one for the Scranton Business Park meeting?',
  }),
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->post('https://my.monicahq.com/api/v1/support-requests/7c1e4a92-5b3d-4f08-a6e1-93d2c8b05f17/messages', [
    'body' => 'Thank you, Jim. Could you also move the one for the Scranton Business Park meeting?',
]);
```

## Response

`201`

```json
{
    "data": {
        "type": "support_message",
        "id": "e5a90b36-1c7d-4284-b9f3-0d6a82c471e9",
        "attributes": {
            "kind": "message",
            "author_name": "Michael Scott",
            "is_support_team": false,
            "body": "Thank you, Jim. Could you also move the one for the Scranton Business Park meeting?",
            "attachments": [
                {
                    "id": "b36f0d8e-47a1-4c92-95e8-1a2d7c63f0b4",
                    "name": "conference-room-booking.png",
                    "mime_type": "image/png",
                    "size_in_bytes": 245760
                }
            ],
            "created_at": 1791554400
        }
    }
}
```
