> For the complete documentation index, see [llms.txt](https://inverselattice.gitbook.io/saurabhsugandh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://inverselattice.gitbook.io/saurabhsugandh/sample-api-reference/rocket-chat.md).

# Rocket Chat

This section describes the endpoint for a live chat file upload.

## /api/v1/livechat/upload/:rid

&#x20;Uploads a file to a live chat with a valid room ID.

<mark style="color:green;">`POST`</mark> `https://<BASE URL>/api/v1/livechat/upload/:rid`

Requires a path parameter and an authorised access token.

#### Path Parameters

| Name                                  | Type   | Description                    |
| ------------------------------------- | ------ | ------------------------------ |
| rid<mark style="color:red;">\*</mark> | String | Defines the live chat room ID. |

#### Headers

| Name                                           | Type   | Description                                  |
| ---------------------------------------------- | ------ | -------------------------------------------- |
| X-Auth-Token<mark style="color:red;">\*</mark> | String | Defines the access token for authentication. |

{% tabs %}
{% tab title="200: OK Successful operation" %}

```javascript
{
    "success": true
}
```

{% endtab %}
{% endtabs %}

### cURL Request

Refer to the following example cURL command that uploads a file from a system to a chat room:

```
curl 'https://<Base_URL>/api/v1/livechat/upload/general' \
  -X POST \
  -H Authorization: Bearer '8nAQfgDpOR5I60CiyGu9L-3SXMsK6HB9CS7_1Y1Tv_X' \
  -F 'file=@/home/sugandhs/pictures/rc/path.png' \

```

### cURL Response

Refer to the following example cURL response for the above request:

```
{
  "message": {
    "rid": "GENERAL",
    "visitorToken": "8nAQfgDpOR5I60CiyGu9L-3SXMsK6HB9CS7_1Y1Tv_X",
    "file": {
      "name": "Path",
      "size": 24,
      "type": "image/png"
      }
    }, 
  "success": true 
}
```

### Error Codes

Refer to the following error codes that you may encounter while using the cURL request:

{% tabs %}
{% tab title="400" %}
Bad request: Invalid syntax. Modify your syntax and try again.
{% endtab %}

{% tab title="401" %}
Unauthorised access: Invalid authorisation credentials. Verify your authorisation key, update, and try again with correct credentials.
{% endtab %}

{% tab title="415" %}
File type is not supported: Invalid media type. Use only the supported media types such as TXT, PNG, and JPEG.
{% endtab %}

{% tab title="413" %}
File size is too large: Invalid file size. Use the maximum allowable limit of 5 MB for a file size.
{% endtab %}
{% endtabs %}
