Skip to main content

Runs API

The Runs API allows you to manage and monitor execution runs in your Unpod platform. A run represents a batch execution or group of tasks within a space.

How to Get Your Space Token

Follow these steps to obtain your Space Token from the Unpod Dashboard:
  1. Login to the Unpod Dashboard
  2. On the left sidebar, click on the Conversation tab
  3. Click on the Settings icon
  4. You’ll see the Space Token option
  5. Click on it to copy the Space Token
Each space has a unique token. Make sure you’re using the correct space token for your API requests.

Get All Runs in a Space

Retrieve all runs associated with a specific space. A run represents a batch execution or group of tasks. This endpoint returns run details including run ID, status, timestamps, and associated user metadata.
GET /api/v2/platform/spaces/{space_token}/runs/

Path Parameters

NameTypeRequiredDescription
space_tokenstringYesPublic token identifying the space

Headers

NameTypeRequiredDescription
AuthorizationstringYesAPI Key format: Token <token>
Content-TypestringYesapplication/json

Example Request

GET /api/v2/platform/spaces/space_abc123xyz/runs/
Headers:
  Authorization: Token your-api-token
  Content-Type: application/json

Success Response (200)

{
  "count": 1716,
  "status_code": 200,
  "message": "Runs Fetched Successfully",
  "data": [
    {
      "space_id": "346",
      "user": "38",
      "thread_id": null,
      "run_id": "R40fe5eface1511f082ac156368e7acc4",
      "collection_ref": "collection_data_F1O3QJM1Y7Q1AVVUYNV4VPRB",
      "run_mode": "dev",
      "status": "completed",
      "batch_count": 1,
      "created": "2025-11-30T17:51:52",
      "modified": "2025-11-30T17:51:52"
    }
  ]
}

Response Fields

FieldTypeDescription
countintegerTotal number of runs
status_codeintegerHTTP status code
messagestringResponse message
dataarrayArray of run objects

Run Object Fields

FieldTypeDescription
space_idstringSpace identifier
userstringUser ID who created the run
thread_idstringThread identifier (null if not applicable)
run_idstringUnique run identifier
collection_refstringReference to the data collection
run_modestringExecution mode: dev, prod
statusstringRun status: completed, running, failed
batch_countintegerNumber of batches in the run
createdstringRun creation timestamp
modifiedstringLast modified timestamp

Error Response (206 — Fetch Failed)

{
  "message": "Error fetching runs",
  "errors": "Detailed error description"
}

Get Detailed Tasks for a Specific Run

Fetches all tasks for a specific run, including complete input, output, call transcript, costs, analysis, artifacts, and provider metadata. This endpoint is used when you need deep inspection of how a run executed each task.
GET /api/v2/platform/spaces/{space_token}/runs/{run_id}/tasks/

Path Parameters

NameTypeRequiredDescription
space_tokenstringYesPublic token of the space
run_idstringYesThe run ID whose tasks to retrieve

Headers

NameTypeRequiredDescription
AuthorizationstringYesAPI Key format: Token <token>
Content-TypestringYesapplication/json

Example Request

GET /api/v2/platform/spaces/space_abc123xyz/runs/R40fe5eface1511f082ac156368e7acc4/tasks/
Headers:
  Authorization: Token your-api-token
  Content-Type: application/json

Success Response (200)

{
  "count": 1,
  "status_code": 200,
  "message": "Tasks Fetched Successfully",
  "data": [
    {
      "space_id": "346",
      "thread_id": null,
      "user": "261",
      "user_org_id": "22",
      "user_info": {
        "id": "261",
        "email": "[email protected]",
        "full_name": "John Doe",
        "user_token": "JY60XSSVVPTV5W5A"
      },
      "run_id": "R0e3294d4cc4211f082ac156368e7acc4",
      "task_id": "T0e3294d5cc4211f082ac156368e7acc4",
      "collection_ref": "collection_data_F1O3QJM1Y7Q1AVVUYNV4VPRB",
      "execution_type": "call",
      "task": {
        "objective": "hey"
      },
      "input": {
        "document_id": "692974344eb028916272c240",
        "name": "John Doe",
        "contact_number": "9876688992",
        "created": "2025-11-28T10:06:44",
        "token": "F1O3QJM1Y7Q1AVVUYNV4VPRB",
        "vapi_agent_id": "6a683958-27ab-4ac5-8b0f-52dae3892efe",
        "number_id": "2d81624a-a0ec-4459-9399-cf71fb21be06",
        "quality": "high"
      },
      "output": {
        "id": "call-uuid-001",
        "assistantId": "assistant-123",
        "phoneNumberId": "phone-456",
        "type": "outbound",
        "startedAt": "2025-11-17T12:05:00.000Z",
        "endedAt": "2025-11-17T12:10:00.000Z",
        "transcript": "Agent: Hello, this is calling to confirm...\nCustomer: Yes, confirmed.",
        "recordingUrl": "https://example.com/recordings/rec123.mp3",
        "summary": "Customer confirmed the appointment for tomorrow at 2 PM",
        "createdAt": "2025-11-17T12:05:00.000Z",
        "updatedAt": "2025-11-17T12:10:00.000Z",
        "orgId": "org-789",
        "cost": 0.45,
        "customer": {
          "number": "+1234567890",
          "name": "Alice Smith"
        }
      },
      "created": "2025-11-28T10:07:32",
      "modified": "2025-11-28T12:04:08"
    }
  ]
}

Response Fields

FieldTypeDescription
countintegerTotal number of tasks
status_codeintegerHTTP status code
messagestringResponse message
dataarrayArray of task objects

Task Object Fields

FieldTypeDescription
space_idstringSpace identifier
thread_idstringThread identifier (null if not applicable)
userstringUser ID who created the task
user_org_idstringOrganization ID of the user
user_infoobjectUser details (id, email, full_name, token)
run_idstringParent run identifier
task_idstringUnique task identifier
collection_refstringReference to the data collection
execution_typestringType of execution: call, email, etc.
taskobjectTask definition with objective
inputobjectInput data for the task
outputobjectTask output including call details
createdstringTask creation timestamp
modifiedstringLast modified timestamp

Input Object Fields

FieldTypeDescription
document_idstringDocument identifier
namestringContact name
contact_numberstringContact phone number
createdstringInput creation timestamp
tokenstringCollection token
vapi_agent_idstringVapi agent identifier
number_idstringNumber identifier
qualitystringCall quality setting: high, low

Output Object Fields

FieldTypeDescription
idstringUnique call identifier
assistantIdstringAssistant identifier
phoneNumberIdstringPhone number identifier
typestringCall type: outbound, inbound
startedAtstringCall start timestamp
endedAtstringCall end timestamp
transcriptstringCall transcript
recordingUrlstringURL to call recording
summarystringAI-generated call summary
createdAtstringRecord creation timestamp
updatedAtstringRecord update timestamp
orgIdstringOrganization identifier
costnumberCost of the call in USD
customerobjectCustomer details (number, name)

Error Response (206 — Business Logic Error)

{
  "message": "Error retrieving run tasks",
  "errors": "Detailed error description"
}

Common Error Codes

Status CodeDescription
200Success - Data fetched successfully
206Partial Content - Business logic error occurred
400Bad Request - Invalid parameters provided
401Unauthorized - Invalid or missing API token
403Forbidden - Access denied to the resource
404Not Found - Space or Run not found
500Internal Server Error - Server-side error

Code Examples

const axios = require('axios');

const headers = {
  'Authorization': 'Token your-api-token',
  'Content-Type': 'application/json'
};

// Get all runs in a space
const fetchRuns = async (spaceToken) => {
  const response = await axios.get(
    `https://unpod.dev/api/v2/platform/spaces/${spaceToken}/runs/`,
    { headers }
  );

  console.log(`Total runs: ${response.data.count}`);
  response.data.data.forEach(run => {
    console.log(`Run ${run.run_id}: ${run.status} (${run.batch_count} batches)`);
  });
  return response.data.data;
};

// Get tasks for a specific run
const fetchRunTasks = async (spaceToken, runId) => {
  const response = await axios.get(
    `https://unpod.dev/api/v2/platform/spaces/${spaceToken}/runs/${runId}/tasks/`,
    { headers }
  );

  console.log(`Total tasks: ${response.data.count}`);
  response.data.data.forEach(task => {
    console.log(`Task ${task.task_id}: ${task.execution_type}`);
    if (task.output?.summary) {
      console.log(`  Summary: ${task.output.summary}`);
    }
  });
  return response.data.data;
};

// Example usage
fetchRuns('your-space-token');

Best Practices

  1. Space Token: Always use the correct space token for your API requests
  2. Pagination: For spaces with many runs, implement proper pagination handling
  3. Error Handling: Always handle potential errors and edge cases
  4. Filtering: Use status filters to focus on specific run outcomes
  5. Security: Keep API tokens secure and rotate them regularly