# Rate limits and size limits

> How many Sofia Space API requests a token may make per minute (the same on every plan), the per-action caps on creates, comments and uploads, the search and per-address limits, request and file size limits, and how to handle 429 responses.

Source: https://docs.sofiaspace.uz/api/rate-limits/

The Sofia Space API limits how fast a token can call it, so one runaway script can't slow down a whole workspace. There are four layers: a **requests-per-minute** limit, lower **per-action caps** on things like creating tasks and posting comments, a separate **search** limit, and a **per-address** limit in front of the API. Bodies and files have **size limits**. Hitting a rate limit returns `429 Too Many Requests`, usually with a `Retry-After` header.

**Who this is for:** developers calling the [Sofia Space API](https://docs.sofiaspace.uz/api/overview.md). The request limits are the same on every plan; file sizes depend on the plan (see [Limits](https://docs.sofiaspace.uz/reference/limits.md)).

## Requests per minute

Which limit applies depends on the kind of token (see [Three kinds of token](https://docs.sofiaspace.uz/api/overview.md#three-kinds-of-token)):

| Token | Limit | Shared by |
| --- | --- | --- |
| Personal token with AI scopes (`tasks:read`, `docs:write` …) | 300 requests per minute | You — all your AI-scope tokens together |
| Integration-account token | 300 requests per minute | That integration account — all its tokens together |
| Personal token with script scopes only (`task:create`, `doc:create`) | 600 requests per minute | The whole workspace — every member's script-scope calls together |

- A call that a token makes with a script scope counts against the workspace's 600, even if the token also has AI scopes (see [Script scopes](https://docs.sofiaspace.uz/api/authentication.md#script-scopes)).
- With an AI-scope or integration-account token, sending, editing or deleting chat messages and reactions has a further cap of 20 a minute, inside the 300.
- Your own use of the app in the browser has its own allowance and never eats into these.
- These numbers are the same on every plan. Changing plan doesn't raise them.

Over the limit you get `429` with `Retry-After: 60` and the body `{"error":"RATE_LIMITED"}`. The allowance refills evenly over the minute, so you can usually continue sooner than 60 seconds.

## Per-action caps

Some actions have a cap per token owner (a person or an integration account), the same on every plan, set far above what a person does by hand:

| Action | Endpoint | Cap |
| --- | --- | --- |
| Create a task | `POST /api/v1/projects/{projectId}/tasks` and `POST /api/v1/orgs/{orgId}/projects/by-key/{projectKey}/tasks` (one shared cap) | 120 per minute |
| Comment on a task | `POST /api/v1/tasks/{taskId}/comments` | 60 per minute |
| Create a page | `POST /api/v1/spaces/{spaceId}/pages` | 60 per minute |
| Comment on a page | `POST /api/v1/pages/{pageId}/comments` | 60 per minute |
| Start a file upload | `POST /api/v1/files/upload-requests` | 120 per minute |
| Create a project | `POST /api/v1/orgs/{orgId}/projects` | 30 per hour |
| Create a space | `POST /api/v1/orgs/{orgId}/spaces` | 30 per hour |

A cap refills evenly: 60 per minute means one more every second. The `429` body names the cap, and `Retry-After` gives the same number of seconds:

```json
{ "error": "RATE_LIMITED", "action": "task-create", "retryAfterSeconds": 1 }
```

## Search

[`GET /api/v1/search`](https://docs.sofiaspace.uz/api/search.md) allows bursts of 20 requests, refilling at 10 per second, per token owner. Over that you get `429` with `"code": "RATE_LIMITED"` and no `Retry-After` header; wait about a second.

## Per address

In front of the API, each IP address may send at most **200 requests to `/api/` in any 10 seconds**, whoever's tokens they carry. An integration server that runs many tokens from one address shares this. Over it you get `429` with a `Retry-After` header; the body may not be JSON.

## Handle a 429

1. Read the `Retry-After` header (seconds). If there is none (search), use 1 second.
2. Wait that long, then retry the same request. Send the same [`Idempotency-Key`](https://docs.sofiaspace.uz/api/idempotency.md) if it's a create.
3. If you hit limits often, slow down: spread a big import over time, or batch work (for example read a project's tasks 100 at a time instead of one by one).

A simple pattern for a bulk import: at most 2 creates per second, and pause on every `429` for `Retry-After` seconds.

## Size limits

| What | Limit |
| --- | --- |
| Any request body sent to the API | 4 MB (larger bodies get `413`) |
| A file attached to a task or page | 100 MB (25 MB on Free, see [Limits](https://docs.sofiaspace.uz/reference/limits.md)). Files go straight to storage, not in the request body — see [Files and attachments](https://docs.sofiaspace.uz/api/files-and-attachments.md) |
| Blocked file types | `.exe`, `.dll`, `.bat`, `.cmd`, `.com`, `.scr`, `.msi`, `.jar`, `.app`, `.deb`, `.rpm` |
| Task title | 500 characters |
| Task description | 100,000 characters |
| Task or page comment | 40,000 characters |
| Page of tasks / comments / search results | 100 / 100 / 50 items |
| User IDs in one [batch-get](https://docs.sofiaspace.uz/api/me-and-workspace.md#turn-user-ids-into-names) | 200 (more are ignored) |

Text over its limit is refused with `400 TEXT_TOO_LONG` or `TEXT_TOO_LARGE`; a task title over its limit with `400 NAME_TOO_LONG`.

## What you can't do

- You can't raise the request limits or the per-action caps by changing plan.
- There is no header telling you how many requests you have left; react to `429` instead.

## Related

- [Errors](https://docs.sofiaspace.uz/api/errors.md#rate-limits)
- [Idempotency and retries](https://docs.sofiaspace.uz/api/idempotency.md)
- [Limits](https://docs.sofiaspace.uz/reference/limits.md)
