# Quickstart

This guide walks through your first call to `https://api.sequencylabs.com`.

## Get an API key

Access is by request. Submit an inquiry on [sequencylabs.com](/) to get a customer key and credits.

Send your key on every call in the `Authorization` header as `Bearer <key>`. Set it in your shell before running the examples below.

## Check prices

Read current rates for each kind of job before asking for one. A kind without a rate cannot be asked for yet.

```bash
$ curl https://api.sequencylabs.com/v1/prices \
  -H "Authorization: Bearer $SEQUENCY_API_KEY"
```

```python
import os
import httpx

response = httpx.get(
    "https://api.sequencylabs.com/v1/prices",
    headers={"Authorization": f"Bearer {os.environ['SEQUENCY_API_KEY']}"},
)
response.raise_for_status()
data = response.json()
```

```javascript
const response = await fetch("https://api.sequencylabs.com/v1/prices", {
  headers: {
    Authorization: `Bearer ${process.env.SEQUENCY_API_KEY}`,
  },
});
const data = await response.json();
```

```json
{
  "rates": [
    {
      "exclusive": false,
      "kind": "route_review",
      "reaction": 10.0,
      "reused_reaction": 10.0
    }
  ]
}
```

## Ask for a job

Send a `JobRequest` to `POST /v1/jobs`. Pass an `Idempotency-Key` header so retrying a timed-out call returns the same job instead of making a second one.

```bash
$ curl https://api.sequencylabs.com/v1/jobs \
  -H "Authorization: Bearer $SEQUENCY_API_KEY" \
  -H "Idempotency-Key: 7d1c0e2a" \
  --json '{
    "exclusive": false,
    "reuse": false,
    "work": {
      "kind": "route_review",
      "route": [
        {
          "id": "step_1",
          "materials": [
            {
              "role": "reactant",
              "smiles": "CCO"
            }
          ],
          "product_smiles": "CCO"
        }
      ],
      "target_smiles": "CCO"
    }
  }'
```

```python
import os
import httpx

response = httpx.post(
    "https://api.sequencylabs.com/v1/jobs",
    headers={
        "Authorization": f"Bearer {os.environ['SEQUENCY_API_KEY']}",
        "Idempotency-Key": "7d1c0e2a",
    },
    json={
        "exclusive": False,
        "reuse": False,
        "work": {
            "kind": "route_review",
            "route": [
                {
                    "id": "step_1",
                    "materials": [
                        {
                            "role": "reactant",
                            "smiles": "CCO",
                        },
                    ],
                    "product_smiles": "CCO",
                },
            ],
            "target_smiles": "CCO",
        },
    },
)
response.raise_for_status()
data = response.json()
```

```javascript
const response = await fetch("https://api.sequencylabs.com/v1/jobs", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SEQUENCY_API_KEY}`,
    "Idempotency-Key": "7d1c0e2a",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "exclusive": false,
    "reuse": false,
    "work": {
      "kind": "route_review",
      "route": [
        {
          "id": "step_1",
          "materials": [
            {
              "role": "reactant",
              "smiles": "CCO"
            }
          ],
          "product_smiles": "CCO"
        }
      ],
      "target_smiles": "CCO"
    }
  }),
});
const data = await response.json();
```

```json
{
  "canceled_at": null,
  "completed_at": null,
  "created_at": "2026-12-01T09:15:00Z",
  "credits": null,
  "id": "job_01h455vb4pex5vsknk084sn02q",
  "package_version": null,
  "request": {
    "exclusive": false,
    "reuse": false,
    "work": {
      "kind": "route_review",
      "route": [
        {
          "id": "step_1",
          "materials": [
            {
              "equivalents": null,
              "name": null,
              "role": "reactant",
              "smiles": "CCO",
              "volume_ml": null
            }
          ],
          "procedure": null,
          "product_smiles": "CCO",
          "scale_mmol": null,
          "temperature_c": null,
          "time_h": null
        }
      ],
      "target_smiles": "CCO"
    }
  },
  "reused": [
    "step_1"
  ],
  "started_at": null,
  "status": "queued"
}
```

Save the `id` from the response. The API holds the most the job may cost from your balance until it completes.

## Follow the job

Poll `GET /v1/jobs/{id}` until `status` is `completed`. When `completed`, `package_version` holds the number of the newest package.

```bash
$ curl https://api.sequencylabs.com/v1/jobs/job_01h455vb4pex5vsknk084sn02q \
  -H "Authorization: Bearer $SEQUENCY_API_KEY"
```

```python
import os
import httpx

response = httpx.get(
    "https://api.sequencylabs.com/v1/jobs/job_01h455vb4pex5vsknk084sn02q",
    headers={"Authorization": f"Bearer {os.environ['SEQUENCY_API_KEY']}"},
)
response.raise_for_status()
data = response.json()
```

```javascript
const response = await fetch("https://api.sequencylabs.com/v1/jobs/job_01h455vb4pex5vsknk084sn02q", {
  headers: {
    Authorization: `Bearer ${process.env.SEQUENCY_API_KEY}`,
  },
});
const data = await response.json();
```

## Read the package

Fetch `GET /v1/jobs/{id}/package` for the job's files, measured rewards and, for a route review, the chemist's review.

```bash
$ curl https://api.sequencylabs.com/v1/jobs/job_01h455vb4pex5vsknk084sn02q/package \
  -H "Authorization: Bearer $SEQUENCY_API_KEY"
```

```python
import os
import httpx

response = httpx.get(
    "https://api.sequencylabs.com/v1/jobs/job_01h455vb4pex5vsknk084sn02q/package",
    headers={"Authorization": f"Bearer {os.environ['SEQUENCY_API_KEY']}"},
)
response.raise_for_status()
data = response.json()
```

```javascript
const response = await fetch("https://api.sequencylabs.com/v1/jobs/job_01h455vb4pex5vsknk084sn02q/package", {
  headers: {
    Authorization: `Bearer ${process.env.SEQUENCY_API_KEY}`,
  },
});
const data = await response.json();
```

```json
{
  "files": [
    {
      "media_type": "step_1",
      "path": "raw/nmr/1.zip",
      "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
      "size_bytes": 48210
    }
  ],
  "reason": null,
  "review": null,
  "rewards": [
    {
      "measure": "yield_pct",
      "measured": 10.0,
      "method": "Stirred 2 h at 25 C.",
      "reaction": null,
      "source": {
        "chemist": "step_1",
        "experiment_id": "step_1",
        "file": "raw/nmr/1.zip",
        "measured_at": "2026-12-01T09:15:00Z",
        "site": "step_1"
      }
    }
  ],
  "version": 1,
  "written_at": "2026-12-01T09:15:00Z"
}
```

Download any file listed in `files` with `GET /v1/jobs/{id}/package/files/{path}`. The response `ETag` is the file's SHA-256 hash.

```bash
$ curl https://api.sequencylabs.com/v1/jobs/job_01h455vb4pex5vsknk084sn02q/package/files/raw/nmr/1.zip \
  -H "Authorization: Bearer $SEQUENCY_API_KEY" \
  -o 1.zip
```

```python
import os
import httpx

response = httpx.get(
    "https://api.sequencylabs.com/v1/jobs/job_01h455vb4pex5vsknk084sn02q/package/files/raw/nmr/1.zip",
    headers={"Authorization": f"Bearer {os.environ['SEQUENCY_API_KEY']}"},
)
response.raise_for_status()
data = response.content
```

```javascript
const response = await fetch("https://api.sequencylabs.com/v1/jobs/job_01h455vb4pex5vsknk084sn02q/package/files/raw/nmr/1.zip", {
  headers: {
    Authorization: `Bearer ${process.env.SEQUENCY_API_KEY}`,
  },
});
const bytes = await response.arrayBuffer();
```
