# Ask for a job

`POST /v1/jobs`

Only a customer's key may ask. The job holds the most it may cost from the customer's credits until it completes:
each reaction at its kind's rate (`GET /v1/prices`), or a synthesis's `max_credits`. To retry a call that may have
failed, such as one that timed out, send it again with the same `Idempotency-Key`: that gives back the job the first
call made rather than a second one.

## Headers

- `Authorization` (Bearer key, required): An API key. [Request access](/) to get one.
- `Idempotency-Key` (string or null): 1 to 255 visible ASCII characters that name this request.

## Body

[JobRequest](/docs/types/job-request.md), as `application/json`.

- `exclusive` (boolean, required): Whether only this customer may ever see the job's results. It cannot change later.
- `reuse` (boolean, required): Whether the lab may hand back results it already measured for the same reaction, at the reuse rate, instead of running it again. The match is exact: every field the two reactions state must agree, and an earlier synthesis must have been for at least the amount, with a measured purity of at least the purity asked for.
- `work` ([Work](/docs/types/work.md) (one of 4 kinds, by kind), required): Which of the four jobs this is, and what it needs. `kind` says which.
  - Variant `kind = "route_review"`: Chemists review a route to a target and say what they would change. It hands back their review and no rewards.
    - `kind` ("route_review", required)
    - `route` (array of [Reaction](/docs/types/reaction.md), at least 1, required): The route's reactions, in order.
      - `id` ([Name](/docs/types/name.md) (string, at most 200 chars, pattern), required): The customer's own name for the reaction, unique within the job. Its rewards carry it.
      - `materials` (array of [PlannedMaterial](/docs/types/planned-material.md), at least 1, required)
      - `product_smiles` ([Smiles](/docs/types/smiles.md) (string, pattern `^[!-~]+$`), required): A molecule as SMILES. The lab checks the chemistry; the API checks only that it is printable ASCII without spaces.
      - `procedure` ([Text](/docs/types/text.md) (string, pattern) or null): Text that says something, such as a procedure: not empty, not all spaces, and with no NUL character. It may hold line breaks.
      - `scale_mmol` ([Positive](/docs/types/positive.md) (number, above 0, at most 10¹²) or null): The amount of the limiting reactant. The lab chooses it when absent.
      - `temperature_c` ([Celsius](/docs/types/celsius.md) (number, -273.15 to 5000) or null): A temperature in degrees Celsius, from absolute zero to 5000.
      - `time_h` ([Positive](/docs/types/positive.md) (number, above 0, at most 10¹²) or null): An amount greater than zero, up to 10¹².
    - `target_smiles` ([Smiles](/docs/types/smiles.md) (string, pattern `^[!-~]+$`), required): A molecule as SMILES. The lab checks the chemistry; the API checks only that it is printable ASCII without spaces.
  - Variant `kind = "reaction_batch"`: The lab runs each reaction. Each hands back its yield.
    - `kind` ("reaction_batch", required)
    - `reactions` (array of [Reaction](/docs/types/reaction.md), at least 1, required): At least one reaction, with unique IDs, so that a reward can name one.
      - `id` ([Name](/docs/types/name.md) (string, at most 200 chars, pattern), required): The customer's own name for the reaction, unique within the job. Its rewards carry it.
      - `materials` (array of [PlannedMaterial](/docs/types/planned-material.md), at least 1, required)
      - `product_smiles` ([Smiles](/docs/types/smiles.md) (string, pattern `^[!-~]+$`), required): A molecule as SMILES. The lab checks the chemistry; the API checks only that it is printable ASCII without spaces.
      - `procedure` ([Text](/docs/types/text.md) (string, pattern) or null): Text that says something, such as a procedure: not empty, not all spaces, and with no NUL character. It may hold line breaks.
      - `scale_mmol` ([Positive](/docs/types/positive.md) (number, above 0, at most 10¹²) or null): The amount of the limiting reactant. The lab chooses it when absent.
      - `temperature_c` ([Celsius](/docs/types/celsius.md) (number, -273.15 to 5000) or null): A temperature in degrees Celsius, from absolute zero to 5000.
      - `time_h` ([Positive](/docs/types/positive.md) (number, above 0, at most 10¹²) or null): An amount greater than zero, up to 10¹².
  - Variant `kind = "reaction_screen"`: The lab runs each reaction as one well of a plate. Each hands back its conversion or yield.
    - `kind` ("reaction_screen", required)
    - `reactions` (array of [Reaction](/docs/types/reaction.md), at least 1, required): At least one reaction, with unique IDs, so that a reward can name one.
      - `id` ([Name](/docs/types/name.md) (string, at most 200 chars, pattern), required): The customer's own name for the reaction, unique within the job. Its rewards carry it.
      - `materials` (array of [PlannedMaterial](/docs/types/planned-material.md), at least 1, required)
      - `product_smiles` ([Smiles](/docs/types/smiles.md) (string, pattern `^[!-~]+$`), required): A molecule as SMILES. The lab checks the chemistry; the API checks only that it is printable ASCII without spaces.
      - `procedure` ([Text](/docs/types/text.md) (string, pattern) or null): Text that says something, such as a procedure: not empty, not all spaces, and with no NUL character. It may hold line breaks.
      - `scale_mmol` ([Positive](/docs/types/positive.md) (number, above 0, at most 10¹²) or null): The amount of the limiting reactant. The lab chooses it when absent.
      - `temperature_c` ([Celsius](/docs/types/celsius.md) (number, -273.15 to 5000) or null): A temperature in degrees Celsius, from absolute zero to 5000.
      - `time_h` ([Positive](/docs/types/positive.md) (number, above 0, at most 10¹²) or null): An amount greater than zero, up to 10¹².
  - Variant `kind = "synthesis"`: The lab makes an amount of a target at a purity. It hands back the final yield and purity.
    - `kind` ("synthesis", required)
    - `amount_mg` ([Positive](/docs/types/positive.md) (number, above 0, at most 10¹²), required): An amount greater than zero, up to 10¹².
    - `max_credits` ([Positive](/docs/types/positive.md) (number, above 0, at most 10¹²), required): The most credits the job may cost. The job holds them until it completes.
    - `purity_pct` ([Percent](/docs/types/percent.md) (number, 0 to 100), required): A percentage, from 0 to 100.
    - `target_smiles` ([Smiles](/docs/types/smiles.md) (string, pattern `^[!-~]+$`), required): A molecule as SMILES. The lab checks the chemistry; the API checks only that it is printable ASCII without spaces.
    - `route` (array of [Reaction](/docs/types/reaction.md), at least 1 or null): The route to follow, in order. Leave it out for the lab to choose one.
      - `id` ([Name](/docs/types/name.md) (string, at most 200 chars, pattern), required): The customer's own name for the reaction, unique within the job. Its rewards carry it.
      - `materials` (array of [PlannedMaterial](/docs/types/planned-material.md), at least 1, required)
      - `product_smiles` ([Smiles](/docs/types/smiles.md) (string, pattern `^[!-~]+$`), required): A molecule as SMILES. The lab checks the chemistry; the API checks only that it is printable ASCII without spaces.
      - `procedure` ([Text](/docs/types/text.md) (string, pattern) or null): Text that says something, such as a procedure: not empty, not all spaces, and with no NUL character. It may hold line breaks.
      - `scale_mmol` ([Positive](/docs/types/positive.md) (number, above 0, at most 10¹²) or null): The amount of the limiting reactant. The lab chooses it when absent.
      - `temperature_c` ([Celsius](/docs/types/celsius.md) (number, -273.15 to 5000) or null): A temperature in degrees Celsius, from absolute zero to 5000.
      - `time_h` ([Positive](/docs/types/positive.md) (number, above 0, at most 10¹²) or null): An amount greater than zero, up to 10¹².

## Responses

| Status | Meaning |
|---|---|
| 201 | The job, new or made by an earlier call with the same idempotency key. |
| 401 | Send a valid API key as `Authorization: Bearer <key>`. |
| 402 | The job may cost more than the balance, or than is left of the key's limit. |
| 403 | The key is not a customer's. |
| 409 | The idempotency key was used for a different request. |
| 413 | The body is larger than 1 MiB. |
| 415 | The body is not sent as `application/json`. |
| 422 | A parameter or the body does not parse. |
| 500 | Something went wrong on our side. |
| 503 | This kind of job has no price yet. |

201 returns [Job](/docs/types/job.md). Every error is a [Problem](/docs/types/problem.md), whose `detail` says what went wrong.

## Examples

### cURL

```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

```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

```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();
```

### Response (201 Created)

```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"
}
```
