---
title: "Specly API"
description: "Start a deploy from CI, or read a site's analytics, with an organization API key."
---

The Specly API has two calls. You can start a deploy of a site, and read its analytics. Both use an organization API
key, so CI and scripts can call them without a person's login.

The server is `https://app.specly.xyz`.

## Make a key

Open **Settings › Organization › API keys** in the [dashboard](https://app.specly.xyz). Only an admin of the
organization can make or see keys.

1. Give the key a name, such as the pipeline that uses it.
2. Choose what it may do. Each choice is a scope.
3. Choose where it works: every site in the organization, or only the sites you pick.
4. Select **Create key**, and copy the key. Specly shows it once.

A key belongs to the organization, not to a person, so it keeps working when people leave. Revoke it on the same page.

- `deploy` (scope): Start a deploy: `POST /api/sites/{id}/deploy`.

- `analytics:read` (scope): Read analytics: `GET /api/sites/{id}/analytics`.

## Call the API

Send the key as a bearer token. Every key starts with `spk_org_`. `{id}` is the site's ID, which is in its address in the
dashboard.

```bash Deploy
curl -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  https://app.specly.xyz/api/sites/{id}/deploy
```

```bash Analytics
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://app.specly.xyz/api/sites/{id}/analytics?days=30"
```

Answers are JSON. A deploy answers `202` with the build it started.

## Errors

- `401` (status): The key is missing, malformed, unknown or revoked. The answer has a `WWW-Authenticate: Bearer` header.

- `403` (status): The key can't be used on this site, or doesn't have the scope the call needs.

- `429` (status): Too many requests. Wait a minute. A key may start 10 deploys and make 60 analytics calls a minute.

Each error has an `error` field that says what went wrong. The pages in this tab show every call's fields and answers.
There's no Send button, because the API doesn't accept calls from a browser page. Use curl.
