Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@
"fundamentals/webhooks-legacy"
]
},
{
"group": "Media",
"pages": [
"fundamentals/presigned-urls"
]
},
{
"group": "User-Roles",
"pages": [
Expand Down
56 changes: 56 additions & 0 deletions fundamentals/presigned-urls.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: "Pre-Signed URLs"
sidebarTitle: "Pre-Signed URLs"
description: "Secure, time-limited access to media files with configurable expiry."
---

CometChat generates **pre-signed URLs** for all media files, including images, audio, video, and documents shared in chat. A pre-signed URL embeds a cryptographic signature and an expiry timestamp directly in the URL, so files are accessible only within a defined time window without requiring API credentials on the client side.

This feature is enabled by default for all newly created apps. Existing apps can opt in from the CometChat dashboard.

---

## How It Works

When a media file is sent or retrieved, CometChat returns a pre-signed URL in the following format:

```
https://media-<REGION>.cometchat.io/<APP_ID>/media/<filename>?Expires=<unix_timestamp>&Signature=<signature>&Key-Pair-Id=<key_pair_id>
```

| Parameter | Description |
| -------------- | -------------------------------------------------------- |
| `Expires` | Unix timestamp after which the URL is no longer valid |
| `Signature` | Cryptographic signature that validates the URL integrity |
| `Key-Pair-Id` | Identifier for the signing key pair used by CometChat |

Pre-signed URLs are returned across all surfaces - SDK responses, REST API, and webhook payloads.

---

## Configuring the TTL

The TTL (Time-to-Live) controls how long a generated pre-signed URL remains valid.

| Setting | Value |
| ------- | ----------- |
| Minimum | 15 minutes |
| Maximum | 1 month |
| Default | 1 day |

To configure the TTL:

1. Go to the [CometChat Dashboard](https://app.cometchat.com/apps).
2. Select your app and navigate to **Chat & Messaging** → **Settings**.
3. Under **Pre-Signed URLs**, set your desired TTL value.
4. Save your changes.

<Frame>
<img src="/images/presigned-url-ttl-settings.png" alt="Pre-Signed URL TTL configuration in CometChat Dashboard" />
</Frame>

<Note>
TTL configuration is available on all plans. Changes take effect for all new pre-signed URLs generated after saving; existing URLs retain their original expiry.
</Note>

---
30 changes: 0 additions & 30 deletions fundamentals/webhooks-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,6 @@ Authorization: Basic <Base64-encoded-credentials>

You can configure this with a username and password known only to your system.

### Token-based files access

Token-based file access provides improved control over media files through pre-signed URLs. When this feature is enabled, media URLs in webhook payloads may return a 401 Unauthorized response.

You can enable this feature in the **Settings** section under **Chats** in the CometChat dashboard. Once enabled, it cannot be disabled.

<Frame>
<img src="/images/7e05ae85-cometchat-token-based-files-access-faf7351fc08b8bd2be2e48bede117eb3.png" />
</Frame>

To access media files, use the media URL from the webhook payload to obtain a URL secured with a file access token (FAT). This URL redirects to a pre-signed URL that remains valid for 5 minutes.

**Sample request:**

```html
curl --location 'https://files-<REGION>.cometchat.io/<APP_ID>/media/audio3.mp3' \
--header 'appId: <APP_ID>' \
--header 'apiKey: <API_KEY>'
```

**Sample response:**

```json
{
"data": {
"url": "https://files-<REGION>.cometchat.io/<APP_ID>/media/audio3.mp3?fat=<FILE_ACCESS_TOKEN>"
}
}
```

***

## Webhook Best Practices
Expand Down
Binary file added images/presigned-url-ttl-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.