Skip to main content

repo_tasks

Creates, updates, deletes, gets or lists a repo_tasks resource.

Overview

Namerepo_tasks
TypeResource
Idgithub.agent_tasks.repo_tasks

Fields

The following fields are returned by SELECT queries:

Task retrieved successfully

NameDatatypeDescription
idstringSession ID
namestringSession name
task_idstringTask ID this session belongs to
base_refstringBase branch name
completed_atstring (date-time)Completion timestamp
created_atstring (date-time)Creation timestamp
errorobjectError details for a failed session
head_refstringHead branch name
modelstringModel used for this session
ownerobjectThe owner of the repository
promptstringContent of the triggering event
repositoryobjectThe repository this session belongs to
statestringCurrent state of a session (queued, in_progress, completed, failed, idle, waiting_for_user, timed_out, cancelled)
updated_atstring (date-time)Last update timestamp
usageobjectStructured information about billing units consumed by the session.
userobjectThe user who created this session

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_task_by_repo_and_idselectowner, repo, task_id> [!NOTE]
> This endpoint is in public preview and is subject to change.

Returns a task by ID scoped to an owner/repo path

Fine-grained access tokens for "Get a task by repo"

This endpoint works with the following fine-grained token types:

* GitHub App user access tokens
* Fine-grained personal access tokens

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.
list_tasks_for_reposelectowner, repoper_page, page, sort, direction, state, is_archived, since, creator_id> [!NOTE]
> This endpoint is in public preview and is subject to change.

Returns a list of tasks for a specific repository

Fine-grained access tokens for "List tasks for repository"

This endpoint works with the following fine-grained token types:

* GitHub App user access tokens
* Fine-grained personal access tokens

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.
create_task_in_repoinsertowner, repo, prompt> [!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:

* GitHub App user access tokens
* Fine-grained personal access tokens

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

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
ownerstringThe account owner of the repository. The name is not case sensitive.
repostringThe name of the repository. The name is not case sensitive.
task_idstringThe unique identifier of the task.
creator_idarrayFilter tasks by creator user ID. Accepts one or more user IDs.
directionstringThe direction to sort results. Can be asc or desc.
is_archivedbooleanFilter by archived status. When true, returns only archived tasks. When false or omitted, returns only non-archived tasks. Defaults to false.
pageintegerThe page number of the results to fetch.
per_pageintegerThe number of results per page (max 100).
sincestring (date-time)Only show tasks updated at or after this time (ISO 8601 timestamp)
sortstringThe field to sort results by. Can be updated_at or created_at.
statestringComma-separated list of task states to filter by. Can be any combination of: queued, in_progress, completed, failed, idle, waiting_for_user, timed_out, cancelled.

SELECT examples

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

Returns a task by ID scoped to an owner/repo path

Fine-grained access tokens for "Get a task by repo"

This endpoint works with the following fine-grained token types:

* GitHub App user access tokens
* Fine-grained personal access tokens

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.

SELECT
id,
name,
task_id,
base_ref,
completed_at,
created_at,
error,
head_ref,
model,
owner,
prompt,
repository,
state,
updated_at,
usage,
user
FROM github.agent_tasks.repo_tasks
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND task_id = '{{ task_id }}' -- required
;

INSERT examples

> [!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:

* GitHub App user access tokens
* Fine-grained personal access tokens

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.

INSERT INTO github.agent_tasks.repo_tasks (
prompt,
model,
custom_agent,
create_pull_request,
base_ref,
head_ref,
owner,
repo
)
SELECT
'{{ prompt }}' /* required */,
'{{ model }}',
'{{ custom_agent }}',
{{ create_pull_request }},
'{{ base_ref }}',
'{{ head_ref }}',
'{{ owner }}',
'{{ repo }}'
RETURNING
id,
name,
archived_at,
artifacts,
created_at,
creator,
creator_type,
custom_agent,
html_url,
owner,
repository,
session_count,
state,
updated_at,
url,
user_collaborators
;