## Get Task by ID

`client.tasks.retrieve(stringtaskID, TaskRetrieveParamsquery?, RequestOptionsoptions?): TaskRetrieveResponse`

**get** `/tasks/{task_id}`

Get a task by its unique ID.

### Parameters

- `taskID: string`

- `query: TaskRetrieveParams`

  - `relationships?: Array<"agents">`

    - `"agents"`

### Returns

- `TaskRetrieveResponse`

  Task response model with optional related data based on relationships

  - `id: string`

  - `agents?: Array<Agent> | null`

    - `id: string`

      The unique identifier of the agent.

    - `acp_type: AcpType`

      The type of the ACP Server (Either sync or async)

      - `"sync"`

      - `"async"`

      - `"agentic"`

    - `created_at: string`

      The timestamp when the agent was created

    - `description: string`

      The description of the action.

    - `name: string`

      The unique name of the agent.

    - `updated_at: string`

      The timestamp when the agent was last updated

    - `agent_input_type?: "text" | "json" | null`

      The type of input the agent expects.

      - `"text"`

      - `"json"`

    - `production_deployment_id?: string | null`

      ID of the current production deployment.

    - `registered_at?: string | null`

      The timestamp when the agent was last registered

    - `registration_metadata?: Record<string, unknown> | null`

      The metadata for the agent's registration.

    - `status?: "Ready" | "Failed" | "Unknown" | 3 more`

      The status of the action, indicating if it's building, ready, failed, etc.

      - `"Ready"`

      - `"Failed"`

      - `"Unknown"`

      - `"Deleted"`

      - `"Unhealthy"`

      - `"BuildOnly"`

    - `status_reason?: string | null`

      The reason for the status of the action.

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const task = await client.tasks.retrieve('task_id');

console.log(task.id);
```

#### Response

```json
{
  "id": "id",
  "agents": [
    {
      "id": "id",
      "acp_type": "sync",
      "created_at": "2019-12-27T18:11:19.117Z",
      "description": "description",
      "name": "name",
      "updated_at": "2019-12-27T18:11:19.117Z",
      "agent_input_type": "text",
      "production_deployment_id": "production_deployment_id",
      "registered_at": "2019-12-27T18:11:19.117Z",
      "registration_metadata": {
        "foo": "bar"
      },
      "status": "Ready",
      "status_reason": "status_reason"
    }
  ],
  "cleaned_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "params": {
    "foo": "bar"
  },
  "status": "CANCELED",
  "status_reason": "status_reason",
  "task_metadata": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```
