apicheats.dev github/llms.txt Raw .md
POST

POST /agents/repos/{owner}/{repo}/tasks — GitHub API

GitHub token (required); https://api.github.com

GitHub API

Start a task

Base URL
https://api.github.com
Auth
Authorization: Bearer <GITHUB_API_KEY>
Last verified
2026-10-20 · upstream hash matched
Actions Try in browser→
Agents: curl -H "Accept: text/markdown" this URL
→ 364 tokens · Vary: Accept

Critical gotchas

GitHub recommends an Accept: application/vnd.github+json header and an explicit X-GitHub-Api-Version header.

Fine-grained tokens only authorize repositories and permissions selected when the token is created.

cURL

curl -X POST 'https://api.github.com/agents/repos/example-owner/example-repo/tasks' \  -H "Authorization: Bearer $GITHUB_TOKEN" \  -H 'Accept: application/vnd.github+json' \  -H 'X-GitHub-Api-Version: 2026-03-10' \  -H 'Content-Type: application/json' \  -d '{  "prompt": "example-prompt"}'

Parameters

Name In Type Required Description
owner path string Yes The account owner of the repository. The name is not case sensitive.
repo path string Yes The name of the repository. The name is not case sensitive.
prompt body string Yes The user's prompt for the agent
model body string No 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`
custom_agent body string No 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`.
create_pull_request body boolean No Whether to create a PR.
base_ref body string No Base ref for new branch/PR
head_ref body string No 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.

Response 200 OK

{
  "id": "string",
  "url": "string",
  "html_url": "string",
  "name": "string",
  "creator": {
    "id": 0
  },
  "creator_type": "user",
  "user_collaborators": [
    {
      "id": 0
    }
  ],
  "owner": {
    "id": 0
  },
  "repository": {
    "id": 0
  },
  "state": "queued",
  "session_count": 0,
  "artifacts": [
    {
      "provider": "github",
      "type": "pull",
      "data": {
        "id": 0,
        "global_id": "string"
      }
    }
  ],
  "archived_at": "2026-09-03T00:00:00Z",
  "updated_at": "2026-09-03T00:00:00Z",
  "created_at": "2026-09-03T00:00:00Z",
  "custom_agent": {
    "id": "string"
  }
}
Get a free GitHub API key → sponsored

Affiliate link - we may earn a commission, at no extra cost to you.