# Deploy from CI with an API token

## Create a token

1. Open **Settings**, **API tokens**, and choose **Create a token**.
2. Name it after where it'll be used, such as `github-actions`.
3. Tick **deploy**, plus anything else the script needs.
4. Copy the token. Coresmith shows it once.

A token acts for one team, and can never do more than your own role allows.

## Start a deploy

Find the app's ID in the address of its page, then send:

```bash
curl -X POST https://app.coresmith.io/api/v1/applications/<app-id>/deploy \
  -H "Authorization: Bearer <token>" \
  -H "Accept: application/json"
```

On self-hosted Coresmith, use its own address in place of `app.coresmith.io`.

Coresmith answers `202` with the deploy's ID. If it can't start one, for example because another deploy is running, it answers `409` with a message that says why. [API](/docs/reference/api) lists every endpoint.

Keep the token in your CI's secrets, never in the repository.

## Revoke a token

Revoke a token from **Settings**, **API tokens** once nothing uses it any more. Revoking it takes effect straight away.
