*Guides › Guides*

# Sign in from CI and sandboxes

4 min · 6 steps · Languages: dcloud

Where no one can sign in through a browser, such as a CI pipeline, a deploy script or an AI agent's cloud sandbox, `dcloud` uses a **project developer key** instead: set it as `DCLOUD_TOKEN`, and every command works with that key's access.

## 1. Make a key

A project admin makes keys on the dashboard: open the project, then **Project settings > Developer > Keys**, and create one. Name it after where it will live (`github-actions`, `codex-sandbox`), so the activity log and the key's call log say who did what.

The secret is shown once, starting with `dsp_live_`. Copy it straight into the secret store of your CI or sandbox.

## 2. Choose its access

Pick the least access that does the job. A key's access can't be changed later: make a new key instead.

| Access | For | `dcloud` commands it can run |
|---|---|---|
| `read` | An agent or job that only looks | `status`, `logs`, `vars` (names), `domains`, `volumes`, `environments`, `config export` |
| `deploy` | Deploying from CI, an agent that deploys and fixes | the above, plus `deploy`, `redeploy`, `rollback`, `restart`, `stop`, `start` |
| `full` | Changing the environment | everything: `vars set`, `domain add`, `plan` and `apply`, `scale`, `volume`, `env create`, `ssh` |

`dcloud plan` needs `full`, because comparing the file with the environment reads secret values. A key never does more than its creator's current role in the project allows, and stops working if its creator leaves the workspace (see **Authentication**).

## 3. Limit it to an environment

When you create the key, choose an environment to limit it to one, such as `staging`. It then sees only that environment, and gets `404 not_found` for everything in the others (see **Environment keys**). Give agents and preview pipelines keys limited to non-production environments; keep production keys for the pipeline that deploys production.

## 4. Set DCLOUD_TOKEN

Set the key as the secret `DCLOUD_TOKEN`. With it set, `dcloud` uses the key and ignores any sign-in on the machine. A key belongs to one project, so name the project and environment: link the folder first, or pass `--project` and `--env` to each command (`.dcloud/` is never committed, so a fresh CI checkout isn't linked).

### Dispra Cloud CLI

```bash
# GitHub Actions
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: curl -fsSL https://dispralabs.com/downloads/dcloud-cli.sh | DCLOUD_VERSION=0.2.1 sh
      - run: dcloud link --project prj_01jdk3m9x2v7c4q8w5n6b1t0ra --env staging
      - run: dcloud deploy api --wait
    env:
      DCLOUD_TOKEN: ${{ secrets.DCLOUD_TOKEN }}
```

## 5. Check it

`dcloud status` lists the environment's services. A key that is wrong, revoked or regenerated is refused with `login_required` and exit code 2 (`DCLOUD_TOKEN was refused: ...`); a command above the key's access is refused with `key_access_denied`.

### Dispra Cloud CLI

```bash
DCLOUD_TOKEN=dsp_live_... dcloud status --json
```

## 6. Rotate and revoke

On **Project settings > Developer > Keys**:

- **Regenerate** gives the key a new secret and stops the old one at once. Update the secret in your CI or sandbox right after.
- **Revoke** stops the key for good. Revoke a key as soon as it may have leaked, or when the pipeline or sandbox it was made for is gone.

Each key has a call log of its recent requests, refused ones included, so you can see what a key did before you revoke it.

## Next steps

Next: [Use Dispra with AI agents](https://docs.dispralabs.com/guides/use-dispra-with-ai-agents.md), and **Authentication** for everything about keys.
