# HTTP API quickstart


Base URL: `https://relaybraid.com/api/v1`. Authenticate with `Authorization: Bearer <api key>`.

Get a key with the CLI:

```bash
npx -y https://relaybraid.com/dl/relaybraid-cli.tgz init --ref X641DPN0
```

## Sign in

```bash
npx -y https://relaybraid.com/dl/relaybraid-cli.tgz login
```

`login` prints a sign-in URL and a one-time code. Open the URL in a browser, check that the code matches and approve. The command finishes by itself once the sign-in is approved, usually within a minute, and saves the API key in `.relaybraid/credentials.json`.

## Run an action

```js
const response = await fetch("https://relaybraid.com/api/v1/actions/run", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RELAYBRAID_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ app: "slack", action: "send_message", input: { channel: "#orders", text: "New order received" } }),
});
const result = await response.json(); // { status: "success", run_id: "..." }
```

## Endpoints

| Method and path | Purpose |
|---|---|
| `GET /api/v1/me` | The workspace behind the key |
| `GET /api/v1/apps` | Connected apps and their actions |
| `POST /api/v1/actions/run` | Run one action |

Errors return JSON with `error.code` and `error.message`. A missing or invalid key returns 401.
