# Tags
Source: https://docs.file.ai/ingest/tags

> List the file tags in a project with GET /v1/tags, search them by name, and set the tags on a file.

fileAI app

# Tags

Copy pageCopy page

List the file tags in a project with GET /v1/tags, search them by name, and set the tags on a file.

Copy pageCopy page

Tags are the labels your team puts on files in the fileAI app, such as `Invoices` or `Needs review`. `GET /v1/tags` lists the tags in a project, with each tag’s id, name, slug and color, so your integration can show the same labels or match them to its own.

## [](#how-it-works)How it works

*   **One project per request.** The list covers the project your API key works in. A [project key](/authentication#key-types) uses its own project. A personal key names the project in the `x-project-id` header.
*   **Sorted by name, case-sensitively.** Names starting with an uppercase letter come before names starting with a lowercase one, so `Zebra` is listed before `apple`.
*   **Deleted tags are left out.** Every other tag in the project is listed, including tags that aren’t on any file yet.
*   **Search matches part of a name.** `search=voice` finds `Invoices` and `voice notes`. Matching ignores case, and characters such as `.` or `*` are matched literally, not as patterns.
*   **Read-only keys work.** Listing tags is a `GET`, so a [read-only key](/authentication#what-a-key-can-do) can call it.

## [](#example)Example

The examples use `FILEAI_BASE_URL`, set to `https://api.orion.file.ai/prod/v1` or your [regional host](/authentication#regions).

cURL

Python

Node

```
curl "$FILEAI_BASE_URL/tags?page=1&limit=50&search=invoice" \
  -H "x-api-key: $FILEAI_API_KEY"
```

```
import os
import requests

response = requests.get(
    f"{os.environ['FILEAI_BASE_URL']}/tags",
    headers={"x-api-key": os.environ["FILEAI_API_KEY"]},
    params={"page": 1, "limit": 50, "search": "invoice"},
)
response.raise_for_status()
for tag in response.json()["data"]:
    print(tag["id"], tag["name"], tag["color"])
```

```
const params = new URLSearchParams({ page: "1", limit: "50", search: "invoice" });
const response = await fetch(`${process.env.FILEAI_BASE_URL}/tags?${params}`, {
  headers: { "x-api-key": process.env.FILEAI_API_KEY },
});
if (!response.ok) throw new Error(`fileAI ${response.status}`);
const { data, pagination } = await response.json();
```

With a personal key, add the project:

```
curl "$FILEAI_BASE_URL/tags" \
  -H "x-api-key: $FILEAI_API_KEY" \
  -H "x-project-id: $FILEAI_PROJECT_ID"
```

### [](#response)Response

200 OK

```
{
  "data": [
    {
      "id": "6630f1c2a1b2c3d4e5f60799",
      "name": "Invoices",
      "slug": "invoices",
      "color": "#1E88E5",
      "createdAt": "2026-11-01T09:30:00.000Z",
      "updatedAt": "2026-11-20T14:05:12.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 50,
    "total": 1
  }
}
```

Field

Type

Description

`data[].id`

string

The tag’s id.

`data[].name`

string

The name shown in the app.

`data[].slug`

string

A URL-safe form of the name.

`data[].color`

string

Hex color, such as `#1E88E5`.

`data[].createdAt`, `data[].updatedAt`

string

ISO 8601 date-times.

`pagination.page`

integer

The page returned.

`pagination.limit`

integer

The page size applied.

`pagination.total`

integer

Tags matching the request across all pages, after `search`.

## [](#page-through-all-tags)Page through all tags

This endpoint uses page numbers, not cursors. Request pages in order until you have `total` tags. A page past the end returns `200` with an empty `data` array.

```
import os
import time
import requests

base = os.environ["FILEAI_BASE_URL"]
headers = {"x-api-key": os.environ["FILEAI_API_KEY"]}

tags, page = [], 1
while True:
    response = requests.get(f"{base}/tags", headers=headers, params={"page": page, "limit": 100})
    if response.status_code == 429:
        time.sleep(int(response.headers.get("Retry-After", "1")))
        continue
    response.raise_for_status()
    body = response.json()
    tags.extend(body["data"])
    if not body["data"] or len(tags) >= body["pagination"]["total"]:
        break
    page += 1
```

## [](#set-a-file’s-tags)Set a file’s tags

`PATCH /v1/files/{fileId}` with `tagIds` replaces the file’s tags with the ones you send. Use ids from `GET /v1/tags`.

```
curl -X PATCH "$FILEAI_BASE_URL/files/b765bd00-181e-4737-b4d9-004dadd6bd45" \
  -H "x-api-key: $FILEAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "tagIds": ["6630f1c2a1b2c3d4e5f60799"] }'
```

200 OK

```
{
  "fileId": "b765bd00-181e-4737-b4d9-004dadd6bd45",
  "tags": [
    { "id": "6630f1c2a1b2c3d4e5f60799", "name": "Invoices", "slug": "invoices", "color": "#1E88E5" }
  ]
}
```

*   **It replaces, not adds.** To add a tag, read the file’s current `tags` with `GET /v1/files?fileIds=<fileId>`, append the new id, then send the full list. The two calls aren’t atomic: if something else changes the file’s tags in between, your `PATCH` overwrites that change. When more than one system tags the same files, have one of them own the tags, or read again after writing to check.
*   **`[]` removes every tag.** Leaving `tagIds` out keeps the current tags.
*   **Up to 50 ids.** Repeated ids are collapsed, and the order you send is kept.
*   **All or nothing.** An unknown or deleted tag id returns `422 VALIDATION_FAILED` naming the bad ids, and the file is not changed.
*   **Deleted files can’t be tagged.** Changing the tags of a deleted file returns `404`.
*   **Read-only keys can’t set tags.** This is a write, so a read-only key gets `403 READONLY_KEY`.

The same endpoint records an export outcome with `integrationExportStatus`. You can send both in one request. If the file has an export status, the response includes its `exportInfo` too. See [Xero export](/deliver/xero-export) for the export fields. `GET /v1/files` returns each file’s `tags` as `{ id, name, slug, color }`, in the order they were set. Deleted tags are left out.

## [](#reference)Reference

### [](#headers)Headers

Header

Required

Description

`x-api-key`

Yes

Your API key. See [Authentication](/authentication).

`x-project-id`

Personal keys only

The project to list tags for. Project keys ignore it.

### [](#query-parameters)Query parameters

Parameter

Type

Default

Description

`page`

integer

1

Page number, from 1 to 10,000.

`limit`

integer

50

Tags per page, from 1 to 100.

`search`

string

—

Only tags whose name contains this text, ignoring case. Up to 100 characters.

`page` and `limit` must be whole numbers written as plain digits: `1.5`, `1e1`, `two` and repeated values such as `page=1&page=2` are rejected. Any other query parameter is rejected too, so a typo such as `serach=` returns a `422` instead of being silently ignored.

### [](#errors)Errors

Errors are [problem documents](/api/errors). Branch on `code`.

Status

`code`

When

400

`BAD_REQUEST`

A personal key was sent without an `x-project-id` header.

401

`UNAUTHENTICATED`

The `x-api-key` header is missing, or the key is unknown.

403

`FORBIDDEN`

The key is inactive, or a personal key named a project it can’t open.

422

`VALIDATION_FAILED`

`page`, `limit` or `search` is out of range or malformed, or an unknown query parameter was sent.

429

`RATE_LIMITED`

The project is over its [rate limit](/api/rate-limits). Wait `Retry-After` seconds and retry.

400: personal key without x-project-id

```
{
  "type": "https://errors.file.ai/bad-request",
  "title": "Bad request",
  "status": 400,
  "detail": "This API key covers workspaces, not one project. Send the project id in the x-project-id header.",
  "instance": "/prod/v1/tags",
  "code": "BAD_REQUEST",
  "requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
  "errors": []
}
```

401: missing or unknown key

```
{
  "type": "https://errors.file.ai/unauthenticated",
  "title": "Unauthenticated",
  "status": 401,
  "detail": "API key is missing",
  "instance": "/prod/v1/tags",
  "code": "UNAUTHENTICATED",
  "requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
  "errors": []
}
```

An unknown key returns the same code with `detail` `Invalid API key.`

403: inactive key or project out of reach

```
{
  "type": "https://errors.file.ai/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "API key is inactive.",
  "instance": "/prod/v1/tags",
  "code": "FORBIDDEN",
  "requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
  "errors": []
}
```

A personal key naming a project it can’t open returns the same code with `detail` `You do not have access to this project.`

422: invalid query parameter

Request: `GET /v1/tags?limit=500`

```
{
  "type": "https://errors.file.ai/validation-failed",
  "title": "Validation failed",
  "status": 422,
  "detail": "One or more fields are invalid.",
  "instance": "/prod/v1/tags",
  "code": "VALIDATION_FAILED",
  "requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
  "errors": [
    {
      "code": "INVALID",
      "detail": "limit must not be greater than 100",
      "pointer": "#/limit"
    }
  ]
}
```
429: rate limit exceeded

```
{
  "type": "https://errors.file.ai/rate-limited",
  "title": "Too many requests",
  "status": 429,
  "detail": "API rate limit exceeded",
  "instance": "/prod/v1/tags",
  "code": "RATE_LIMITED",
  "requestId": "0f1c8e03-978e-40d5-bc93-6894a57f9324",
  "errors": [],
  "retryAfter": 18
}
```

See [List tags](/api-reference/files/list-tags) in the API reference to try the request in the playground.

## [](#related)Related

## Files and folders

Group files into folders in the app or with the API.

## Authentication

Project and personal keys, and the `x-project-id` header.

## Pagination

How other list endpoints page their results.

## Errors

Problem documents, error codes and request ids.

[Previous](/ingest/folders)[

Validation

See where each extracted value came from in the file, and whether it has been validated.

Next

](/verify/citations-validations)

⌘I

## On this page

Back to top

*   [How it works](#how-it-works)
*   [Example](#example)
    *   [Response](#response)
*   [Page through all tags](#page-through-all-tags)
*   [Set a file’s tags](#set-a-file%E2%80%99s-tags)
*   [Reference](#reference)
    *   [Headers](#headers)
    *   [Query parameters](#query-parameters)
    *   [Errors](#errors)
*   [Related](#related)
