# Storage

> A community’s storage spaces and the files in them.

Source: https://klank.work/docs/api-reference/storage

Base URL: https://api.klank.work/v1. Conventions (keys, envelope, pages, errors, idempotency): https://klank.work/docs/api-reference.md

## GET /v1/communities/:id/storage/files

List the files in a storage space, by path.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |

Query parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `space` | string | Yes | Matches `^[a-z0-9][a-z0-9-]{0,39}$`. |
| `prefix` | string | No | At most 512 characters. |
| `after` | string | No | At most 512 characters. |
| `limit` | integer | No | 1 to 100. Default `25`. |

```bash
curl https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/storage/files \
  -H "Authorization: Bearer $KLANK_API_KEY"
```

Sample response (200):

```json
{
  "data": [
    {
      "space": "renders",
      "path": "tool.txt",
      "size_bytes": 13,
      "content_type": "text/plain",
      "ready_at": "2026-12-01T19:52:38.138Z"
    }
  ],
  "meta": {
    "request_id": "req_example",
    "next_cursor": null,
    "has_more": false
  }
}
```

## POST /v1/communities/:id/storage/files

Reserve room for a file in a storage space and get a 15-minute upload link.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |

Body:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `space` | string | Yes | Matches `^[a-z0-9][a-z0-9-]{0,39}$`. |
| `path` | string | Yes | At most 512 characters. |
| `size_bytes` | integer | Yes | 1 to 5000000000. |
| `content_type` | string | Yes | At most 255 characters. |

```bash
curl -X POST https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/storage/files \
  -H "Authorization: Bearer $KLANK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"space":"example","path":"path","size_bytes":1,"content_type":"content type"}'
```

Sample response (201):

```json
{
  "data": {
    "upload_id": "00000000-0000-4000-8000-000000000001",
    "url": "https://storage.example.com/signed/private/communities%2F00000000-0000-4000-8000-000000000002%2Fstore%2F00000000-0000-4000-8000-000000000003%2F00000000-0000-4000-8000-000000000001",
    "method": "PUT",
    "headers": {
      "content-type": "text/plain",
      "content-length": "9"
    },
    "expires_at": "2026-12-01T20:07:37.395Z"
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## POST /v1/communities/:id/storage/files/:fileId/ready

Finish an upload so the file is ready, replacing any file at the same path.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |
| `fileId` | string | Yes | The file’s ID. |

```bash
curl -X POST https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/storage/files/00000000-0000-4000-8000-000000000001/ready \
  -H "Authorization: Bearer $KLANK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Sample response (200):

```json
{
  "data": {
    "space": "renders",
    "path": "final.txt",
    "size_bytes": 8,
    "content_type": "text/plain",
    "ready_at": "2026-12-01T19:52:37.892Z"
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## DELETE /v1/communities/:id/storage/files/:space

Remove a file from a storage space.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |
| `space` | string | Yes | The storage space’s name. |

Query parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `path` | string | Yes | At most 512 characters. |

```bash
curl -X DELETE https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/storage/files/assets \
  -H "Authorization: Bearer $KLANK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Sample response (200):

```json
{
  "data": {
    "space": "renders",
    "path": "intro/cut-1.txt",
    "deleted": true
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## GET /v1/communities/:id/storage/files/:space

Get a one-hour download link to a file in a storage space.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |
| `space` | string | Yes | The storage space’s name. |

Query parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `path` | string | Yes | At most 512 characters. |

```bash
curl https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/storage/files/assets \
  -H "Authorization: Bearer $KLANK_API_KEY"
```

Sample response (200):

```json
{
  "data": {
    "space": "renders",
    "path": "final.txt",
    "size_bytes": 16,
    "content_type": "text/plain",
    "url": "https://storage.example.com/signed/private/communities%2F00000000-0000-4000-8000-000000000001%2Fstore%2F00000000-0000-4000-8000-000000000002%2F00000000-0000-4000-8000-000000000003",
    "expires_at": "2026-12-01T20:52:37.907Z"
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## GET /v1/communities/:id/storage/spaces

List your community's storage spaces and how much of its storage is used.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |

```bash
curl https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/storage/spaces \
  -H "Authorization: Bearer $KLANK_API_KEY"
```

Sample response (200):

```json
{
  "data": {
    "used_bytes": 0,
    "ceiling_bytes": 100000000000,
    "spaces": []
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## POST /v1/communities/:id/storage/spaces

Create a storage space in your community, or update its description.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |

Body:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string | Yes | Matches `^[a-z0-9][a-z0-9-]{0,39}$`. |
| `description` | string | No | At most 280 characters. |

```bash
curl -X POST https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/storage/spaces \
  -H "Authorization: Bearer $KLANK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"name":"example"}'
```

Sample response (200):

```json
{
  "data": {
    "name": "refs",
    "description": "Reference footage",
    "created_at": "2026-12-01T19:52:37.616Z"
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## DELETE /v1/communities/:id/storage/spaces/:name

Remove a storage space and every file in it.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |
| `name` | string | Yes | The storage space’s name. |

```bash
curl -X DELETE https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/storage/spaces/assets \
  -H "Authorization: Bearer $KLANK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Sample response (200):

```json
{
  "data": {
    "name": "renders",
    "deleted": true
  },
  "meta": {
    "request_id": "req_example"
  }
}
```

## PATCH /v1/communities/:id/storage/spaces/:name

Update a storage space's description.

Who can call it: The community’s CEO.

Path parameters:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | string | Yes | The community’s ID. |
| `name` | string | Yes | The storage space’s name. |

Body:

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `description` | string | Yes | At most 280 characters. |

```bash
curl -X PATCH https://api.klank.work/v1/communities/00000000-0000-4000-8000-000000000001/storage/spaces/assets \
  -H "Authorization: Bearer $KLANK_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"description":"description"}'
```

Sample response (200):

```json
{
  "data": {
    "name": "renders",
    "description": "Cut renders",
    "created_at": "2026-12-01T19:52:37.272Z"
  },
  "meta": {
    "request_id": "req_example"
  }
}
```
