# List files

> The files of the workspace in a region, newest first.

Source: https://docs.stacksync.com/api-reference/files/list_files

`GET https://api.stacksync.com/v1/workspaces/{workspace_id}/files`

- Operation: `list_files`
- Resource: Files
- Access: read-only

## Authentication

- `Authorization: Bearer <key>`: A workspace API key (workspace_…, created by a workspace owner under Workspace settings > Stacksync API) acts with editor rights on that workspace only; a user API key (user_…, created under Profile > Stacksync API) acts as that user in every workspace they belong to. POST, PUT and PATCH requests must send Content-Type: application/json. Every authentication failure answers 403.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `workspace_id` | integer | Yes | The workspace. List the ones your key can reach with GET /v1/workspaces. |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `region` | string (besg \| usnv) | Yes | Region whose files are listed: besg (Europe) or usnv (United States) |
| `search` | string \| null, 1 to 255 characters | No | Only files whose name contains this text |
| `limit` | integer, 1 to 100, default 50 | No | Maximum number of files returned, at most 100 |
| `cursor` | string \| null, 1 to 1000 characters | No | next_cursor of the previous page; absent for the first page |

## Returns

### 200 OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | array of object (WorkspaceFile) | Yes |  |
| `data[].file_id` | string | Yes |  |
| `data[].name` | string | Yes |  |
| `data[].mime_type` | string \| null | Yes |  |
| `data[].size_bytes` | integer \| null | Yes |  |
| `data[].tags` | array of string | Yes |  |
| `data[].source` | string \| null | Yes |  |
| `data[].source_ref` | string \| null | Yes | Id of the resource the file belongs to, null when it belongs to none |
| `data[].created_at` | string \| null | Yes |  |
| `data[].region` | string | Yes |  |
| `has_more` | boolean | Yes | Whether more files may follow this page: request the next one with cursor = next_cursor |
| `next_cursor` | string \| null | Yes | Pass as cursor to get the next page; null on the last page |

## Example request

```bash
curl -X GET "https://api.stacksync.com/v1/workspaces/{workspace_id}/files?region=besg" \
  -H "Authorization: Bearer $STACKSYNC_API_KEY"
```

## Example response (200)

```json
{
  "data": [
    {
      "file_id": "<file_id>",
      "name": "<name>",
      "mime_type": "<mime_type>",
      "size_bytes": 0,
      "tags": [
        "<tags>"
      ],
      "source": "<source>",
      "source_ref": "<source_ref>",
      "created_at": "<created_at>",
      "region": "<region>"
    }
  ],
  "has_more": false,
  "next_cursor": "<next_cursor>"
}
```

## Errors

| Status | Meaning | Body |
| --- | --- | --- |
| 400 | Bad Request | `{ "error": string, "msg": string, "field": string \| null }` |
| 403 | Forbidden | `{ "error": string, "msg": string, "field": string \| null }` |

## Related

- [API Reference overview](https://docs.stacksync.com/api-reference): base URLs, regions, pagination, idempotency and errors
- [Authentication](https://docs.stacksync.com/api-reference/authentication): API keys and the 403 answers
- OpenAPI document: https://docs.stacksync.com/openapi.json
- [Get a file](https://docs.stacksync.com/api-reference/files/get_file)