Tasks API
The Tasks API allows you to manage and retrieve tasks in your Unpod platform. Tasks represent individual execution units within a run or space.Prerequisites: Make sure you have your API Token. See Authentication for details.
Create a Task in a Space
Create a new task inside a given space using the space’s public token. You can assign the task to a pilot/agent, attach multiple documents, provide additional context, and optionally schedule the execution.Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| space_token | string | Yes | Public token of the space where task is created |
You can get the
space_token by hitting the Get All Spaces API. The token field in the response is your Space Token.Headers
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | API Key format: Token <token> |
| Content-Type | string | Yes | application/json |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| pilot | string | Yes | Agent/pilot handle to assign the task |
| documents | array | Yes | Array of document objects with task data |
| context | string | No | Additional context for the task |
| schedule | object | No | Schedule configuration (type: “now”) |
Example Request
Document Object Fields
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Contact name |
| string | No | Contact email | |
| contact_number | string | Yes | Primary contact number |
| alternate_number | string | No | Alternate contact number |
| occupation | string | No | Contact’s occupation |
| company_name | string | No | Contact’s company |
| address | string | No | Contact’s address |
| about | string | No | About the contact |
| context | string | No | Additional context for the call |
| labels | array | No | Labels/tags for the document |
| title | string | No | Document title |
| description | string | No | Document description |
| document_id | string | No | Unique document identifier |
Success Response (200)
Response Fields
| Field | Type | Description |
|---|---|---|
| status_code | integer | HTTP status code |
| message | string | Response message |
| data | object | Created task details |
Data Object Fields
| Field | Type | Description |
|---|---|---|
| run_id | string | Created run identifier |
| space_id | string | Space identifier |
| status | string | Task status (initially pending) |
| created | string | Task creation timestamp |
| _id | string | Internal task document ID |
Error Response (206 — Validation / Creation Failed)
Get All Agents
Retrieve detailed information for all registered agents, helping you view and manage agent records within the system.Headers
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | API Key format: Token <token> |
| Org-Handle | string | Yes | Organization domain handle |
You can get the
Org-Handle by hitting the Get All Organizations API. The domain_handle field in the response is your Org-Handle.Example Request
Success Response (200)
Response Fields
| Field | Type | Description |
|---|---|---|
| count | integer | Total number of agents |
| status_code | integer | HTTP status code |
| message | string | Response message |
| data | array | Array of agent objects |
Agent Object Fields
| Field | Type | Description |
|---|---|---|
| handle | string | Unique agent handle/identifier |
| name | string | Agent display name |
| type | string | Agent type: Voice, Chat, etc. |
| state | string | Agent state: published, draft, archived |
| description | string | Agent description |
| purpose | string | Agent purpose/use case |
Error Response (401 — Unauthorized)
Get Tasks by Agent Handle
Fetch all tasks assigned to a specific agent/pilot using their handle. This returns full task metadata including user info, input payloads, attachments, and execution details.Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| handle | string | Yes | Unique handle/identifier of the agent |
The
handle is the agent handle. You can get it by hitting the Get All Agents API. The handle field in the response is your Agent Handle.Headers
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | API Key format: Token <token> |
| Content-Type | string | Yes | application/json |
Example Request
Success Response (200)
Response Fields
| Field | Type | Description |
|---|---|---|
| count | integer | Total number of tasks |
| status_code | integer | HTTP status code |
| message | string | Response message |
| data | array | Array of task objects |
Task Object Fields
| Field | Type | Description |
|---|---|---|
| _id | string | Internal task document ID |
| space_id | string | Space identifier |
| thread_id | string | Thread identifier (null if not applicable) |
| user | string | User ID who created the task |
| user_org_id | string | Organization ID of the user |
| user_info | object | User details (id, email, full_name, token) |
| created | string | Task creation timestamp |
| modified | string | Last modified timestamp |
| task_id | string | Unique task identifier |
| run_id | string | Parent run identifier |
| collection_ref | string | Reference to the data collection |
| task | object | Task definition with objective |
| input | object | Input data for the task |
| output | object | Task output (empty if pending) |
| attachments | array | List of attachments |
| assignee | string | Agent handle assigned to the task |
| status | string | Task status: pending, completed, failed |
| execution_type | string | Type of execution: call, email, etc. |
| ref_id | string | Reference ID linking to input data |
Error Response (206 — Tasks Fetch Failed)
Error Response (404 — Agent Not Found)
Get Tasks by Space Token
Fetch all tasks for a specific space using the space_token. Supports pagination with page and query parameters for efficient data retrieval.Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| space_token | string | Yes | Public token identifying the workspace |
You can get the
space_token by hitting the Get All Spaces API. The token field in the response is your Space Token.Query Parameters (Optional)
| Name | Type | Required | Description |
|---|---|---|---|
| page | int | No | Page number (default = 1) |
| page_size | int | No | Number of tasks per page (default = 20) |
Headers
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | API Key format: Token <token> |
| Content-Type | string | Yes | application/json |
Example Request
Success Response (200)
Response Fields
| Field | Type | Description |
|---|---|---|
| count | integer | Total number of tasks |
| status_code | integer | HTTP status code |
| message | string | Response message |
| data | array | Array of task objects |
Task Object Fields
| Field | Type | Description |
|---|---|---|
| _id | string | Internal task document ID |
| space_id | string | Space identifier |
| thread_id | string | Thread identifier (null if not applicable) |
| user | string | User ID who created the task |
| user_org_id | string | Organization ID of the user |
| user_info | object | User details (id, email, full_name, token) |
| created | string | Task creation timestamp |
| modified | string | Last modified timestamp |
| task_id | string | Unique task identifier |
| run_id | string | Parent run identifier |
| collection_ref | string | Reference to the data collection |
| task | object | Task definition with objective |
| input | object | Input data for the task |
| output | object | Task output (empty if pending) |
| attachments | array | List of attachments |
| assignee | string | Agent handle assigned to the task |
| status | string | Task status: pending, completed, failed |
| execution_type | string | Type of execution: call, email, etc. |
| ref_id | string | Reference ID linking to input data |
Output Object Fields
| Field | Type | Description |
|---|---|---|
| call_id | string | Unique call identifier |
| customer | string | Customer name |
| contact_number | string | Contact phone number |
| call_end_reason | string | Reason for call ending |
| recording_url | string | URL to call recording |
| transcript | array | Array of conversation messages |
| start_time | string | Call start timestamp |
| end_time | string | Call end timestamp |
| assistant_number | string | Outbound phone number used |
| call_summary | string | AI-generated summary of the call |
| duration | number | Call duration in seconds |
| cost | number | Cost of the call in USD |
| post_call_data | object | Post-call analysis data |
| metadata | object | Additional metadata (cost, type, usage) |
Error Response (206 — Tasks Fetch Failed)
Common Error Codes
| Status Code | Description |
|---|---|
| 200 | Success - Data fetched/created successfully |
| 206 | Partial Content - Business logic error occurred |
| 400 | Bad Request - Invalid parameters provided |
| 401 | Unauthorized - Invalid or missing API token |
| 403 | Forbidden - Access denied to the resource |
| 404 | Not Found - Agent or Space not found |
| 500 | Internal Server Error - Server-side error |
Code Examples
Best Practices
- Pagination: Use page and page_size parameters for efficient data retrieval
- Agent Handle: Ensure you’re using the correct agent handle for task assignment
- Document Fields: Include all required document fields (name, contact_number)
- Error Handling: Always handle potential errors and edge cases
- Security: Keep API tokens secure and rotate them regularly