---
title: "Get a task by ID"
method: GET
path: "/agents/tasks/{task_id}"
tags: ["agent-tasks"]
---

# Get a task by ID

`GET /agents/tasks/{task_id}`

> [!NOTE]
> This endpoint is in public preview and is subject to change.

Returns a task by ID with its associated sessions

## Path parameters

- `task_id` string, required

## Response `200`

Task retrieved successfully

- object
  - `id` string, required — Unique task identifier
  - `url` string — API URL for this task
  - `html_url` string — Web URL for this task
  - `name` string — Human-readable name derived from the task prompt
  - `creator` object — A GitHub user
    - `id` integer — The unique identifier of the user
  - `creator_type` 'user' | 'organization' — Type of the task creator
  - `user_collaborators` object[] — User objects of collaborators on this task
    - `id` integer — The unique identifier of the user
  - `owner` object — The owner of the repository
    - `id` integer — The unique identifier of the user
  - `repository` object — The repository this task belongs to
    - `id` integer — The unique identifier of the repository
  - `state` 'queued' | 'in_progress' | 'completed' | 'failed' | 'idle' | 'waiting_for_user' | 'timed_out' | 'cancelled', required — Current state of the task, derived from its most recent session
  - `session_count` integer — Number of sessions in this task
  - `artifacts` object[] — Resources created by this task (PRs, branches, etc.)
    - `provider` 'github', required — Provider namespace
    - `type` 'github_resource' | 'branch', required — Discriminator for data shape
    - `data` union, required — Resource data (shape depends on type)
      - object — A GitHub resource (pull request, issue, etc.)
        - `id` integer — GitHub resource ID
        - `type` string — Resource type (e.g., pull_request, issue)
        - `global_id` string — GraphQL global ID
      - object — A Git branch reference
        - `head_ref` string — Head branch name
        - `base_ref` string — Base branch name
  - `archived_at` string, date-time, nullable — Timestamp when the task was archived, null if not archived
  - `updated_at` string, date-time — Timestamp of the most recent update
  - `created_at` string, date-time, required — Timestamp when the task was created
  - `sessions` object[] — Sessions associated with this task
    - `id` string, required — Session ID
    - `name` string — Session name
    - `user` object — The user who created this session
      - `id` integer — The unique identifier of the user
    - `owner` object — The owner of the repository
      - `id` integer — The unique identifier of the user
    - `repository` object — The repository this session belongs to
      - `id` integer — The unique identifier of the repository
    - `agent_id` integer — Agent ID
    - `agent_task_id` string — Agent internal task ID
    - `task_id` string — Task ID this session belongs to
    - `state` 'queued' | 'in_progress' | 'completed' | 'failed' | 'idle' | 'waiting_for_user' | 'timed_out' | 'cancelled', required — Current state of a session
    - `created_at` string, date-time, required — Creation timestamp
    - `updated_at` string, date-time — Last update timestamp
    - `completed_at` string, date-time — Completion timestamp
    - `event_type` string — Type of event that triggered this session
    - `event_url` string — URL of the triggering event
    - `event_content` string — Content of the triggering event
    - `event_identifiers` string[] — Identifiers for tracking
    - `resource_type` string — Type of resource associated with this session
    - `resource_id` integer — Resource ID
    - `resource_number` integer — Resource number (e.g., PR number)
    - `resource_global_id` string — GraphQL global ID of the resource
    - `resource_state` string — State of the associated resource
    - `head_ref` string — Head branch name
    - `base_ref` string — Base branch name
    - `workflow_run_id` integer — GitHub Actions workflow run ID
    - `model` string — Model used for this session
    - `premium_requests` number, double — Premium request count
    - `error` object — Error details for a failed session
      - `message` string — Error message

## Other responses

- `400` — Problems parsing request
- `401` — Authentication required
- `403` — Insufficient permissions
- `404` — Resource not found
- `422` — Validation Failed

## Changes

- **2026-04-02** `f46a0dd461fb` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/github/apis/enterprise-cloud/changes/agents/tasks/:task_id/get.md)

---

[API](https://skmtc.dev/github/apis/enterprise-cloud.md) · [All operations](https://skmtc.dev/github/apis/enterprise-cloud/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/github/enterprise-cloud/revisions/b0fdd71dd714/schema)
