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

# Close a job execution

PATCH https://platform.labric.co/api/v1/job-executions/{execution_id}
Content-Type: application/json

Close a job execution as completed or failed.

Call this when an off-platform script finishes. Either status is final:
re-sending the same status is a no-op, and changing it is rejected. Only
executions opened by the start tool are accepted; the platform records
every other execution's status itself.

Requires an API key with the `write` scope.

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

## Authentication

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

## Request

### Path parameters

- `execution_id` (string, required)

### Body (application/json)

This endpoint expects an object.

- `status` (enum, required) — How the run ended. Either status is final: the execution cannot change status afterwards.
  - Allowed values: `completed`, `failed`

## Response

### 200

OK

- `job_execution_id` (string, required) — Pass this as job_execution_id to the write and upload-file tools.
- `job_id` (string, required) — ID of the job the execution belongs to.
- `job_name` (string, required) — Name of the job the execution belongs to.
- `status` (string, required, nullable) — The execution's current status.
- `started_at` (datetime, required, nullable) — When the execution started.
- `completed_at` (datetime, required, nullable) — When the execution ended, or null while it is still running.

## 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)

### 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
{
  "status": "completed"
}
```

**Response**

```json
{
  "job_execution_id": "string",
  "job_id": "string",
  "job_name": "string",
  "status": "string",
  "started_at": "2024-01-15T09:30:00Z",
  "completed_at": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
from labric import Labric

client = Labric(
    api_key="YOUR_TOKEN_HERE",
)

client.jobs.close(
    execution_id="execution_id",
    status="completed",
)

```