# Referência da API

> As rotas que um token de acesso pode chamar, com o escopo de cada uma. Gerada do openapi.json.

URL base: `https://api.cloud.sysnee.com`. Envie `Authorization: Bearer <token>` com um token pessoal (`sysnee_pat_…`) ou um token OAuth (`sysnee_oat_…`). Um token só chega às rotas dos escopos dele, e nunca a mais do que o papel do usuário permite. As rotas que não estão aqui recusam tokens. Veja [Tokens e escopos](https://docs.sysnee.com/tokens.md).

Os schemas completos (corpos, parâmetros e padrões) estão no [openapi.json](/openapi.json).

## Conta e projetos

| Método | Rota | Escopo | O que faz |
|---|---|---|---|
| `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

| Método | Rota | Escopo | O que faz |
|---|---|---|---|
| `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

| Método | Rota | Escopo | O que faz |
|---|---|---|---|
| `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 |

## Cobrança

| Método | Rota | Escopo | O que faz |
|---|---|---|---|
| `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 |
