# API reference

> The routes an access token can call, with the scope each one requires. Generated from openapi.json.

Base URL: `https://api.cloud.sysnee.com`. Send `Authorization: Bearer <token>` with a personal access token (`sysnee_pat_…`) or an OAuth access token (`sysnee_oat_…`). A token only reaches the routes of its scopes, and never more than the user's role allows. Routes not listed here refuse tokens. See [Tokens and scopes](https://docs.sysnee.com/en/tokens.md).

The full schemas (request bodies, parameters, patterns) are in [openapi.json](/openapi.json).

## Account and projects

| Method | Route | Scope | What it does |
|---|---|---|---|
| `GET` | `/v1/auth/me` | `account:read` | The signed-in user and their organization |
| `GET` | `/v1/projects` | `account:read` | List projects |
| `GET` | `/v1/projects/default` | `account:read` | The default project |
| `GET` | `/v1/projects/{id}` | `account:read` | Get a project |

## Sites

| Method | Route | Scope | What it does |
|---|---|---|---|
| `GET` | `/v1/resources/deploy` | `sites:read` | List sites |
| `POST` | `/v1/resources/deploy` | `sites:deploy` | Create a site |
| `GET` | `/v1/resources/deploy/name-availability` | `sites:read` | Check whether a site name is free |
| `GET` | `/v1/resources/deploy/{id}` | `sites:read` | Get a site |
| `PATCH` | `/v1/resources/deploy/{id}` | `sites:deploy` | Change a site (SPA mode, build settings, Git source) |
| `DELETE` | `/v1/resources/deploy/{id}` | `sites:delete` | Delete a site |
| `GET` | `/v1/resources/deploy/{id}/deployments` | `sites:read` | List deployments |
| `POST` | `/v1/resources/deploy/{id}/deployments` | `sites:deploy` | Deploy a zip archive (multipart, field "archive") |
| `POST` | `/v1/resources/deploy/{id}/redeploy` | `sites:deploy` | Build the Git source again |
| `GET` | `/v1/resources/deploy/{id}/deployments/{deploymentId}` | `sites:read` | Get a deployment |
| `GET` | `/v1/resources/deploy/{id}/deployments/{deploymentId}/logs` | `sites:read` | Build log of a deployment, from a byte offset |
| `POST` | `/v1/resources/deploy/{id}/deployments/{deploymentId}/activate` | `sites:deploy` | Serve an earlier deployment (rollback) |
| `GET` | `/v1/resources/deploy/{id}/domains` | `sites:read` | List custom domains |
| `POST` | `/v1/resources/deploy/{id}/domains` | `sites:deploy` | Add a custom domain |
| `PATCH` | `/v1/resources/deploy/{id}/domains/{domainId}` | `sites:deploy` | Change a custom domain (e.g. redirect target) |
| `DELETE` | `/v1/resources/deploy/{id}/domains/{domainId}` | `sites:delete` | Remove a custom domain |
| `POST` | `/v1/resources/deploy/{id}/domains/{domainId}/verify` | `sites:deploy` | Check the DNS records of a custom domain now |
| `GET` | `/v1/resources/deploy/{id}/analytics` | `sites:read` | Site analytics for a period |
| `POST` | `/v1/resources/deploy/{id}/deletion-request` | `sites:delete` | Request the deletion of a site; a person confirms it in the console |
| `POST` | `/v1/resources/deploy/{id}/domains/{domainId}/deletion-request` | `sites:delete` | Request the removal of a domain; a person confirms it in the console |

## PostgreSQL

| Method | Route | Scope | What it does |
|---|---|---|---|
| `GET` | `/v1/resources/postgres` | `databases:read` | List PostgreSQL databases |
| `POST` | `/v1/resources/postgres` | `databases:write` | Create a PostgreSQL database (account level 3) |
| `GET` | `/v1/resources/postgres/{id}` | `databases:read` | Get a PostgreSQL database |
| `POST` | `/v1/resources/postgres/{id}/stop` | `databases:write` | Stop a PostgreSQL database |
| `POST` | `/v1/resources/postgres/{id}/start` | `databases:write` | Start a stopped PostgreSQL database |
| `POST` | `/v1/resources/postgres/{id}/deletion-request` | `databases:delete` | Request the deletion of a database; a person confirms it in the console |

## Billing

| Method | Route | Scope | What it does |
|---|---|---|---|
| `GET` | `/v1/billing/usage/current` | `billing:read` | Usage so far in the current period |
| `GET` | `/v1/billing/usage/months` | `billing:read` | Months that have usage |
| `GET` | `/v1/billing/usage` | `billing:read` | Usage detail (JSON or CSV) |
| `GET` | `/v1/billing/invoices` | `billing:read` | List invoices |
| `GET` | `/v1/billing/invoices/{id}` | `billing:read` | Get an invoice |
