# Tasks ## List objective tasks `client.objectives.tasks.list(stringobjectiveID, TaskListParamsquery?, RequestOptionsoptions?): CursorPagination` **get** `/v1/objectives/{objectiveId}/tasks` Lists all tasks for an objective ### Parameters - `objectiveID: string` - `query: TaskListParams` - `cursor?: string` Pagination cursor from previous response - `limit?: number` Maximum number of results to return - `sortOrder?: string` Sort order for results ### Returns - `ObjectiveTask` ObjectiveTask represents a task within an objective, typically created and managed by an AI agent to track progress toward completing the objective. - `data: ObjectiveTaskData` - `completed: boolean` Whether the task has been completed - `number: number` The sequential number of this task within the objective (auto-assigned, 1-based) - `task: string` Description of the task to be completed - `completedAt?: string` Timestamp when the task was marked as completed - `metadata: BareMetadata` BareMetadata contains the minimal metadata for a resource: the ID and an optional human-readable name. These are used for reference fields where the full metadata (account scoping, timestamps, labels, external IDs) is not needed — e.g., the tool references inside an agent variation spec or the tools assigned to an objective. Both fields are server-populated; clients provide IDs through sibling fields rather than by constructing a BareMetadata themselves. - `id?: string` - `name?: string` Human-readable name of the referenced resource, populated by the server on reads for convenience. Absent on references to resources that do not have a name (e.g., objective tasks). ### Example ```typescript import Cadenya from '@cadenya/cadenya'; const client = new Cadenya({ apiKey: process.env['CADENYA_API_KEY'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const objectiveTask of client.objectives.tasks.list('objectiveId')) { console.log(objectiveTask.data); } ``` #### Response ```json { "items": [ { "data": { "completed": true, "number": 0, "task": "task", "completedAt": "2019-12-27T18:11:19.117Z" }, "metadata": { "id": "id", "name": "name" } } ], "pagination": { "nextCursor": "nextCursor", "total": 0 } } ``` ## Get an objective task by ID `client.objectives.tasks.retrieve(stringid, TaskRetrieveParamsparams, RequestOptionsoptions?): ObjectiveTask` **get** `/v1/objectives/{objectiveId}/tasks/{id}` Retrieves a task by ID from an objective ### Parameters - `id: string` - `params: TaskRetrieveParams` - `objectiveId: string` The ID of the objective. Supports "external_id:" prefix for external IDs. ### Returns - `ObjectiveTask` ObjectiveTask represents a task within an objective, typically created and managed by an AI agent to track progress toward completing the objective. - `data: ObjectiveTaskData` - `completed: boolean` Whether the task has been completed - `number: number` The sequential number of this task within the objective (auto-assigned, 1-based) - `task: string` Description of the task to be completed - `completedAt?: string` Timestamp when the task was marked as completed - `metadata: BareMetadata` BareMetadata contains the minimal metadata for a resource: the ID and an optional human-readable name. These are used for reference fields where the full metadata (account scoping, timestamps, labels, external IDs) is not needed — e.g., the tool references inside an agent variation spec or the tools assigned to an objective. Both fields are server-populated; clients provide IDs through sibling fields rather than by constructing a BareMetadata themselves. - `id?: string` - `name?: string` Human-readable name of the referenced resource, populated by the server on reads for convenience. Absent on references to resources that do not have a name (e.g., objective tasks). ### Example ```typescript import Cadenya from '@cadenya/cadenya'; const client = new Cadenya({ apiKey: process.env['CADENYA_API_KEY'], // This is the default and can be omitted }); const objectiveTask = await client.objectives.tasks.retrieve('id', { objectiveId: 'objectiveId' }); console.log(objectiveTask.data); ``` #### Response ```json { "data": { "completed": true, "number": 0, "task": "task", "completedAt": "2019-12-27T18:11:19.117Z" }, "metadata": { "id": "id", "name": "name" } } ``` ## Domain Types ### Objective Task - `ObjectiveTask` ObjectiveTask represents a task within an objective, typically created and managed by an AI agent to track progress toward completing the objective. - `data: ObjectiveTaskData` - `completed: boolean` Whether the task has been completed - `number: number` The sequential number of this task within the objective (auto-assigned, 1-based) - `task: string` Description of the task to be completed - `completedAt?: string` Timestamp when the task was marked as completed - `metadata: BareMetadata` BareMetadata contains the minimal metadata for a resource: the ID and an optional human-readable name. These are used for reference fields where the full metadata (account scoping, timestamps, labels, external IDs) is not needed — e.g., the tool references inside an agent variation spec or the tools assigned to an objective. Both fields are server-populated; clients provide IDs through sibling fields rather than by constructing a BareMetadata themselves. - `id?: string` - `name?: string` Human-readable name of the referenced resource, populated by the server on reads for convenience. Absent on references to resources that do not have a name (e.g., objective tasks). ### Objective Task Data - `ObjectiveTaskData` - `completed: boolean` Whether the task has been completed - `number: number` The sequential number of this task within the objective (auto-assigned, 1-based) - `task: string` Description of the task to be completed - `completedAt?: string` Timestamp when the task was marked as completed