Get a task by ID
[!NOTE] This endpoint is in public preview and is subject to change.
Returns a task by ID with its associated sessions
Fine-grained access tokens for “Get a task by ID”
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
- “Agent tasks” repository permissions (read)
GitHub App installation access tokens are not supported for this endpoint.
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”The unique identifier of the task.
Responses
Section titled “ Responses ”Task retrieved successfully
object
Unique task identifier
API URL for this task
Web URL for this task
Human-readable name derived from the task prompt
A GitHub user
object
The unique identifier of the user
Type of the task creator
User objects of collaborators on this task
A GitHub user
object
The unique identifier of the user
The owner of the repository
object
The unique identifier of the user
The repository this task belongs to
object
The unique identifier of the repository
Current state of the task, derived from its most recent session
Number of sessions in this task
Resources created by this task (PRs, branches, etc.)
A resource generated by the task
object
Provider namespace
Type of artifact. Available Values: pull, branch.
Timestamp when the task was archived, null if not archived
Timestamp of the most recent update
Timestamp when the task was created
Custom agent metadata associated with this task
object
The custom agent’s filename without the extension - for example, performance-optimizer for a .github/agents/performance-optimizer.agent.md custom agent.
Sessions associated with this task
Full session details within a task
object
Session ID
Session name
The user who created this session
object
The unique identifier of the user
The owner of the repository
object
The unique identifier of the user
The repository this session belongs to
object
The unique identifier of the repository
Task ID this session belongs to
Current state of a session
Creation timestamp
Last update timestamp
Completion timestamp
Content of the triggering event
Head branch name
Base branch name
Model used for this session
Structured information about billing units consumed by the session.
object
Billing unit used for this session. New sessions since June 1, 2026 use ai_credits, but older sessions use premium_requests.
Number of billing units used by this session. When the type is ai_credits, the value is a whole number, expressed in nano units. When presenting this to a human, divide by 1,000,000,000 and round to one decimal place. When aggregating (for example, summing usage across sessions), sum the nano values first, and divide once at the end before presenting to a human to avoid losing precision. When the type is premium_requests, the value may be fractional (for example 1.5).
Error details for a failed session
object
Error message
Examples
{ "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "url": "https://api.github.com/agents/repos/octocat/hello-world/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890", "html_url": "https://github.com/octocat/hello-world/copilot/tasks/a1b2c3d4-e5f6-7890-abcd-ef1234567890", "name": "Fix the login button on the homepage", "creator": { "id": 1 }, "creator_type": "user", "owner": { "id": 1 }, "repository": { "id": 1296269 }, "state": "completed", "session_count": 1, "artifacts": [ { "provider": "github", "type": "pull", "data": { "id": 42 } } ], "archived_at": null, "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T01:00:00Z", "sessions": [ { "id": "s1a2b3c4-d5e6-7890-abcd-ef1234567890", "name": "Fix the login button on the homepage", "user": { "id": 1 }, "owner": { "id": 1 }, "repository": { "id": 1296269 }, "task_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "state": "completed", "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T01:00:00Z", "completed_at": "2025-01-01T01:00:00Z", "prompt": "Fix the login button on the homepage", "head_ref": "copilot/fix-1", "base_ref": "main", "model": "claude-sonnet-4.6" } ]}Problems parsing request
Structured error response following GitHub REST API conventions. For 422 Unprocessable Entity the errors array contains validation details; for other error status codes only message and documentation_url are returned.
object
Summary message (e.g. “Validation Failed”, “Not Found”)
List of validation errors (present only for 422 responses)
A single validation error
object
Machine-readable error code
Human-readable message (populated when code is “custom”)
URL to relevant API documentation
Example
{ "errors": [ { "code": "missing" } ]}Authentication required
Structured error response following GitHub REST API conventions. For 422 Unprocessable Entity the errors array contains validation details; for other error status codes only message and documentation_url are returned.
object
Summary message (e.g. “Validation Failed”, “Not Found”)
List of validation errors (present only for 422 responses)
A single validation error
object
Machine-readable error code
Human-readable message (populated when code is “custom”)
URL to relevant API documentation
Example
{ "errors": [ { "code": "missing" } ]}Insufficient permissions
Structured error response following GitHub REST API conventions. For 422 Unprocessable Entity the errors array contains validation details; for other error status codes only message and documentation_url are returned.
object
Summary message (e.g. “Validation Failed”, “Not Found”)
List of validation errors (present only for 422 responses)
A single validation error
object
Machine-readable error code
Human-readable message (populated when code is “custom”)
URL to relevant API documentation
Example
{ "errors": [ { "code": "missing" } ]}Resource not found
Structured error response following GitHub REST API conventions. For 422 Unprocessable Entity the errors array contains validation details; for other error status codes only message and documentation_url are returned.
object
Summary message (e.g. “Validation Failed”, “Not Found”)
List of validation errors (present only for 422 responses)
A single validation error
object
Machine-readable error code
Human-readable message (populated when code is “custom”)
URL to relevant API documentation
Example
{ "errors": [ { "code": "missing" } ]}Validation Failed
Structured error response following GitHub REST API conventions. For 422 Unprocessable Entity the errors array contains validation details; for other error status codes only message and documentation_url are returned.
object
Summary message (e.g. “Validation Failed”, “Not Found”)
List of validation errors (present only for 422 responses)
A single validation error
object
Machine-readable error code
Human-readable message (populated when code is “custom”)
URL to relevant API documentation
Example
{ "errors": [ { "code": "missing" } ]}