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

# REST API overview

> Reference for Strand AI REST endpoints, bearer authentication, prediction lifecycle, and errors.

The Strand AI REST API exposes the platform's job infrastructure. The Python
and R SDKs use the same API, which can also be called directly from other
languages.

The OpenAPI spec is hosted at
[`https://app.strandai.com/api/v1/openapi.json`](https://app.strandai.com/api/v1/openapi.json).
A Markdown variant for LLM agents is available at
[`https://app.strandai.com/docs/api.md`](https://app.strandai.com/docs/api.md).
The LLM index is available at
[`https://app.strandai.com/llms.txt`](https://app.strandai.com/llms.txt).

## Base URL

```text theme={"dark"}
https://app.strandai.com/api/v1
```

## Authentication

Every endpoint requires a bearer credential: either an organization API key or
a Strand OAuth access token.

```http theme={"dark"}
Authorization: Bearer sk-strand-XXXXXXXXXXXXXXXXXXXXXXXX
```

Generate API keys at
[/settings/api-keys](https://app.strandai.com/settings/api-keys). They are
org-scoped and suit headless direct REST clients. OAuth access tokens suit
clients acting with a user's delegated organization access, including the hosted
MCP connector.

**Slides must be de-identified before upload.** See [Security and data
handling](https://docs.strandai.com/security-data-handling.md).

## Lifecycle

A prediction starts with an event-driven upload, followed by pricing,
submission, and result retrieval:

**1. Upload the slide**

`POST /uploads` with the slide's filename, size, content type, and optional
`mpp`. The response contains a **resumable upload URL** (signed GCS). `PUT`
the declared slide bytes there directly. GCS automatically starts ingest
preprocessing when the object finalizes; there is no client finalize
request. Automated de-identification is off by default and runs during
ingest only when enabled for your organization. Poll `GET /uploads/{id}`
while status is `uploading`.

**2. Price or submit**

`POST /predict` with `dryRun: true` validates the request and returns the
exact credit cost without side effects. Send the same request with
`dryRun: false` or omit the field to reserve credits atomically and enqueue
inference, returning a `jobId`.

**3. Poll or stream the job**

`GET /jobs/{id}` for snapshots, or `GET /jobs/{id}/stream` for an
SSE stream. When `status` reaches `completed`, download the OME-Zarr
results as OME-Zarr via `GET /jobs/{id}/results/files/{path}` or
`GET /jobs/{id}/results` (signed GCS URL). Use the single format-driven
`POST /jobs/{id}/exports` operation for native OME-Zarr, OME-Zarr ZIP, or
OME-TIFF plus optional H\&E and segmentation/cell artifacts; poll the same
path with `GET` while a generated export is pending.

Completion settles and debits delivered work, then releases any unused
reservation. Call `POST /jobs/{id}/cancel` to release the reservation for an
eligible in-flight job.

## Error model

Errors are returned as JSON in a consistent shape:

```json theme={"dark"}
{
  "error": "insufficient_credits",
  "message": "Org has 120 credits; this job requires 450.",
  "required": 450
}
```

| HTTP | Meaning |
| - | - |
| 400 | Bad request: invalid body, unknown marker, etc. |
| 401 | Missing or invalid bearer credential. |
| 402 | Insufficient credits. `required` carries the credit cost. |
| 404 | Resource not found, or scoped to a different org. |
| 409 | Resource not ready. Upload ingest or job processing may still be running. |

## SDKs

The platform provides first-party SDKs for this API:

> [card] [Python](https://docs.strandai.com/sdks/python.md)
>
> `pip install strand-sdk`

> [card] [R](https://docs.strandai.com/sdks/r.md)
>
> `install.packages("strandai", ...)`


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