Start a task
[!NOTE] This endpoint is in public preview and is subject to change.
Starts a new Copilot cloud agent task for a repository.
This endpoint is only available to users with a Copilot Business or Copilot Enterprise subscription.
Fine-grained access tokens for “Start a task”
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 and write)
GitHub App installation access tokens are not supported for this endpoint.
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”The account owner of the repository. The name is not case sensitive.
The name of the repository. The name is not case sensitive.
Request Body required
Section titled “ Request Body required ”The task creation parameters, including the user’s prompt and optional agent settings.
object
The user’s prompt for the agent
The model to use for this task. The allowed models may change over time and depend on the user’s GitHub Copilot plan and organization policies. Currently supported values: claude-sonnet-4.6, claude-opus-4.6, gpt-5.2-codex, gpt-5.3-codex, gpt-5.4, claude-sonnet-4.5, claude-opus-4.5
Optional identifier for a custom agent to use for this task. Use the custom agent’s filename without the extension - for example, for a .github/agents/performance-optimizer.agent.md custom agent, use performance-optimizer.
Whether to create a PR.
Base ref for new branch/PR
Head ref for existing branch/PR. If provided with base_ref, the agent looks up open PR context for head_ref targeting base_ref and commits to head_ref instead of creating a new branch.
Examples
{ "prompt": "Fix the login button on the homepage", "base_ref": "main"}Task with a custom agent
{ "prompt": "Fix the login button on the homepage", "base_ref": "main", "custom_agent": "my-custom-agent"}Responses
Section titled “ Responses ”Task created 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.
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": "queued", "session_count": 1, "artifacts": [], "archived_at": null, "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T00:00:00Z"}Task created with a custom agent
{ "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": "queued", "session_count": 1, "custom_agent": { "id": "my-custom-agent" }, "artifacts": [], "archived_at": null, "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T00:00:00Z"}Problems parsing JSON
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" } ]}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" } ]}