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

# Claim the next ready task

POST https://api.athenaintel.com/api/v0/tasks/claim-next
Content-Type: application/json

Take the next ready task of a queue as the caller's to work on now: the first open task of the workspace the caller can change that nobody is working on, that is not held for a person and that waits on no open task. The caller's own tasks come first, then tasks assigned to nobody, each soonest due first by day; a task assigned to someone else is never taken. Narrow the queue with labels (a task must carry all of them) and a folder or project. It answers the task it claimed, or nothing_ready with how the queue stands in numbers: no task that was passed over is named. A blank label or folder id is refused, never ignored. Open to a person's own key or token; a credential acting as an agent or an automation is refused.

Reference: https://docs.athenaintel.com/api-reference/tasks/claim-next

## Authentication

- `X-API-KEY` header (required) — API Key authentication via header

## Request

### Body (application/json)

This endpoint expects a ClaimNextTaskRequestIn.

- `workspace_id` (string, required) — The workspace whose tasks to take from; the caller is a member.
- `folder_id` (string, optional, nullable) — Only tasks placed directly in this folder, or linked by this project: one the caller can open. Left out or null: every task of the workspace the caller can open. A blank id is refused (400), never ignored.
- `labels` (list of string, optional, nullable) — Only tasks that carry every one of these label names, each matched whatever its case (at most 20: a task carries no more). Left out, null or an empty list: whatever their labels. A blank name is refused (400), never ignored.
- `lease_minutes` (integer, optional, nullable) — How long the claim holds, in minutes (30 when left out).
- `worker` (string, optional, nullable) — Your own name for the worker that is calling (1 to 64 letters, digits, -, _ or .), for when several workers share one API key. A claim made with a name is that worker's: another worker of the same caller is refused the task while the claim is live, and only the same name renews it or gives it back. Left out, the call is the caller's own, as from the app. The name is yours to choose and grants nothing.

## Response

### 200

The task claimed, or nothing_ready with counts.

- `queue` (TaskQueueCountsOut, required, nullable) — With nothing_ready: the same in numbers. No task is named.
- `reason` (string, required, nullable) — With nothing_ready: how the queue stands, in one line.
- `result` (enum, required) — claimed or nothing_ready.
  - Allowed values: `claimed`, `nothing_ready`
- `task` (TaskOut, required, nullable) — The task now claimed by the caller; null when nothing is ready.

## Errors

### 400 Bad Request Error

A label or the folder id is blank: leave it out to take from the whole queue. Nothing was claimed.

- `any`

### 401 Unauthorized Error

The API key or token is missing or not valid.

- `any`

### 403 Forbidden Error

The caller is not a member of the workspace named, or is a credential acting as an agent or an automation.

- `any`

### 404 Not Found Error

No folder or project the caller can open has the folder_id given.

- `any`

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### TaskQueueCountsOut

How a queue's open tasks stand, in numbers: each task is counted once. Only tasks the caller can open are counted, and none is named.

- `assigned_to_someone_else` (integer, required) — How many are assigned to someone other than the caller.
- `claimed` (integer, required) — Of those, how many someone is working on.
- `held` (integer, required) — How many are held for a person.
- `more_may_match` (boolean, required) — Whether the queue holds more open tasks than one call reads (200): a ready one may be among them, so narrow the queue.
- `open_tasks` (integer, required) — The open tasks of the queue the caller can open.
- `waiting_on_another_task` (integer, required) — How many wait on a task that is still open.

### TaskOut

An assignable to-do: due on a calendar day, at a time in due_time_zone.

- `assignee` (TaskAssigneeOut, required, nullable) — Who it is for, or null for nobody.
- `blocked_by` (list of string, required) — The ids of the tasks that must be done before this one: those the caller can open.
- `can_edit` (boolean, required, nullable) — Whether the caller may change it; null in a list.
- `claim` (TaskClaimOut, required, nullable) — Who is working on it now; null when nobody is, and once the lease ran out.
- `completed_at` (datetime, required, nullable) — When it was marked done.
- `completed_by_ref` (string, required, nullable) — Who marked it done.
- `completion_note` (string, required, nullable) — What the work produced, left when it was marked done.
- `completion_reason` (enum, required, nullable) — Why it is done (completed or not_planned); null while open.
  - Allowed values: `completed`, `not_planned`
- `created_at` (datetime, required, nullable)
- `created_by` (string, required, nullable) — The user who created it.
- `description` (string, required, nullable) — Markdown.
- `due_date` (string, required, nullable) — YYYY-MM-DD, or null.
- `due_time` (string, required, nullable) — HH:MM (24-hour), or null.
- `due_time_zone` (string, required, nullable) — The IANA time zone of due_time.
- `external_refs` (list of TaskExternalRefOut, required) — The items kept elsewhere it is linked to (a pull request, an issue, a thread), each with what its system last said.
- `hidden_blockers` (integer, required) — How many more tasks it waits on that the caller can't open.
- `hold` (TaskHoldOut, required, nullable) — Why it waits on a person; null when it doesn't. A held task is not ready and can't be claimed until the hold is lifted.
- `id` (string, required) — The task's asset id.
- `is_archived` (boolean, required) — Whether it is in the trash.
- `is_blocked` (boolean, required) — Whether a task it waits on is still open, counting the ones the caller can't open.
- `is_ready` (boolean, required) — Whether it can be worked on now: open, not in the trash, nobody working on it, not held for a person and waiting on no open task. It says nothing of who may take it: a task assigned to someone is theirs alone to claim.
- `labels` (list of TaskLabelOut, required)
- `links` (list of TaskLinkOut, required) — The records it is about, read as the caller. Always empty in a list.
- `number` (integer, required, nullable) — Its number in its workspace (1, 2, 3, …), shown as T-\<n>; null for a task written before tasks were numbered.
- `parent` (TaskParentOut, required, nullable) — The task it is a sub-task of, read through that task's own gate; null when it is no sub-task.
- `priority` (enum, required)
  - Allowed values: `none`, `low`, `medium`, `high`, `urgent`
- `status` (enum, required)
  - Allowed values: `open`, `done`
- `subtask_progress` (TaskSubtaskProgressOut, required) — How many of its sub-tasks the caller can open are done, of how many.
- `title` (string, required)
- `updated_at` (datetime, required, nullable)
- `workspace_id` (string, required)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `ctx` (ValidationErrorCtx, optional)
- `input` (any, optional)

### TaskAssigneeOut

Who a task is assigned to: a person or an agent.

- `display_name` (string, required, nullable) — Their name, when the caller may see it (an agent's only when they can open it).
- `kind` (enum, required) — person or agent.
  - Allowed values: `person`, `agent`
- `ref` (string, required) — user_… for a person, agent_asset_… for an agent.

### TaskClaimOut

Who is working on a task now, and until when. A claim is live only while the task is open and its lease has not run out; after that the task reads as nobody's, at once.

- `claimed_by` (TaskAssigneeOut, required) — Who holds it: a person, or an agent acting as itself.
- `expires_at` (datetime, required) — When the lease runs out unless its holder renews it.
- `is_yours` (boolean, required) — Whether the claim is the caller's own to renew or give back: held by the caller and, when the request names a worker, made by that worker (or with no worker named). The worker that made a claim is never shown.

### TaskExternalRefOut

An item kept elsewhere that a task is linked to. A pull request, an issue, a thread. What its system last said of it is null until that system has spoken.

- `checks_failed` (integer, required, nullable) — How many of its checks failed.
- `checks_passed` (integer, required, nullable) — How many of its checks passed.
- `id` (string, required) — The link's own id.
- `label` (string, required) — A short name for the item, such as acme/app#12.
- `lifecycle` (string, required, nullable) — Where the item stands there: open, draft, merged or closed.
- `provider` (string, required) — The system that keeps the item, such as github.
- `relation` (string, required) — tracks, mirrors or conversation.
- `review_verdict` (string, required, nullable) — Its reviewers' overall verdict, when it has reviews.
- `updated_at` (datetime, required, nullable) — When the link or what its system said of it last changed.
- `url` (string, required) — The item's address.

### TaskHoldOut

Why a task waits on a person: it is open, not ready, and nobody can claim it.

- `held_at` (datetime, required) — When it was held.
- `held_by` (TaskAssigneeOut, required, nullable) — Who held it (a person or an agent).
- `kind` (string, required) — What sort of wait it is, in one short word: needs_input, awaiting_approval, failed (a worker gave it up), or the holder's own.
- `reason` (string, required) — What the task waits for, in one line.

### TaskLabelOut

A label on a task: its name, color and who applied it.

- `applied_at` (string, required) — When it was applied (ISO 8601).
- `applied_by_ref` (string, required) — Principal ref of who applied it.
- `color` (string, required, nullable) — #RRGGBB, or null.
- `name` (string, required)

### TaskLinkOut

A record a task is about, read as the caller.

- `detail` (string, required, nullable) — Its asset or object type, read as the caller.
- `id` (string, required, nullable) — The asset or object id; null when unreadable.
- `readable` (boolean, required) — Whether the caller can open it. One they can't shows its kind only: no id, URL or title.
- `referenced` (string, required) — asset, ontology_object or external_url.
- `title` (string, required, nullable) — Its title, read as the caller.
- `url` (string, required, nullable) — The web page's URL; null when unreadable.

### TaskParentOut

The task a sub-task belongs to, read through its own gate.

- `id` (string, required, nullable) — Its asset id; null when the caller can't open it.
- `number` (integer, required, nullable) — Its number (T-\<n>); null when the caller can't open it.
- `readable` (boolean, required) — Whether the caller can open it.
- `status` (enum, required, nullable) — open or done; null when the caller can't open it.
  - Allowed values: `open`, `done`
- `title` (string, required, nullable) — Its title; null when the caller can't open it.

### TaskSubtaskProgressOut

How far along a task's sub-tasks are, among those the caller can open.

- `done` (integer, required) — How many of them are done.
- `total` (integer, required) — How many there are.

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "workspace_id": "ws_abc123-def456",
  "labels": [
    "needs-review"
  ],
  "worker": "build-agent-2"
}
```

**Response**

```json
{
  "queue": {
    "assigned_to_someone_else": 1,
    "claimed": 1,
    "held": 1,
    "more_may_match": true,
    "open_tasks": 1,
    "waiting_on_another_task": 1
  },
  "reason": "string",
  "result": "claimed",
  "task": {
    "assignee": {
      "display_name": "Ada Lovelace",
      "kind": "person",
      "ref": "user_123"
    },
    "blocked_by": [],
    "can_edit": true,
    "claim": {
      "claimed_by": {
        "display_name": "Ada Lovelace",
        "kind": "person",
        "ref": "user_123"
      },
      "expires_at": "2026-11-11T15:30:00+00:00",
      "is_yours": true
    },
    "completed_at": "2024-01-15T09:30:00Z",
    "completed_by_ref": "string",
    "completion_note": "string",
    "completion_reason": "completed",
    "created_at": "2026-11-11T15:00:00+00:00",
    "created_by": "user_123",
    "description": "string",
    "due_date": "2026-11-13",
    "due_time": "15:00",
    "due_time_zone": "America/New_York",
    "external_refs": [],
    "hidden_blockers": 0,
    "hold": {
      "held_at": "2024-01-15T09:30:00Z",
      "held_by": {
        "display_name": "string",
        "kind": "person",
        "ref": "string"
      },
      "kind": "string",
      "reason": "string"
    },
    "id": "asset_7c1e5b2a-4f3d-4e8a-9b6c-1d2e3f4a5b6c",
    "is_archived": false,
    "is_blocked": false,
    "is_ready": false,
    "labels": [
      {
        "applied_at": "2026-11-11T15:00:00+00:00",
        "applied_by_ref": "user_123",
        "color": "string",
        "name": "Investor"
      }
    ],
    "links": [
      {
        "detail": "string",
        "id": "string",
        "readable": true,
        "referenced": "external_url",
        "title": "example.com",
        "url": "https://example.com"
      }
    ],
    "number": 12,
    "parent": {
      "id": "string",
      "number": 1,
      "readable": true,
      "status": "open",
      "title": "string"
    },
    "priority": "high",
    "status": "open",
    "subtask_progress": {
      "done": 1,
      "total": 3
    },
    "title": "Send the deck to Mayfield",
    "updated_at": "2026-11-11T15:00:00+00:00",
    "workspace_id": "ws_abc123-def456"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.athenaintel.com/api/v0/tasks/claim-next"

payload = {
    "workspace_id": "ws_abc123-def456",
    "labels": ["needs-review"],
    "worker": "build-agent-2"
}
headers = {
    "X-API-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.athenaintel.com/api/v0/tasks/claim-next';
const options = {
  method: 'POST',
  headers: {'X-API-KEY': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"workspace_id":"ws_abc123-def456","labels":["needs-review"],"worker":"build-agent-2"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.athenaintel.com/api/v0/tasks/claim-next"

	payload := strings.NewReader("{\n  \"workspace_id\": \"ws_abc123-def456\",\n  \"labels\": [\n    \"needs-review\"\n  ],\n  \"worker\": \"build-agent-2\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-API-KEY", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.athenaintel.com/api/v0/tasks/claim-next")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"workspace_id\": \"ws_abc123-def456\",\n  \"labels\": [\n    \"needs-review\"\n  ],\n  \"worker\": \"build-agent-2\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.athenaintel.com/api/v0/tasks/claim-next")
  .header("X-API-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"workspace_id\": \"ws_abc123-def456\",\n  \"labels\": [\n    \"needs-review\"\n  ],\n  \"worker\": \"build-agent-2\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.athenaintel.com/api/v0/tasks/claim-next', [
  'body' => '{
  "workspace_id": "ws_abc123-def456",
  "labels": [
    "needs-review"
  ],
  "worker": "build-agent-2"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.athenaintel.com/api/v0/tasks/claim-next");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"workspace_id\": \"ws_abc123-def456\",\n  \"labels\": [\n    \"needs-review\"\n  ],\n  \"worker\": \"build-agent-2\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "workspace_id": "ws_abc123-def456",
  "labels": ["needs-review"],
  "worker": "build-agent-2"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.athenaintel.com/api/v0/tasks/claim-next")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```