> ## Documentation Index
> Fetch the complete documentation index at: https://docs.exploratory.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Automation

Run expl server from scripts and CI without anyone signing in through a browser, with an API key.

## Create an API key

CI is a system that runs steps automatically when code changes. No one can sign in through a browser there, so you give it an API key. Create one as described on the [API keys](https://docs.exploratory.io/en/cli/server/token.md#create) page.

Store the key as a secret in your CI (a feature that keeps values hidden). Do not write it in a script, and do not print it to the screen or to logs. A key expires; create a new one and replace the secret before then.

For how to create a key and keep it safe, see [API keys](https://docs.exploratory.io/en/cli/server/token.md).

## Pass the key

Pass the key with the environment variable EXPL\_SERVER\_TOKEN. For the order against a saved login, see [Sign in](https://docs.exploratory.io/en/cli/server/login.md#apikey). To use another server, set EXPL\_SERVER\_URL.

## Example: GitHub Actions

An example for GitHub Actions. Replace \<id> with the id of the content to read. Replace \<version> with the version you use, and always pin it.

```text theme={null}
- uses: actions/setup-node@v4
  with:
    node-version: 22
- run: npx -y @exploratory/cli@<version> server fetch <id> --json
  env:
    EXPL_SERVER_TOKEN: ${{ secrets.EXPL_SERVER_TOKEN }}
    EXPL_SERVER_URL: https://exploratory.io
```

## Exit codes

A script can tell success from failure by the exit code. These two are common in CI.

| Code | Meaning | What to do |
| - | - | - |
| 3 | The server cannot be reached (network, an HTML error page and so on) | Check the network and run it again. |
| 4 | Not signed in, or the API key was rejected | Check that the key is correct, has not expired and has not been revoked. |

Every exit code is described in [Exit codes and errors](https://docs.exploratory.io/en/cli/server/exit-codes.md).

## Revoke the API key

Revoke a key that leaks or that you no longer need, as described in [API keys](https://docs.exploratory.io/en/cli/server/token.md#revoke).

A call with a revoked or expired key exits with code 4.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.