
# Connections

A connection is an outside API, a Google Sheet, an Airtable base or an RSS feed that a site reads from. Collections [sync from it or fetch it live](https://developers.unvop.com/guides/collections.md#where-entries-come-from), workflow HTTP steps call it, and tools query it. Its secrets are stored encrypted and never leave Unvop again.

Reading needs `connections:read`; the rest needs `connections:write`. Creating, changing, deleting and testing connections is for owners and admins.

## Create one

```json title="POST /sites/{siteId}/connections"
{
  "name": "Bookings API",
  "kind": "rest",
  "baseUrl": "https://api.example.com/v2",
  "headers": { "Accept": "application/json" },
  "secrets": { "Authorization": "Bearer sk_live_…" }
}
```

| Field | What it holds |
|---|---|
| `kind` | `rest`, `google-sheet`, `airtable` or `rss` |
| `baseUrl` | Where requests go. Paths are added to it. |
| `headers` | Plain headers sent with every request |
| `secrets` | Secret headers (or `apiKey`), encrypted at rest and write-only |

Answers never contain secret values. `secretsSet` names the ones that are set, and `secretsMissing` the ones a request needs but nobody has filled in yet.

## Secrets stay write-only

`PATCH …/connections/{connectionId}` changes a connection. Secrets you send replace those names; secrets you leave out are kept; an empty string removes one. So you can rename a connection or change its base URL without ever handling its key.

### A key slot

A plain header can hold `{secret}` where the key goes, like `Authorization: Key {secret}`. The secret of the same name then stores only the bare key, written into the slot when a request is sent. Until it is stored the header is never sent: requests answer `not_configured` without calling out, and workflows that use the connection say what to add before they can run.

## Test it

- `POST …/connections/{connectionId}/test` calls the base URL and reports what came back: `ok`, `status`, a `sample` of the answer and any `error`. The result is kept as its last test.
- `POST …/connections/{connectionId}/request` sends one request through it, with `path`, `method` and `body`, using its headers and secrets, and answers a sample. Private and local addresses are refused.

## Delete it

`DELETE …/connections/{connectionId}`. Collections that synced from it keep their entries and become manual.
