# API reference

> The App API: addresses, authentication, errors and limits.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://app.docs.sypnia.com/api/

For agents: App API at https://app.api.sypnia.com/v1 (Cloud) or <your server>/v1. Auth: Authorization: Bearer <token> — a Sypnia session token (from the device flow), a personal access token, or an OAuth token; agent tokens cannot approve, top up, spend, raise limits or manage members. Browser: the Sypnia session cookie, same-site, with CSRF header. Streaming: POST /sessions/{id}/messages answers text/event-stream. Errors {error {code, message}}: 400 invalid_request/amount_too_small (top-up under USD 5), 401 unauthorized, 403 forbidden/role_required/person_required, 404 not_found, 409 already_exists/conflict, 413 too_large, 415 type_not_allowed, 402 insufficient_credits/spending_limit_reached, 429 rate_limited (retry-after). Rate limits: 600 requests/min per token, 30 messages/min per session.

API: `https://app.api.sypnia.com/v1` **\[Cloud]**, or your App server's address followed by `/v1` **\[Engine]**.

## Authentication

`Authorization: Bearer <token>`, with one of:

| Token                     | From                                                 | Can                         |
| ------------------------- | ---------------------------------------------------- | --------------------------- |
| **Session token**         | `app login` or any Sypnia command line (device flow) | everything your role allows |
| **Personal access token** | **Account → Tokens**, with scopes and an end date    | what its scopes allow       |
| **OAuth token**           | an agent or app you authorized                       | what you allowed it         |

Tokens used by agents can never approve, top up, spend credits, raise limits or manage members: those answer `403 person_required`. In a browser, App uses your Sypnia session cookie instead of a token.

## Errors

```json
{ "error": { "code": "role_required", "message": "Topping up needs the owner or billing role in La Espiga. Ask Ana or Luis." } }
```

| Status | Codes                                                        |
| ------ | ------------------------------------------------------------ |
| 400    | `invalid_request`, `amount_too_small` (a top-up under USD 5) |
| 401    | `unauthorized`                                               |
| 402    | `insufficient_credits`, `spending_limit_reached`             |
| 403    | `forbidden`, `role_required`, `person_required`              |
| 404    | `not_found`                                                  |
| 409    | `already_exists`, `conflict`                                 |
| 413    | `too_large`                                                  |
| 415    | `type_not_allowed`                                           |
| 429    | `rate_limited` (with `retry-after`)                          |

## Limits

600 requests a minute per token, and 30 messages a minute per session. Every limit is in [Limits](https://app.docs.sypnia.com/reference/limits).

- [Endpoints](/api/endpoints/): Account, organizations, projects, the board, sessions, uploads, credits, limits and notifications.
