Docs / API Reference / REST API

REST API

Complete endpoint reference for the Ploton REST API — create, retrieve, list, and cancel tasks.

Tasks

A task is a unit of work. You create one, Ploton runs it.

All endpoints require an Authorization: Bearer <api_key> header.


Create a task

POST /v1/tasks

Creates a task and starts running it immediately.

Request body

FieldTypeRequiredDefaultDescription
promptstringYesNatural language description of the work to perform. Max 10,000 characters.
user_idstringNonullThe end-user this task is for. Required for tasks that touch user-specific services.
metadataobjectNo{}Arbitrary key-value pairs. Handy for correlating tasks with your own records.
modestringNo"live"Set to "test" to validate the prompt and preview tool selection without actually executing.

Example request

curl -X POST https://api.ploton.ai/v1/tasks \
  -H "Authorization: Bearer $PLOTON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Pull all contacts from user_123'\''s CRM account created in the last 30 days. Return name, email, and company.",
    "user_id": "user_123",
    "metadata": {
      "source": "lead_enrichment_pipeline"
    }
  }'

Example response

{
  "id": "task_8xK2mP",
  "status": "running",
  "tool": "crm",
  "created_at": "2025-06-15T14:22:00Z",
  "metadata": {
    "source": "lead_enrichment_pipeline"
  }
}

Error responses

StatusCodeCause
400invalid_requestMissing prompt field or invalid JSON
401invalid_api_keyBad or revoked API key
422prompt_too_longPrompt exceeds 10,000 characters
429rate_limit_exceededToo many requests — check Retry-After header

Get a task

GET /v1/tasks/:task_id

Returns a task by ID. Includes the result if the task is done, or the error if it failed.

Path parameters

ParameterTypeDescription
task_idstringThe task ID (e.g., task_8xK2mP)

Example request

curl https://api.ploton.ai/v1/tasks/task_8xK2mP \
  -H "Authorization: Bearer $PLOTON_API_KEY"

Example response (complete)

{
  "id": "task_8xK2mP",
  "status": "complete",
  "tool": "crm",
  "created_at": "2025-06-15T14:22:00Z",
  "completed_at": "2025-06-15T14:22:07Z",
  "result": {
    "contacts": [
      {
        "name": "Jane Smith",
        "email": "[email protected]",
        "company": "Acme Corp"
      },
      {
        "name": "Bob Chen",
        "email": "[email protected]",
        "company": "Globex Inc"
      }
    ]
  },
  "metadata": {
    "source": "lead_enrichment_pipeline"
  }
}

Example response (failed)

{
  "id": "task_8xK2mP",
  "status": "failed",
  "tool": "crm",
  "created_at": "2025-06-15T14:22:00Z",
  "failed_at": "2025-06-15T14:22:04Z",
  "error": {
    "code": "auth_token_expired",
    "message": "The user's OAuth token has expired and automatic refresh failed.",
    "recoverable": true,
    "suggestion": "Prompt the user to re-authorize access"
  },
  "metadata": {
    "source": "lead_enrichment_pipeline"
  }
}

Error responses

StatusCodeCause
401invalid_api_keyBad or revoked API key
404task_not_foundNo task exists with this ID

List tasks

GET /v1/tasks

Returns tasks, paginated.

Query parameters

ParameterTypeDefaultDescription
statusstringFilter by status: pending, running, complete, failed, waiting, cancelled
user_idstringFilter by end-user ID
limitinteger20Items per page (max 100)
offsetinteger0Number of items to skip

Example request

curl "https://api.ploton.ai/v1/tasks?status=complete&user_id=user_123&limit=5" \
  -H "Authorization: Bearer $PLOTON_API_KEY"

Example response

{
  "data": [
    {
      "id": "task_8xK2mP",
      "status": "complete",
      "tool": "crm",
      "created_at": "2025-06-15T14:22:00Z",
      "completed_at": "2025-06-15T14:22:07Z"
    },
    {
      "id": "task_3nL7pR",
      "status": "complete",
      "tool": "payments",
      "created_at": "2025-06-15T13:10:00Z",
      "completed_at": "2025-06-15T13:10:12Z"
    }
  ],
  "has_more": true
}

List responses omit result and error. Hit GET /v1/tasks/:task_id for the full object.


Cancel a task

POST /v1/tasks/:task_id/cancel

Cancels a pending, running, or waiting task. Returns 409 if the task already finished or failed.

Path parameters

ParameterTypeDescription
task_idstringThe task ID to cancel

Example request

curl -X POST https://api.ploton.ai/v1/tasks/task_8xK2mP/cancel \
  -H "Authorization: Bearer $PLOTON_API_KEY"

Example response

{
  "id": "task_8xK2mP",
  "status": "cancelled",
  "cancelled_at": "2025-06-15T14:22:05Z"
}

Error responses

StatusCodeCause
401invalid_api_keyBad or revoked API key
404task_not_foundNo task exists with this ID
409task_already_completeTask has already completed, failed, or been cancelled

Get a task trace

GET /v1/tasks/:task_id/trace

Returns the step-by-step execution trace for a task: what ran, in what order, and how long each step took.

Example request

curl https://api.ploton.ai/v1/tasks/task_8xK2mP/trace \
  -H "Authorization: Bearer $PLOTON_API_KEY"

Example response

{
  "task_id": "task_8xK2mP",
  "steps": [
    {
      "tool": "crm",
      "action": "authenticate",
      "status": "complete",
      "duration_ms": 120
    },
    {
      "tool": "crm",
      "action": "fetch_contacts",
      "status": "complete",
      "duration_ms": 890,
      "note": "Filtered to last 30 days, 47 contacts returned"
    },
    {
      "tool": "crm",
      "action": "format_response",
      "status": "complete",
      "duration_ms": 15
    }
  ],
  "total_duration_ms": 1025
}

Use traces to debug failures or find where time is going.

Next steps