> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.labric.co/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.labric.co/_mcp/server.

# Create a job

POST https://platform.labric.co/api/v1/jobs
Content-Type: application/json

Create a job that runs a Python script on the platform.

The code becomes the job's script; declare its dependencies inline in a
PEP 723 `# /// script` block. The job then appears on the platform, where
it can be run and its executions reviewed. To change an existing job's
name, description, or code, use update_job instead.

Requires an API key with the `write` scope.

Reference: https://docs.labric.co/api-reference/labric-api/jobs/create

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects an object.

- `name` (string, required) — Name of the job. Unique within the organization.
- `code` (string, required) — Python source of the script the job runs. Declare dependencies inline in a PEP 723 `# /// script` block.
- `description` (string, optional, nullable) — What the job does.

## Response

### 200

OK

- `id` (string, required) — Pass this as job_id to the job execution tools.
- `name` (string, required)
- `archived` (boolean, required)
- `description` (string, optional, nullable)

## Errors

### 400 Bad Request Error

Bad Request

- `detail` (string, required)

### 401 Unauthorized Error

Unauthorized

- `detail` (string, required)

### 403 Forbidden Error

Forbidden

- `detail` (string, required)

### 404 Not Found Error

Not Found

- `detail` (string, required)

### 409 Conflict Error

Conflict

- `detail` (string, required)

### 422 Unprocessable Entity Error

Unprocessable Content

- `detail` (list of map from string to any, required)

### 500 Internal Server Error

Internal Server Error

- `detail` (string, required)

## Examples

**Request**

```json
{
  "name": "Tensile curve summary",
  "code": "# /// script\n# dependencies = [\"pandas\"]\n# ///\nimport os\nimport pandas as pd\nfrom labric import Labric\n\nclient = Labric()\ncurve = pd.read_csv(os.environ[\"LABRIC_FILE_PATH_0\"])\nsummary = {\n    \"specimen_id\": os.path.basename(os.environ[\"LABRIC_FILE_PATH_0\"]),\n    \"peak_load_n\": curve[\"load_n\"].max(),\n    \"elongation_at_break_pct\": curve[\"strain_pct\"].iloc[-1],\n}\nclient.tools.write(\n    target_type=\"table\",\n    target_name=\"tensile_summaries\",\n    data=[summary],\n    mode=\"create\",\n    job_execution_id=os.environ[\"LABRIC_JOB_EXECUTION_ID\"],\n)\n",
  "description": "Reduces each uploaded tensile test to its peak load and elongation at break."
}
```

**Response**

```json
{
  "id": "8f1c2d3e-4b5a-4c6d-9e7f-0a1b2c3d4e5f",
  "name": "Tensile curve summary",
  "archived": false,
  "description": "Reduces each uploaded tensile test to its peak load and elongation at break."
}
```

**SDK Code**

```python
from labric import Labric

client = Labric(
    api_key="YOUR_TOKEN_HERE",
)

client.jobs.create(
    name="Tensile curve summary",
    description="Reduces each uploaded tensile test to its peak load and elongation at break.",
    code="# /// script\n# dependencies = [\"pandas\"]\n# ///\nimport os\nimport pandas as pd\nfrom labric import Labric\n\nclient = Labric()\ncurve = pd.read_csv(os.environ[\"LABRIC_FILE_PATH_0\"])\nsummary = {\n    \"specimen_id\": os.path.basename(os.environ[\"LABRIC_FILE_PATH_0\"]),\n    \"peak_load_n\": curve[\"load_n\"].max(),\n    \"elongation_at_break_pct\": curve[\"strain_pct\"].iloc[-1],\n}\nclient.tools.write(\n    target_type=\"table\",\n    target_name=\"tensile_summaries\",\n    data=[summary],\n    mode=\"create\",\n    job_execution_id=os.environ[\"LABRIC_JOB_EXECUTION_ID\"],\n)\n",
)

```