# Lumen Platform API

> The API an application built on Lumen uses, with an app key: the worker API its remote steps' workers call.

Source: https://docs.go-lumen.ai/he/reference/api/platform

| מאפיין | ערך |
| --- | --- |
| **Server** | `https://api.go-lumen.ai` |
| **Authentication** | An app key issued to your application: `Authorization: Bearer lak_<id>_<secret>`. App keys (`lak_`) are separate from the workspace API keys (`lmn_`) of the Runtime API. |
| **OpenAPI file** | [platform-v1.json](https://docs.go-lumen.ai/openapi/platform-v1.json) |
| **Operations** | 5 |

## Overview

The API an application built on Lumen uses, authenticated by a key of its AppClient (`Authorization: Bearer lak_<id>_<secret>`).

Worker API (`/worker/v1`): an app's own workers pull the tasks of its remote steps (ClusterStep `executor.remote.app`) from the region the workspace lives in. A worker claims tasks, heartbeats them every lease/3, uploads any files through `artifacts:presign`, and completes or fails each attempt. An attempt it no longer holds (its lease ran out and the task was claimed again, or it finished) answers 409, and the worker must stop working on it. The task `idempotencyKey` is stable across attempts: key side effects on it.

Errors are a Status object (`code`, `reason`, `message`).

## Operations

| Method | Path | Operation |
| --- | --- | --- |
| POST | `/worker/v1/artifacts:presign` | [Sign an upload of one artifact of a held attempt](#presignartifact) |
| POST | `/worker/v1/claims` | [Claim tasks of the app's remote steps](#claimtasks) |
| POST | `/worker/v1/heartbeats` | [Extend the leases of held tasks](#heartbeattasks) |
| POST | `/worker/v1/tasks/{taskId}/attempts/{attempt}:complete` | [Complete a held attempt](#completetask) |
| POST | `/worker/v1/tasks/{taskId}/attempts/{attempt}:fail` | [Fail a held attempt](#failtask) |

Request and response bodies below are described by the schemas in [Schemas](#schemas); the example bodies are built from those schemas.

### Sign an upload of one artifact of a held attempt

POST `/worker/v1/artifacts:presign`

Returns a PUT to the region's store, among the run's files. Send exactly the returned headers: Content-Type and Content-Length are signed, so the store refuses any other body. The size and type are checked again when the attempt completes.

**Request body** application/json

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `attempt` (חובה) | integer |  |  |
| `contentType` (חובה) | string |  |  |
| `name` (חובה) | string |  | (pattern \`^\[A-Za-z0-9\_-\]\[A-Za-z0-9.\_-\]{0,127}$\`) |
| `size` (חובה) | integer |  | (minimum 1) |
| `taskId` (חובה) | string |  |  |

```json title="request body (built from the schema)"
{
  "attempt": 1,
  "contentType": "string",
  "name": "string",
  "size": 1,
  "taskId": "string"
}
```

**Responses**

| Status | Meaning |
| --- | --- |
| 200 | The signed upload. |
| 400 | The request is malformed or breaks a limit. (BadRequest) |
| 401 | No valid app key. (Unauthorized) |
| 403 | The key lacks the scope, the region, or a label it presented; or the task is not the app's. (Forbidden) |
| 409 | The attempt is not held by this worker any more; stop working on it. (NotHeld) |

**Response 200**

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `expiresAt` (חובה) | string |  |  |
| `headers` (חובה) | map of string |  |  |
| `method` (חובה) | string |  | (one of PUT) |
| `name` (חובה) | string |  |  |
| `url` (חובה) | string |  |  |

```json title="response 200 (built from the schema)"
{
  "expiresAt": "2026-01-02T15:04:05Z",
  "headers": {},
  "method": "PUT",
  "name": "string",
  "url": "string"
}
```

### Claim tasks of the app's remote steps

POST `/worker/v1/claims`

Takes up to `limit` tasks the worker may run, from the workspaces the app is installed in, each leased for `leaseSeconds`. With `waitSeconds` the call waits that long for a task when none is ready (a long poll). The labels a worker presents must be granted by the AppClient's `spec.workerLabels`; the app label is set for it.

**Request body** application/json

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `labels` | map of string |  | What the worker carries, each granted by the AppClient's spec.workerLabels. |
| `leaseSeconds` | integer | `60` | (minimum 30; maximum 600) |
| `limit` | integer | `1` | (minimum 1; maximum 50) |
| `waitSeconds` | integer | `0` | (minimum 0; maximum 25) |
| `worker` (חובה) | string |  | The worker's own name, a DNS label; the same for every call about its tasks. (pattern \`^\[a-z0-9\](\[-a-z0-9.\]{0,61}\[a-z0-9\])?$\`) |

```json title="request body (built from the schema)"
{
  "labels": {},
  "leaseSeconds": 60,
  "limit": 1,
  "waitSeconds": 0,
  "worker": "string"
}
```

**Responses**

| Status | Meaning |
| --- | --- |
| 200 | The tasks claimed; none when nothing was ready. |
| 400 | The request is malformed or breaks a limit. (BadRequest) |
| 401 | No valid app key. (Unauthorized) |
| 403 | The key lacks the scope, the region, or a label it presented; or the task is not the app's. (Forbidden) |
| 429 | The key holds as many open claims as it may; retry after Retry-After. (TooManyRequests) |

**Response 200**

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `tasks` (חובה) | list of object |  |  |
| `tasks[].attempt` (חובה) | integer |  | This claim's attempt; later calls name it. |
| `tasks[].config` | object |  | The node's settings. |
| `tasks[].id` (חובה) | string |  | Opaque; names the task in every later call. |
| `tasks[].idempotencyKey` (חובה) | string |  | Stable across attempts. |
| `tasks[].input` (חובה) | list of object |  |  |
| `tasks[].input[].fields` | map of object |  |  |
| `tasks[].input[].files` | list of object |  |  |
| `tasks[].input[].files[].contentType` (חובה) | string |  |  |
| `tasks[].input[].files[].name` (חובה) | string |  |  |
| `tasks[].input[].files[].size` (חובה) | integer |  |  |
| `tasks[].input[].files[].url` | string |  | A signed GET |
| `tasks[].input[].text` | string |  |  |
| `tasks[].leaseExpiresAt` (חובה) | string |  |  |
| `tasks[].maxAttempts` (חובה) | integer |  |  |
| `tasks[].nodeId` (חובה) | string |  |  |
| `tasks[].runId` (חובה) | string |  |  |
| `tasks[].step` (חובה) | string |  | The ClusterStep's name. |
| `tasks[].workspace` (חובה) | string |  |  |

```json title="response 200 (built from the schema)"
{
  "tasks": [
    {
      "attempt": 1,
      "config": {},
      "id": "string",
      "idempotencyKey": "string",
      "input": [
        {
          "fields": {},
          "files": [
            null
          ],
          "text": "string"
        }
      ],
      "leaseExpiresAt": "2026-01-02T15:04:05Z",
      "maxAttempts": 1,
      "nodeId": "string",
      "runId": "string",
      "step": "string",
      "workspace": "string"
    }
  ]
}
```

### Extend the leases of held tasks

POST `/worker/v1/heartbeats`

Extends the lease of every attempt the worker still holds and returns those. An attempt missing from the answer was lost: stop working on it.

**Request body** application/json

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `leaseSeconds` | integer | `60` | (minimum 30; maximum 600) |
| `refs` (חובה) | list of object |  | (maxItems 200) |
| `refs[].attempt` (חובה) | integer |  |  |
| `refs[].id` (חובה) | string |  |  |

```json title="request body (built from the schema)"
{
  "leaseSeconds": 60,
  "refs": [
    {
      "attempt": 1,
      "id": "string"
    }
  ]
}
```

**Responses**

| Status | Meaning |
| --- | --- |
| 200 | The attempts still held. |
| 400 | The request is malformed or breaks a limit. (BadRequest) |
| 401 | No valid app key. (Unauthorized) |
| 403 | The key lacks the scope, the region, or a label it presented; or the task is not the app's. (Forbidden) |

**Response 200**

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `refs` (חובה) | list of object |  |  |
| `refs[].attempt` (חובה) | integer |  |  |
| `refs[].id` (חובה) | string |  |  |

```json title="response 200 (built from the schema)"
{
  "refs": [
    {
      "attempt": 1,
      "id": "string"
    }
  ]
}
```

### Complete a held attempt

POST `/worker/v1/tasks/{taskId}/attempts/{attempt}:complete`

Finishes the attempt with its output, and the run goes on. The output's fields are set over the first input document's, its text replaces the text when given, and each artifact (uploaded first through `artifacts:presign`) is added as a file.

**Parameters**

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `taskId` (חובה) | path | string | The task id a claim returned (opaque). |
| `attempt` (חובה) | path | integer | <nil> |

**Request body** application/json

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `artifacts` | list of object |  |  |
| `artifacts[].name` (חובה) | string |  | The name presigned for this attempt. |
| `output` (חובה) | object |  |  |
| `output.fields` | map of object |  |  |
| `output.text` | string |  |  |
| `weightMilli` | integer |  | Work done, in milli-credits; the step's catalog weight is the least charged. |

```json title="request body (built from the schema)"
{
  "artifacts": [
    {
      "name": "string"
    }
  ],
  "output": {
    "fields": {},
    "text": "string"
  },
  "weightMilli": 1
}
```

**Responses**

| Status | Meaning |
| --- | --- |
| 204 | Completed. |
| 400 | The request is malformed or breaks a limit. (BadRequest) |
| 401 | No valid app key. (Unauthorized) |
| 403 | The key lacks the scope, the region, or a label it presented; or the task is not the app's. (Forbidden) |
| 409 | The attempt is not held by this worker any more; stop working on it. (NotHeld) |

### Fail a held attempt

POST `/worker/v1/tasks/{taskId}/attempts/{attempt}:fail`

A retryable failure queues the task again after `backoffSeconds` while it has attempts left; otherwise the task and its run fail.

**Parameters**

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `taskId` (חובה) | path | string | The task id a claim returned (opaque). |
| `attempt` (חובה) | path | integer | <nil> |

**Request body** application/json

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `backoffSeconds` | integer | `0` | (minimum 0; maximum 3600) |
| `error` (חובה) | string |  | (maxLength 2000) |
| `retryable` | boolean | `false` |  |

```json title="request body (built from the schema)"
{
  "backoffSeconds": 0,
  "error": "string",
  "retryable": false
}
```

**Responses**

| Status | Meaning |
| --- | --- |
| 204 | Failed. |
| 400 | The request is malformed or breaks a limit. (BadRequest) |
| 401 | No valid app key. (Unauthorized) |
| 403 | The key lacks the scope, the region, or a label it presented; or the task is not the app's. (Forbidden) |
| 409 | The attempt is not held by this worker any more; stop working on it. (NotHeld) |

## Schemas

### ArtifactRef

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `name` (חובה) | string |  | The name presigned for this attempt. |

```json title="example (built from the schema)"
{
  "name": "string"
}
```

### ClaimRequest

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `labels` | map of string |  | What the worker carries, each granted by the AppClient's spec.workerLabels. |
| `leaseSeconds` | integer | `60` | (minimum 30; maximum 600) |
| `limit` | integer | `1` | (minimum 1; maximum 50) |
| `waitSeconds` | integer | `0` | (minimum 0; maximum 25) |
| `worker` (חובה) | string |  | The worker's own name, a DNS label; the same for every call about its tasks. (pattern \`^\[a-z0-9\](\[-a-z0-9.\]{0,61}\[a-z0-9\])?$\`) |

```json title="example (built from the schema)"
{
  "labels": {},
  "leaseSeconds": 60,
  "limit": 1,
  "waitSeconds": 0,
  "worker": "string"
}
```

### ClaimResponse

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `tasks` (חובה) | list of object |  |  |
| `tasks[].attempt` (חובה) | integer |  | This claim's attempt; later calls name it. |
| `tasks[].config` | object |  | The node's settings. |
| `tasks[].id` (חובה) | string |  | Opaque; names the task in every later call. |
| `tasks[].idempotencyKey` (חובה) | string |  | Stable across attempts. |
| `tasks[].input` (חובה) | list of object |  |  |
| `tasks[].input[].fields` | map of object |  |  |
| `tasks[].input[].files` | list of object |  |  |
| `tasks[].input[].files[].contentType` (חובה) | string |  |  |
| `tasks[].input[].files[].name` (חובה) | string |  |  |
| `tasks[].input[].files[].size` (חובה) | integer |  |  |
| `tasks[].input[].files[].url` | string |  | A signed GET |
| `tasks[].input[].text` | string |  |  |
| `tasks[].leaseExpiresAt` (חובה) | string |  |  |
| `tasks[].maxAttempts` (חובה) | integer |  |  |
| `tasks[].nodeId` (חובה) | string |  |  |
| `tasks[].runId` (חובה) | string |  |  |
| `tasks[].step` (חובה) | string |  | The ClusterStep's name. |
| `tasks[].workspace` (חובה) | string |  |  |

```json title="example (built from the schema)"
{
  "tasks": [
    {
      "attempt": 1,
      "config": {},
      "id": "string",
      "idempotencyKey": "string",
      "input": [
        {
          "fields": {},
          "files": [
            null
          ],
          "text": "string"
        }
      ],
      "leaseExpiresAt": "2026-01-02T15:04:05Z",
      "maxAttempts": 1,
      "nodeId": "string",
      "runId": "string",
      "step": "string",
      "workspace": "string"
    }
  ]
}
```

### CompleteRequest

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `artifacts` | list of object |  |  |
| `artifacts[].name` (חובה) | string |  | The name presigned for this attempt. |
| `output` (חובה) | object |  |  |
| `output.fields` | map of object |  |  |
| `output.text` | string |  |  |
| `weightMilli` | integer |  | Work done, in milli-credits; the step's catalog weight is the least charged. |

```json title="example (built from the schema)"
{
  "artifacts": [
    {
      "name": "string"
    }
  ],
  "output": {
    "fields": {},
    "text": "string"
  },
  "weightMilli": 1
}
```

### Document

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `fields` | map of object |  |  |
| `files` | list of object |  |  |
| `files[].contentType` (חובה) | string |  |  |
| `files[].name` (חובה) | string |  |  |
| `files[].size` (חובה) | integer |  |  |
| `files[].url` | string |  | A signed GET |
| `text` | string |  |  |

```json title="example (built from the schema)"
{
  "fields": {},
  "files": [
    {
      "contentType": "string",
      "name": "string",
      "size": 1,
      "url": "string"
    }
  ],
  "text": "string"
}
```

### FailRequest

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `backoffSeconds` | integer | `0` | (minimum 0; maximum 3600) |
| `error` (חובה) | string |  | (maxLength 2000) |
| `retryable` | boolean | `false` |  |

```json title="example (built from the schema)"
{
  "backoffSeconds": 0,
  "error": "string",
  "retryable": false
}
```

### Field

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `raw` | string |  | What the document said; defaults to the value as text. |
| `type` (חובה) | string |  | (one of string, number, boolean, date, money, object, array) |
| `value` | any |  | The value; a money value is {amount, currency}, a date YYYY-MM-DD. |

```json title="example (built from the schema)"
{
  "raw": "string",
  "type": "string",
  "value": "string"
}
```

### HeartbeatRequest

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `leaseSeconds` | integer | `60` | (minimum 30; maximum 600) |
| `refs` (חובה) | list of object |  | (maxItems 200) |
| `refs[].attempt` (חובה) | integer |  |  |
| `refs[].id` (חובה) | string |  |  |

```json title="example (built from the schema)"
{
  "leaseSeconds": 60,
  "refs": [
    {
      "attempt": 1,
      "id": "string"
    }
  ]
}
```

### HeartbeatResponse

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `refs` (חובה) | list of object |  |  |
| `refs[].attempt` (חובה) | integer |  |  |
| `refs[].id` (חובה) | string |  |  |

```json title="example (built from the schema)"
{
  "refs": [
    {
      "attempt": 1,
      "id": "string"
    }
  ]
}
```

### InputFile

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `contentType` (חובה) | string |  |  |
| `name` (חובה) | string |  |  |
| `size` (חובה) | integer |  |  |
| `url` | string |  | A signed GET |

```json title="example (built from the schema)"
{
  "contentType": "string",
  "name": "string",
  "size": 1,
  "url": "string"
}
```

### Output

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `fields` | map of object |  |  |
| `text` | string |  |  |

```json title="example (built from the schema)"
{
  "fields": {},
  "text": "string"
}
```

### PresignRequest

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `attempt` (חובה) | integer |  |  |
| `contentType` (חובה) | string |  |  |
| `name` (חובה) | string |  | (pattern \`^\[A-Za-z0-9\_-\]\[A-Za-z0-9.\_-\]{0,127}$\`) |
| `size` (חובה) | integer |  | (minimum 1) |
| `taskId` (חובה) | string |  |  |

```json title="example (built from the schema)"
{
  "attempt": 1,
  "contentType": "string",
  "name": "string",
  "size": 1,
  "taskId": "string"
}
```

### PresignResponse

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `expiresAt` (חובה) | string |  |  |
| `headers` (חובה) | map of string |  |  |
| `method` (חובה) | string |  | (one of PUT) |
| `name` (חובה) | string |  |  |
| `url` (חובה) | string |  |  |

```json title="example (built from the schema)"
{
  "expiresAt": "2026-01-02T15:04:05Z",
  "headers": {},
  "method": "PUT",
  "name": "string",
  "url": "string"
}
```

### Status

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `code` | integer |  |  |
| `message` | string |  |  |
| `reason` | string |  |  |

```json title="example (built from the schema)"
{
  "code": 1,
  "message": "string",
  "reason": "string"
}
```

### Task

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `attempt` (חובה) | integer |  | This claim's attempt; later calls name it. |
| `config` | object |  | The node's settings. |
| `id` (חובה) | string |  | Opaque; names the task in every later call. |
| `idempotencyKey` (חובה) | string |  | Stable across attempts. |
| `input` (חובה) | list of object |  |  |
| `input[].fields` | map of object |  |  |
| `input[].files` | list of object |  |  |
| `input[].files[].contentType` (חובה) | string |  |  |
| `input[].files[].name` (חובה) | string |  |  |
| `input[].files[].size` (חובה) | integer |  |  |
| `input[].files[].url` | string |  | A signed GET |
| `input[].text` | string |  |  |
| `leaseExpiresAt` (חובה) | string |  |  |
| `maxAttempts` (חובה) | integer |  |  |
| `nodeId` (חובה) | string |  |  |
| `runId` (חובה) | string |  |  |
| `step` (חובה) | string |  | The ClusterStep's name. |
| `workspace` (חובה) | string |  |  |

```json title="example (built from the schema)"
{
  "attempt": 1,
  "config": {},
  "id": "string",
  "idempotencyKey": "string",
  "input": [
    {
      "fields": {},
      "files": [
        {
          "contentType": "string",
          "name": "string",
          "size": 1,
          "url": "string"
        }
      ],
      "text": "string"
    }
  ],
  "leaseExpiresAt": "2026-01-02T15:04:05Z",
  "maxAttempts": 1,
  "nodeId": "string",
  "runId": "string",
  "step": "string",
  "workspace": "string"
}
```

### TaskRef

| Field | סוג | ברירת מחדל | תיאור |
| --- | --- | --- | --- |
| `attempt` (חובה) | integer |  |  |
| `id` (חובה) | string |  |  |

```json title="example (built from the schema)"
{
  "attempt": 1,
  "id": "string"
}
```
