# Endpoints

> Apps, deploys, releases, environment, domains, jobs, queues, logs and tokens.

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

For agents: Run API endpoints: apps (GET/POST/PATCH/DELETE /apps), deploys (POST /apps/{app}/deploys with git ref, upload or prebuilt; POST /uploads signed URL; GET deploys; GET /deploys/{id}; build logs SSE), releases (POST environments/{env}/release {deploy, gradual, reason}, rollback, releases history), deploy statuses, vars (GET/PUT/DELETE, secrets never returned), domains (POST returns records), tokens, jobs (runs, trigger), queues (dlq, replay), logs (filters, follow), approvals (GET /approvals, POST decision).

## Apps

| Method and path      | Does                                                                  |
| -------------------- | --------------------------------------------------------------------- |
| `GET /apps?project=` | List apps                                                             |
| `POST /apps`         | Create an app: `{ project, name, kind?, framework? }`                 |
| `GET /apps/{app}`    | One app, with environments and the deploy each points to              |
| `PATCH /apps/{app}`  | Change settings from the config file's fields                         |
| `DELETE /apps/{app}` | Delete the app, its deploys and resources (asks for `?confirm=<app>`) |

## Deploys and releases

| Method and path                                | Does                                                                                                  |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `POST /apps/{app}/deploys`                     | Start a deploy: `{ env, source: { git: { ref } } \| { upload: uploadId } \| { prebuilt: uploadId } }` |
| `POST /uploads`                                | Get a signed URL to upload a source or prebuilt archive                                               |
| `GET /apps/{app}/deploys`                      | List deploys (`?env=`, `?status=`)                                                                    |
| `GET /deploys/{deploy}`                        | One deploy: status, build, address, use-case diff                                                     |
| `GET /deploys/{deploy}/build/logs`             | Build logs (`?follow=true` streams as server-sent events)                                             |
| `POST /apps/{app}/environments/{env}/release`  | `{ deploy, gradual?, reason? }`                                                                       |
| `POST /apps/{app}/environments/{env}/rollback` | `{ to? }`                                                                                             |
| `GET /apps/{app}/environments/{env}/releases`  | Release history                                                                                       |

Deploy statuses: `queued`, `building`, `deploying`, `ready`, `failed`, `timed_out`, `canceled`.

## Environment, domains and tokens

| Method and path                                                  | Does                                                     |
| ---------------------------------------------------------------- | -------------------------------------------------------- |
| `GET /apps/{app}/environments/{env}/vars`                        | Variables (secret values are never returned)             |
| `PUT /apps/{app}/environments/{env}/vars/{name}`                 | `{ value, secret?, build? }`                             |
| `DELETE /apps/{app}/environments/{env}/vars/{name}`              | Remove                                                   |
| `POST /apps/{app}/domains`                                       | `{ domain, env, redirect? }`, returns the records to add |
| `GET /apps/{app}/domains`, `DELETE /apps/{app}/domains/{domain}` | List, remove                                             |
| `POST /apps/{app}/tokens`, `GET`, `DELETE /tokens/{id}`          | Deploy tokens                                            |

## Jobs, queues and logs

| Method and path                                                                                      | Does                                              |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| `GET /apps/{app}/jobs`, `GET /apps/{app}/jobs/{job}/runs`                                            | Jobs and their runs                               |
| `POST /apps/{app}/jobs/{job}/trigger`                                                                | Run now                                           |
| `GET /apps/{app}/queues`, `GET /apps/{app}/queues/{q}/dlq`, `POST /apps/{app}/queues/{q}/dlq/replay` | Queues                                            |
| `GET /apps/{app}/logs`                                                                               | `?env=&deploy=&job=&since=&level=&where=&follow=` |

## Approvals

| Method and path        | Does                                |
| ---------------------- | ----------------------------------- |
| `GET /approvals`       | Pending actions started by agents   |
| `POST /approvals/{id}` | `{ decision: "approve" \| "deny" }` |

The OpenAPI document of this API is in the engine's repository, at `spec/openapi.yaml`.
