# Errors

> The JSON shape of Sofia Space API errors, what each HTTP status means, the stable error codes your code can rely on, and the special bodies for refused tokens, plan limits, workflow rules and rate limits.

Source: https://docs.sofiaspace.uz/api/errors/

When a Sofia Space API call fails, you get an HTTP status from the table below and a JSON body. Most errors carry a stable machine-readable **`code`** next to an English message; branch on the code, never on the message text, which can change. A few refusals that happen before your request reaches the data put their code in `error` instead — all the shapes are listed here so your error handling covers every case.

**Who this is for:** developers calling the [Sofia Space API](https://docs.sofiaspace.uz/api/overview.md) with a personal or integration-account token.

## The usual error body

```json
{
  "error": "A status named 'Review' already exists in this project",
  "code": "STATUS_NAME_TAKEN",
  "params": { "name": "Review" }
}
```

| Field | Always there | Meaning |
| --- | --- | --- |
| `error` | yes | English, human-readable. For logs, not for logic. |
| `code` | yes | Stable code (below). Falls back to the status's generic code, such as `NOT_FOUND`. |
| `params` | no | Values taken from the message, for example the `max` length or the clashing `name`. |

## HTTP statuses

| Status | Generic `code` | Meaning |
| --- | --- | --- |
| `400` | `INVALID_ARGUMENT`, `REQUEST_MALFORMED` | The request is wrong: a missing or invalid field, malformed JSON, a missing or mistyped parameter |
| `401` | `UNAUTHENTICATED` | No token, or the token is wrong, revoked or expired |
| `402` | — (`error: SUSPENDED`) | The workspace is suspended for billing; changes are refused until it's paid |
| `403` | `PERMISSION_DENIED` | You may not do this: the owner's role, the token's scopes, or a workspace setting (see below) |
| `404` | `NOT_FOUND` | It doesn't exist — or you can't see it. Also an unknown path |
| `405`, `415` | `REQUEST_MALFORMED` | Wrong HTTP method for this path, or a body that isn't JSON |
| `409` | `ALREADY_EXISTS`, `FAILED_PRECONDITION`, `ABORTED` | It clashes with what's there: a duplicate name or key, a workflow rule, a plan limit, a page changed since your draft. `ABORTED` means "safe to retry" |
| `413` | — | The request body is too large (see [Size limits](https://docs.sofiaspace.uz/api/rate-limits.md#size-limits)); the body may not be JSON |
| `423` | — (`error: ORG_ARCHIVED`, `ORG_DELETION_PENDING`) | The workspace is archived (writes refused) or being deleted |
| `429` | — (`error: RATE_LIMITED`) | Too many requests; wait for `Retry-After` seconds. See [Rate limits](#rate-limits) for the other shapes |
| `500` | `INTERNAL` | Something broke on our side; retry later |
| `503` | `UNAVAILABLE` | A part of Sofia Space is briefly unavailable; retry with backoff |
| `504` | `DEADLINE_EXCEEDED` | It took too long; retry with backoff |

A `404` and a `403` can both mean "you can't open this". Sofia Space doesn't always tell you whether something exists if you can't see it.

## Error codes you can rely on

These codes are a public contract: they are never renamed. The list covers what the endpoints in this reference can return.

All the codes below come with `400`, except where the table says otherwise. Branch on `code`, not on the status.

### Tasks and projects

| Code | When |
| --- | --- |
| `PROJECT_CREATE_NOT_ALLOWED` | `403`. Creating a project needs an Org Admin, or a role allowed to create projects (for example **Project Creator**); `projects:admin` alone isn't enough |
| `STATUS_NAME_TAKEN` | A status with that name already exists in the project (`params.name`) |
| `TRANSITION_EXISTS` | That workflow transition already exists |
| `TRANSITION_SAME_STATUS` | A transition from a status to itself |
| `TASK_PARENT_SELF`, `TASK_PARENT_CYCLE` | A task can't be its own parent, or the parent of its parent |
| `TASK_HIERARCHY_INVALID` | That nesting isn't allowed (for example an epic as a subtask) |
| `TASK_PARENT_ARCHIVED` | Restore the parent task first |
| `TASK_BLOCKS_SELF`, `TASK_BLOCK_EXISTS` | A task can't block itself; that block already exists |
| `BLOCKER_LOOP` | The blocker would make a loop: the blocking task already waits, directly or through other tasks, on the one it would block |
| `TASKS_DIFFERENT_WORKSPACE` | A blocker between tasks of two different workspaces |
| `SUBTASK_DEPTH` | Subtasks are one level deep: the parent is itself a subtask, or the task already has subtasks |
| `STORY_POINTS_TOO_HIGH` | Story points above the maximum (`params.max`, 1000) |
| `EXTERNAL_REF_TAKEN` | `409`. That record in your system is already linked to another task (`params.system`, `params.externalId`) |
| `EXTERNAL_REF_LIMIT` | `409`. The task already holds the most linked records it can (`params.max`, 20) |
| `MEMBER_EMAIL_NOT_FOUND` | [Create by project key](https://docs.sofiaspace.uz/api/integrations.md#create-a-task-by-project-key): no active member has exactly that e-mail (`params.field`: `assignee` or `reporter`) |
| `MEMBER_EMAIL_AMBIGUOUS` | Create by project key: too many members match the e-mail to find the exact one; pass their user ID instead (`params.field`) |
| `SPRINT_WRONG_PROJECT` | The sprint belongs to another project |
| `DATE_RANGE_INVALID` | A start date after the due date, or a range the wrong way round |
| `DATE_FORMAT_INVALID` | A date isn't `yyyy-MM-dd` |
| `COMMENT_EMPTY` | Comment content is blank |
| `COMMENT_REPLY_DEPTH` | Replies are one level deep: you can't reply to a reply |
| `NAME_REQUIRED`, `NAME_TOO_LONG` | A required name or title is blank (also a blank task title), or too long (`params.max`) |
| `TEXT_TOO_LONG`, `TEXT_TOO_LARGE` | A description or comment is over its limit (see [Size limits](https://docs.sofiaspace.uz/api/rate-limits.md#size-limits)) |
| `WORKLOG_DURATION_INVALID` | A worklog must be 1 minute to 24 hours |
| `WORKLOG_DESCRIPTION_REQUIRED`, `WORKLOG_FUTURE_NOT_ALLOWED`, `WORKLOG_DONE_NOT_ALLOWED`, `WORKLOG_DATE_REQUIRED` | The project's time-tracking rules refuse this worklog |
| `TOO_MANY_ITEMS` | Too many items in one request (`params.max`) |

Some refusals have no code of their own yet and come back with the generic code of their status; read `error` for the reason:

| Refusal | Status and `code` |
| --- | --- |
| A custom-field value that doesn't fit its field | `400 INVALID_ARGUMENT` |
| A backlog reorder with a neighbour from another project, or neighbours the wrong way round | `400 INVALID_ARGUMENT` |
| Time tracking off for the project, or a project that doesn't use the timer | `409 FAILED_PRECONDITION` |

### Docs

| Code | When |
| --- | --- |
| `PAGE_MOVE_CYCLE` | A page can't move under itself or one of its subpages |
| `PAGE_CHANGED_SINCE_DRAFT` | `409`. Someone published since the version you started from (`params.currentVersion`) |
| `LANGUAGE_INVALID` | Not a supported language code |

### Requests and access

| Code | When |
| --- | --- |
| `REQUEST_MALFORMED` | The JSON body can't be read, or a parameter is missing or has the wrong type (also with `405` and `415`) |
| `CURSOR_INVALID` | A pagination cursor is damaged |
| `NOT_ORG_MEMBER` | `403`. The token's owner isn't a member of that workspace |
| `ORG_NOT_FOUND` | `404`. No workspace at that address |
| `USER_NOT_FOUND` | `404`. No such user |
| `SEARCH_QUERY_TOO_SHORT` | The search text is too short (`params.min`) |
| `FILE_TOO_LARGE`, `FILE_EMPTY` | The file is over the limit, or empty |
| `RATE_LIMITED` | `429`. Too many searches (see [Rate limits](#rate-limits)) |

Anything not in a table comes back with the generic code of its status (`NOT_FOUND`, `ALREADY_EXISTS`, `FAILED_PRECONDITION`, `PERMISSION_DENIED`, `INVALID_ARGUMENT`, `RESOURCE_EXHAUSTED`). New codes may be added; treat an unknown code like its status's generic one.

## Moving a task: the three workflow refusals

[`POST /api/v1/tasks/{taskId}/status`](https://docs.sofiaspace.uz/api/tasks.md#move-a-task-to-another-status) answers `409` with its own body when the move breaks a rule:

```json
{
  "error": "BLOCKED_BY_INCOMPLETE_TASK",
  "message": "Cannot move this task to a completion status: it is blocked by 1 task(s) that are not yet in a completion status. Resolve the blocker(s) first."
}
```

| `error` | Why |
| --- | --- |
| `INVALID_TRANSITION` | The project's workflow has no transition from the current status to that one |
| `INCOMPLETE_SUBTASKS` | Moving to a done status while subtasks are still open |
| `BLOCKED_BY_INCOMPLETE_TASK` | Moving to a done status while a blocking task is unfinished. A blocker in the same project always stops the move; a blocker in another project stops it only when the project's cross-project setting is **Block** (`crossProjectBlockerGate: "BLOCK"`) |

## Token and AI-app refusals

The token check runs before anything else. Two shapes:

```json
{ "error": "This token does not have the 'task:create' scope", "code": "PERMISSION_DENIED" }
```

```json
{ "error": "INSUFFICIENT_SCOPE", "acceptedScopes": ["tasks:write"] }
```

The first shape (with `code`) is for a token that can't use this endpoint at all, has none of the needed kind of scope, or belongs to another workspace; `401` with `"code": "UNAUTHENTICATED"` is for a wrong, revoked or expired token. The second shape (`error` only):

| `error` | Status | Meaning |
| --- | --- | --- |
| `INSUFFICIENT_SCOPE` | 403 | The token lacks every scope in `acceptedScopes` — also when the owner's role no longer allows it |
| `ROLE_NOT_ALLOWED` | 403 | The token has the scope, the owner's role doesn't allow it here |
| `NOT_AVAILABLE_TO_AGENTS` | 403 | The endpoint isn't open to full-access (AI-scope) tokens |
| `SIGNED_IN_APP_ONLY` | 403 | Deleting and file download links: only apps you signed in to can do these, never an API token. The body adds `"message": "This action needs an app you signed in to; API tokens can't do it"`. See [the list](https://docs.sofiaspace.uz/api/authentication.md#actions-only-signed-in-apps-can-do) |
| `MCP_DISABLED` | 403 | **AI agents** is switched off in this workspace (personal AI-scope tokens only) |
| `AI_APP_NOT_APPROVED` | 403 | The workspace allows only approved AI apps, and **API token** isn't one (personal AI-scope tokens only) |
| `AI_APP_BLOCKED` | 403 | An admin turned this token off for you (personal AI-scope tokens only) |

Integration-account tokens never get the last three, but they do get `SIGNED_IN_APP_ONLY`. More on each in [Authentication and scopes](https://docs.sofiaspace.uz/api/authentication.md#refusals-youll-see).

## Plan limits and switched-off modules

When a plan limit or a workspace setting stops a create:

```json
{
  "error": "ENTITLEMENT_DENIED",
  "key": "tasks.projects.max",
  "limit": 3,
  "current": 3,
  "isUnlimited": false,
  "upgradeUrl": "/settings/billing?upgrade=1"
}
```

- `409 ENTITLEMENT_DENIED` — a quota is full (for example the number of projects). `key`, `limit` and `current` say which. Plan numbers are on [Limits](https://docs.sofiaspace.uz/reference/limits.md).
- `403 ENTITLEMENT_DENIED` — a feature isn't on the workspace's plan.
- `403` with `"error": "MODULE_DISABLED"` and `"module": "docs"` — an Org Admin switched that module off in **Settings → Advanced → Modules**.
- `402` with `"error": "SUSPENDED"` — the workspace is suspended for billing; reads still work.

## Rate limits

There are three `429` shapes:

```json
{ "error": "RATE_LIMITED" }
```

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

```json
{ "error": "Too many search requests", "code": "RATE_LIMITED" }
```

- The first is the requests-per-minute limit, with `Retry-After: 60`.
- The second is a per-action cap; `action` names it, and `Retry-After` matches `retryAfterSeconds`.
- The third is the search limit, with no `Retry-After` — wait about a second.

A `429` can also come from the per-address limit in front of the API, with `Retry-After` and possibly a non-JSON body. See [Rate limits and size limits](https://docs.sofiaspace.uz/api/rate-limits.md).

## Retrying safely

| Status | Retry? |
| --- | --- |
| `429` | Yes, after `Retry-After` seconds (1 second if there is none) |
| `500`, `503`, `504` | Yes, with exponential backoff (1 s, 2 s, 4 s …). Send an [`Idempotency-Key`](https://docs.sofiaspace.uz/api/idempotency.md) on creates so a retry can't create a duplicate |
| `409` with `"code": "REQUEST_IN_PROGRESS"` | Yes: the same create is still running; retry in a second |
| `409` with `"code": "ABORTED"` | Yes, once |
| `400`, `401`, `403`, `404`, `413`, other `409` | No — fix the request first |

The `REQUEST_IN_PROGRESS` body has `code` and `message`, but no `error`: `{"code":"REQUEST_IN_PROGRESS","message":"The same request is still being processed"}`.

## Related

- [Authentication and scopes](https://docs.sofiaspace.uz/api/authentication.md)
- [Rate limits and size limits](https://docs.sofiaspace.uz/api/rate-limits.md)
- [Idempotency and retries](https://docs.sofiaspace.uz/api/idempotency.md)
