# Sai HTTP API

Today we’re launching the **Sai HTTP API** — a way to send tasks to your Sai agent over HTTPS, straight from your own code. If you’ve ever wanted Sai to run inside a CI pipeline, on a device, or as part of your own app, this is for you.

It’s the same REST surface that powers our `sapi` CLI, now documented and available to build on directly.

Here’s a task from start to finish — one request in, a live stream out:

```bash
curl -N -X POST https://api.sai.simular.ai/v1/agents/message \
  -H "Authorization: Bearer sapi_..." \
  -H "Content-Type: application/json" \
  -d '{"machineId":"m_1a2b","message":"list my unread emails from today"}'
```

```text
data: {"type":"start"}
data: {"type":"reasoning-delta","id":"r1","delta":"Opening Gmail..."}
data: {"type":"text-delta","id":"t1","delta":"You have 3 unread emails: ..."}
data: {"type":"finish","finishReason":"stop"}
data: [DONE]
```

## What you can do

- **Send tasks to your agent** — Fire off a message like “list my unread emails from today” and stream the agent’s response back in real time.
- **Manage sessions and machines** — List your machines, list past conversations, start a fresh one, and pull recent context.
- **Attach files** — Upload files to include with a message.
- **Stay in control** — Approvals, aborts, and restarts are all available over the API, so the agent asks before doing anything sensitive — even when you call it programmatically.

## Built for real workflows

- **Live streaming responses** — The send-message endpoint returns a Server-Sent Events stream, so you get the agent’s narration, tool activity, and final answer as they happen.
- **Simple, secure auth** — Authenticate with a long-lived API key (great for servers, CI, and devices) or an interactive sign-in. Generate keys with `sapi key generate` or from **Settings → API Keys** in the desktop app.
- **One base URL** — Everything lives under `https://api.sai.simular.ai`, with agent endpoints under `/v1/agents` and account endpoints under `/v1/account`. Requests and responses are JSON.

```bash
curl https://api.sai.simular.ai/v1/agents/auth \
  -H "Authorization: Bearer sapi_your_api_key_here"
```

## Prefer the command line?

The same capabilities are available through the `sapi` CLI — perfect for quick scripts and terminal-driven workflows.

## Get started

Read the full reference, including authentication, endpoints, streaming events, and rate limits, here:

[Sai API Documentation](/content/api/index.html)

We can’t wait to see what you build with Sai.

_Email us at [support@simular.ai](mailto:support@simular.ai).
