# API reference

> The Run API: addresses, authentication, errors, pagination and limits.

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

For agents: Run API base https://run.api.sypnia.com/v1 (engine: <engine>/v1); Bearer auth with Sypnia session, PAT syp_pat_, deploy token syp_rdt_, engine API key syp_rk_; scopes run:read/run:deploy/run:admin; error shape {error:{code,message,doc_url}}; codes 400 invalid_request/invalid_config, 401, 403 forbidden/approval_required, 404, 409 conflict/deploy_not_ready/domain_taken/name_taken, 402 credits_exhausted, 429 rate_limited, 5xx; cursor pagination; Idempotency-Key 24 h.

Base address: `https://run.api.sypnia.com/v1` **\[Cloud]**, or `<engine>/v1` **\[Engine]**. Requests and responses are JSON over HTTPS.

## Authentication

`Authorization: Bearer <token>`, where the token is one of:

| Token                                     | Gets                                                                                      | Scopes                                         |
| ----------------------------------------- | ----------------------------------------------------------------------------------------- | ---------------------------------------------- |
| Sypnia session (console, device flow)     | what your organization role allows                                                        | `run:read`, `run:deploy`, `run:admin` per role |
| Personal access token (`syp_pat_…`)       | the scopes you gave it, within your role                                                  | chosen at creation                             |
| Deploy token (`syp_rdt_…`)                | deploy one app to listed environments                                                     | `run:deploy` on that app                       |
| Engine API key (`syp_rk_…`) **\[Engine]** | the engine's admin or a scope you chose                                                   | per key                                        |
| Case key (`syp_rck_…`)                    | call one case that starts `external`, at `POST /hooks/<case-id>` of the app; nothing else | that case only                                 |

## Errors

Every error has the same shape:

```json
{ "error": { "code": "deploy_not_ready", "message": "dpl_7h3k is still building.", "doc_url": "https://run.docs.sypnia.com/api#errors" } }
```

| Status | Codes                                                        |
| ------ | ------------------------------------------------------------ |
| 400    | `invalid_request`, `invalid_config`                          |
| 401    | `unauthorized`                                               |
| 403    | `forbidden`, `approval_required`                             |
| 404    | `not_found`                                                  |
| 409    | `conflict`, `deploy_not_ready`, `domain_taken`, `name_taken` |
| 402    | `credits_exhausted` **\[Cloud]**                             |
| 429    | `rate_limited` (with `Retry-After`)                          |
| 5xx    | `internal`, `aws_unavailable`                                |

## Pagination

Lists return `{ "data": [...], "next": "<cursor>" }`; pass `?cursor=` for the next page and `?limit=` (1–100, default 20).

## Idempotency

`POST` requests accept `Idempotency-Key`; a repeat within 24 hours returns the first result.

- [Endpoints](/api/endpoints/): Apps, deploys, releases, environment, domains, jobs, queues, logs and tokens.
