# Folders API

The Folders API: create, edit and delete folders, previews and ZIP downloads, with every endpoint's fields, who may call it, its rate limit and a curl example.

## Create a new folder

`POST /folders`

Needs a session token. Rate limit: 120 a minute, per address. An app's token or an API key needs the `folders:write` scope.

### Body

| Field | Type | Required | Notes |
|---|---|---|---|
| `name` | `string` | required | 1 to 64 characters. |
| `contentType` | `"Image"` | required |  |

### Response

Returns a [Folder](https://hematite.gg/docs/developers/models/folder).

Error `402`: Folder limit reached.

```bash
curl -X POST 'https://api.hematite.gg/v1/folders' \
  -H "Authorization: $HEMATITE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Ranked","contentType":"Image"}'
```

Example `data`:

```json
{
  "id": 1,
  "userId": 1,
  "createdAt": "2026-11-10T18:24:00.000Z",
  "updatedAt": "2026-11-10T18:24:00.000Z",
  "contentType": "Image",
  "name": "Ranked",
  "description": "1v4 on the last round",
  "visibility": "Unlisted",
  "color": "#c4d4e0",
  "previewId": 1,
  "downloads": 0,
  "privateLockedAt": "2026-11-10T18:24:00.000Z",
  "offlineAt": "2026-11-10T18:24:00.000Z",
  "preview": {
    "key": "images/a1b2c3d4e5f6.png"
  },
  "shareId": 1,
  "shareCode": "x7Kp2QmA",
  "contentCount": 1,
  "size": 2457600,
  "contentCountForOthers": 0,
  "sizeForOthers": 0,
  "viewCount": 0,
  "likeCount": 0,
  "commentCount": 0
}
```

## Get a single folder by ID

`GET /folders/:folderId`

Needs a session token. Rate limit: 120 a minute, per address. An app's token or an API key needs the `folders:read` scope.

### Path parameters

| Field | Type | Required | Notes |
|---|---|---|---|
| `folderId` | `any` | required | The folder's id. |

### Response

Returns a [Folder](https://hematite.gg/docs/developers/models/folder).

```bash
curl 'https://api.hematite.gg/v1/folders/1' \
  -H "Authorization: $HEMATITE_TOKEN"
```

Example `data`:

```json
{
  "id": 1,
  "userId": 1,
  "createdAt": "2026-11-10T18:24:00.000Z",
  "updatedAt": "2026-11-10T18:24:00.000Z",
  "contentType": "Image",
  "name": "Ranked",
  "description": "1v4 on the last round",
  "visibility": "Unlisted",
  "color": "#c4d4e0",
  "previewId": 1,
  "downloads": 0,
  "privateLockedAt": "2026-11-10T18:24:00.000Z",
  "offlineAt": "2026-11-10T18:24:00.000Z",
  "preview": {
    "key": "images/a1b2c3d4e5f6.png"
  },
  "shareId": 1,
  "shareCode": "x7Kp2QmA",
  "contentCount": 1,
  "size": 2457600,
  "contentCountForOthers": 0,
  "sizeForOthers": 0,
  "viewCount": 0,
  "likeCount": 0,
  "commentCount": 0
}
```

## Edit a folder. One a moderation decision made private stays private (`403 FOLDER_PRIVATE_LOCKED`).

`PATCH /folders/:folderId`

Needs a session token. Rate limit: 120 a minute, per address. An app's token or an API key needs the `folders:write` scope.

### Path parameters

| Field | Type | Required | Notes |
|---|---|---|---|
| `folderId` | `any` | required | The folder's id. |

### Body

Send at least one field.

| Field | Type | Required | Notes |
|---|---|---|---|
| `name` | `string` |  | 1 to 64 characters. |
| `description` | `string` |  | At most 1000 characters. |
| `visibility` | `enum` |  | One of `Public`, `Unlisted`, `Private`. |
| `color` | `string` |  | A colour: `#` and six hex digits, as in `#c4d4e0`. Send it so; it's stored and sent back in lowercase. Six digits without the `#` are still taken for now. Matches ^#?[0-9a-fA-F]{6}$. |

### Response

Returns a [Folder](https://hematite.gg/docs/developers/models/folder).

```bash
curl -X PATCH 'https://api.hematite.gg/v1/folders/1' \
  -H "Authorization: $HEMATITE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Ranked"}'
```

Example `data`:

```json
{
  "id": 1,
  "userId": 1,
  "createdAt": "2026-11-10T18:24:00.000Z",
  "updatedAt": "2026-11-10T18:24:00.000Z",
  "contentType": "Image",
  "name": "Ranked",
  "description": "1v4 on the last round",
  "visibility": "Unlisted",
  "color": "#c4d4e0",
  "previewId": 1,
  "downloads": 0,
  "privateLockedAt": "2026-11-10T18:24:00.000Z",
  "offlineAt": "2026-11-10T18:24:00.000Z",
  "preview": {
    "key": "images/a1b2c3d4e5f6.png"
  },
  "shareId": 1,
  "shareCode": "x7Kp2QmA",
  "contentCount": 1,
  "size": 2457600,
  "contentCountForOthers": 0,
  "sizeForOthers": 0,
  "viewCount": 0,
  "likeCount": 0,
  "commentCount": 0
}
```

## Delete a folder and its link. Its images stay in your gallery, out of any folder, unless `withContent` is true: then they're deleted with it, for good.

`DELETE /folders/:folderId`

Needs a session token. Rate limit: 120 a minute, per address. An app's token or an API key needs the `folders:write` scope.

### Path parameters

| Field | Type | Required | Notes |
|---|---|---|---|
| `folderId` | `any` | required | The folder's id. |

### Body

| Field | Type | Required | Notes |
|---|---|---|---|
| `withContent` | `boolean` |  | Whether the folder's images are deleted with it, for good (true), or stay in the gallery, out of any folder (false). Default `false`. |

### Response

`data` is empty.

```bash
curl -X DELETE 'https://api.hematite.gg/v1/folders/1' \
  -H "Authorization: $HEMATITE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"withContent":false}'
```

## Get comments for a folder

`GET /folders/:folderId/comments`

Needs no token. Rate limit: 120 a minute, per address. An app's token or an API key needs the `comments:read` scope.

### Path parameters

| Field | Type | Required | Notes |
|---|---|---|---|
| `folderId` | `any` | required | The folder's id. |

### Query

| Field | Type | Required | Notes |
|---|---|---|---|
| `shareCode` | `string` | required | The share code of the folder. |

### Response

Returns a list of [Comments](https://hematite.gg/docs/developers/models/comment).

```bash
curl 'https://api.hematite.gg/v1/folders/1/comments?shareCode=x7Kp2QmA'
```

Example `data`:

```json
[
  {
    "id": 1,
    "userId": 1,
    "createdAt": "2026-11-10T18:24:00.000Z",
    "updatedAt": "2026-11-10T18:24:00.000Z",
    "referenceType": "Image",
    "referenceId": 1,
    "content": "That last round",
    "parentId": null,
    "offlineAt": "2026-11-10T18:24:00.000Z",
    "likeCount": 0
  }
]
```

## Get the content of a folder: every image in it for its owner; for anyone else, with the folder's share code, the images in it that are Public or Unlisted and don't hide who uploaded them. Private ones, and those that hide their uploader, show only to the owner.

`GET /folders/:folderId/content`

Needs no token. Rate limit: 120 a minute, per address. An app's token or an API key needs the `folders:read` scope.

### Path parameters

| Field | Type | Required | Notes |
|---|---|---|---|
| `folderId` | `any` | required | The folder's id. |

### Query

| Field | Type | Required | Notes |
|---|---|---|---|
| `shareCode` | `string` | required | The share code of the folder. |

### Response

Returns a list of [Images](https://hematite.gg/docs/developers/models/image).

```bash
curl 'https://api.hematite.gg/v1/folders/1/content?shareCode=x7Kp2QmA'
```

Example `data`:

```json
[
  {
    "id": 1,
    "userId": 1,
    "createdAt": "2026-11-10T18:24:00.000Z",
    "updatedAt": "2026-11-10T18:24:00.000Z",
    "title": "Clutch on Ascent",
    "description": "1v4 on the last round",
    "visibility": "Unlisted",
    "folderId": 1,
    "views": 0,
    "downloads": 0,
    "favorite": false,
    "application": "VALORANT",
    "filename": "a1b2c3d4e5f6.png",
    "size": 2457600,
    "width": 1920,
    "height": 1080,
    "nsfw": false,
    "storageId": 1,
    "autoDeleteAt": null,
    "hideUser": false,
    "shield": false,
    "nsfwLockedAt": "2026-11-10T18:24:00.000Z",
    "privateLockedAt": "2026-11-10T18:24:00.000Z",
    "offlineAt": "2026-11-10T18:24:00.000Z",
    "storage": {
      "key": "images/a1b2c3d4e5f6.png"
    },
    "shareId": 1,
    "shareCode": "x7Kp2QmA",
    "likeCount": 0,
    "commentCount": 0,
    "meta": {
      "id": 1,
      "blurHash": "string",
      "dominantColor": "string",
      "palette": null,
      "hasAlpha": false,
      "animated": false,
      "orientation": 0
    },
    "treatment": "string",
    "burn": {
      "secondsPerView": 0,
      "viewsEach": 0,
      "viewsInAll": 0,
      "then": "Blur",
      "viewsUsed": 0,
      "burnedAt": "string"
    }
  }
]
```

## Increment the download count for a folder and return a URL to the folder zip: of every image in it for its owner, as stored, and for anyone else of the images they see in it (Public or Unlisted, not hiding who uploaded them), with the owner's watermark when they have one.

`POST /folders/:folderId/download`

Needs no token. Rate limit: 2 a minute, per address. An app's token or an API key needs the `folders:read` scope.

### Path parameters

| Field | Type | Required | Notes |
|---|---|---|---|
| `folderId` | `any` | required | The folder's id. |

### Body

| Field | Type | Required | Notes |
|---|---|---|---|
| `shareCode` | `string` | required |  |

### Response

Returns an `object` with these fields:

| Field | Type | Present | Notes |
|---|---|---|---|
| `downloads` | `number` |  | The new number of downloads for the folder. |
| `url` | `string` |  | The presigned URL to the folder zip. |

```bash
curl -X POST 'https://api.hematite.gg/v1/folders/1/download' \
  -H "Content-Type: application/json" \
  -d '{"shareCode":"x7Kp2QmA"}'
```

Example `data`:

```json
{
  "downloads": 0,
  "url": "https://cdn.hematite.gg/images/a1b2c3d4e5f6.png"
}
```

## Make a folder's cover: a collage of its four newest images anyone with its link may see (Public or Unlisted, not hiding who uploaded them), never one marked NSFW. A folder with none of those gets no cover, and loses the one it had.

`POST /folders/:folderId/preview`

Needs a session token. Rate limit: 120 a minute, per address. An app's token or an API key needs the `folders:write` scope.

### Path parameters

| Field | Type | Required | Notes |
|---|---|---|---|
| `folderId` | `any` | required | The folder's id. |

### Response

Returns an `object` with these fields:

| Field | Type | Present | Notes |
|---|---|---|---|
| `key` | `string` |  |  |

```bash
curl -X POST 'https://api.hematite.gg/v1/folders/1/preview' \
  -H "Authorization: $HEMATITE_TOKEN"
```

Example `data`:

```json
{
  "key": "images/a1b2c3d4e5f6.png"
}
```

## Delete a folder preview

`DELETE /folders/:folderId/preview`

Needs a session token. Rate limit: 120 a minute, per address. An app's token or an API key needs the `folders:write` scope.

### Path parameters

| Field | Type | Required | Notes |
|---|---|---|---|
| `folderId` | `any` | required | The folder's id. |

### Response

`data` is empty.

```bash
curl -X DELETE 'https://api.hematite.gg/v1/folders/1/preview' \
  -H "Authorization: $HEMATITE_TOKEN"
```

## Get the folder an image is in, with the image's share code. An image that hides who uploaded it is in no folder for anyone but its uploader, as a folder names its owner. The folder's counts are of what the caller sees in it.

`GET /folders/by-content`

Needs no token. Rate limit: 120 a minute, per address. An app's token or an API key needs the `folders:read` scope.

### Query

| Field | Type | Required | Notes |
|---|---|---|---|
| `folderId` | `number` | required | The ID of the folder that contains the content. |
| `contentId` | `number` | required | The ID of the content that is in the folder. |
| `contentShareCode` | `string` | required | The share code of the content that is in the folder. |

### Response

Returns a [Folder](https://hematite.gg/docs/developers/models/folder).

```bash
curl 'https://api.hematite.gg/v1/folders/by-content?folderId=1&contentId=1&contentShareCode=string'
```

Example `data`:

```json
{
  "id": 1,
  "userId": 1,
  "createdAt": "2026-11-10T18:24:00.000Z",
  "updatedAt": "2026-11-10T18:24:00.000Z",
  "contentType": "Image",
  "name": "Ranked",
  "description": "1v4 on the last round",
  "visibility": "Unlisted",
  "color": "#c4d4e0",
  "previewId": 1,
  "downloads": 0,
  "privateLockedAt": "2026-11-10T18:24:00.000Z",
  "offlineAt": "2026-11-10T18:24:00.000Z",
  "preview": {
    "key": "images/a1b2c3d4e5f6.png"
  },
  "shareId": 1,
  "shareCode": "x7Kp2QmA",
  "contentCount": 1,
  "size": 2457600,
  "contentCountForOthers": 0,
  "sizeForOthers": 0,
  "viewCount": 0,
  "likeCount": 0,
  "commentCount": 0
}
```
