Skip to main content
REST API 现已开始进行版本化。 有关详细信息,请参阅“关于 API 版本控制”。

REST API endpoints for Copilot Spaces

Use the REST API to interact with Copilot Spaces resources.

List resources for an organization Copilot Space

Lists all resources attached to a specific Copilot Space owned by an organization. The authenticated user must have appropriate permissions to view the space.

OAuth app tokens and personal access tokens (classic) need the read:org scope to use this endpoint.

“List resources for an organization Copilot Space”的细粒度访问令牌

此端点支持以下精细令牌类型:

细粒度令牌必须具有以下权限集:

  • "Copilot Spaces" organization permissions (read)

“”List resources for an organization Copilot Space 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
org string 必须

The organization name. The name is not case sensitive.

space_number integer 必须

The unique identifier of the Copilot Space.

“List resources for an organization Copilot Space”的 HTTP 响应状态代码

状态代码说明
200

OK

403

Forbidden

404

Resource not found

“List resources for an organization Copilot Space”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

get/orgs/{org}/copilot-spaces/{space_number}/resources
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/orgs/ORG/copilot-spaces/SPACE_NUMBER/resources

Response

Status: 200
{ "resources": [ { "id": 1, "resource_type": "repository", "copilot_chat_attachment_id": null, "metadata": { "repository_id": 42 }, "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T00:00:00Z" }, { "id": 2, "resource_type": "free_text", "copilot_chat_attachment_id": null, "metadata": { "name": "notes.txt", "text": "Some helpful notes" }, "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T00:00:00Z" } ] }

Create a resource for an organization Copilot Space

Creates a new resource in a specific Copilot Space owned by an organization. The authenticated user must have write permissions on the space.

The following resource types are supported: repository, github_file, free_text, github_issue, github_pull_request. The uploaded_text_file and media_content types are not supported via this endpoint.

For github_file resources, if a resource with the same repository, file path, and SHA already exists, the existing resource is returned with a 200 status.

OAuth app tokens and personal access tokens (classic) need the write:org scope to use this endpoint.

“Create a resource for an organization Copilot Space”的细粒度访问令牌

此端点支持以下精细令牌类型:

细粒度令牌必须具有以下权限集:

  • "Copilot Spaces" organization permissions (write)

“”Create a resource for an organization Copilot Space 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
org string 必须

The organization name. The name is not case sensitive.

space_number integer 必须

The unique identifier of the Copilot Space.

主体参数
名称, 类型, 说明
resource_type string 必须

The type of resource to create.

可以是以下选项之一: repository, github_file, free_text, github_issue, github_pull_request

metadata object 必须

Resource-specific metadata.

“Create a resource for an organization Copilot Space”的 HTTP 响应状态代码

状态代码说明
200

Duplicate github_file resource already exists

201

Resource created

403

Forbidden

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Get a resource for an organization Copilot Space

Gets a specific resource attached to a Copilot Space owned by an organization. The authenticated user must have appropriate permissions to view the space.

OAuth app tokens and personal access tokens (classic) need the read:org scope to use this endpoint.

“Get a resource for an organization Copilot Space”的细粒度访问令牌

此端点支持以下精细令牌类型:

细粒度令牌必须具有以下权限集:

  • "Copilot Spaces" organization permissions (read)

“”Get a resource for an organization Copilot Space 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
org string 必须

The organization name. The name is not case sensitive.

space_number integer 必须

The unique identifier of the Copilot Space.

space_resource_id integer 必须

The unique identifier of the resource.

“Get a resource for an organization Copilot Space”的 HTTP 响应状态代码

状态代码说明
200

OK

403

Forbidden

404

Resource not found

“Get a resource for an organization Copilot Space”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

get/orgs/{org}/copilot-spaces/{space_number}/resources/{space_resource_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/orgs/ORG/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID

Response

Status: 200
{ "id": 1, "resource_type": "free_text", "copilot_chat_attachment_id": null, "metadata": { "name": "notes.txt", "text": "Some helpful notes" }, "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T00:00:00Z" }

Set a resource for an organization Copilot Space

Updates the metadata of a resource in a specific Copilot Space owned by an organization. The authenticated user must have write permissions on the space.

OAuth app tokens and personal access tokens (classic) need the write:org scope to use this endpoint.

“Set a resource for an organization Copilot Space”的细粒度访问令牌

此端点支持以下精细令牌类型:

细粒度令牌必须具有以下权限集:

  • "Copilot Spaces" organization permissions (write)

“”Set a resource for an organization Copilot Space 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
org string 必须

The organization name. The name is not case sensitive.

space_number integer 必须

The unique identifier of the Copilot Space.

space_resource_id integer 必须

The unique identifier of the resource.

主体参数
名称, 类型, 说明
metadata object

Updated resource-specific metadata.

“Set a resource for an organization Copilot Space”的 HTTP 响应状态代码

状态代码说明
200

OK

403

Forbidden

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

“Set a resource for an organization Copilot Space”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

put/orgs/{org}/copilot-spaces/{space_number}/resources/{space_resource_id}
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/orgs/ORG/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID \ -d '{"metadata":{"name":"updated-notes.txt","text":"Updated content"}}'

Response

Status: 200
{ "id": 1, "resource_type": "free_text", "copilot_chat_attachment_id": null, "metadata": { "name": "updated-notes.txt", "text": "Updated content" }, "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T12:00:00Z" }

Delete a resource from an organization Copilot Space

Deletes a resource from a specific Copilot Space owned by an organization. The authenticated user must have write permissions on the space.

OAuth app tokens and personal access tokens (classic) need the write:org scope to use this endpoint.

“Delete a resource from an organization Copilot Space”的细粒度访问令牌

此端点支持以下精细令牌类型:

细粒度令牌必须具有以下权限集:

  • "Copilot Spaces" organization permissions (write)

“”Delete a resource from an organization Copilot Space 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
org string 必须

The organization name. The name is not case sensitive.

space_number integer 必须

The unique identifier of the Copilot Space.

space_resource_id integer 必须

The unique identifier of the resource.

“Delete a resource from an organization Copilot Space”的 HTTP 响应状态代码

状态代码说明
204

No Content

403

Forbidden

404

Resource not found

“Delete a resource from an organization Copilot Space”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

delete/orgs/{org}/copilot-spaces/{space_number}/resources/{space_resource_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/orgs/ORG/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID

Response

Status: 204

List resources for a Copilot Space for a user

Lists all resources attached to a specific Copilot Space owned by a user. The authenticated user must have appropriate permissions to view the space.

OAuth app tokens and personal access tokens (classic) need the read:user scope to use this endpoint.

“List resources for a Copilot Space for a user”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”List resources for a Copilot Space for a user 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
username string 必须

The handle for the GitHub user account.

space_number integer 必须

The unique identifier of the Copilot Space.

“List resources for a Copilot Space for a user”的 HTTP 响应状态代码

状态代码说明
200

OK

403

Forbidden

404

Resource not found

“List resources for a Copilot Space for a user”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

get/users/{username}/copilot-spaces/{space_number}/resources
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/users/USERNAME/copilot-spaces/SPACE_NUMBER/resources

Response

Status: 200
{ "resources": [ { "id": 1, "resource_type": "free_text", "copilot_chat_attachment_id": null, "metadata": { "name": "notes.txt", "text": "Some helpful notes" }, "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T00:00:00Z" } ] }

Create a resource for a Copilot Space for a user

Creates a new resource in a specific Copilot Space owned by a user. The authenticated user must have write permissions on the space.

The following resource types are supported: repository, github_file, free_text, github_issue, github_pull_request. The uploaded_text_file and media_content types are not supported via this endpoint.

For github_file resources, if a resource with the same repository, file path, and SHA already exists, the existing resource is returned with a 200 status.

OAuth app tokens and personal access tokens (classic) need the write:user scope to use this endpoint.

“Create a resource for a Copilot Space for a user”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”Create a resource for a Copilot Space for a user 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
username string 必须

The handle for the GitHub user account.

space_number integer 必须

The unique identifier of the Copilot Space.

主体参数
名称, 类型, 说明
resource_type string 必须

The type of resource to create.

可以是以下选项之一: repository, github_file, free_text, github_issue, github_pull_request

metadata object 必须

Resource-specific metadata.

“Create a resource for a Copilot Space for a user”的 HTTP 响应状态代码

状态代码说明
200

Duplicate github_file resource already exists

201

Resource created

403

Forbidden

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Get a resource for a Copilot Space for a user

Gets a specific resource attached to a Copilot Space owned by a user. The authenticated user must have appropriate permissions to view the space.

OAuth app tokens and personal access tokens (classic) need the read:user scope to use this endpoint.

“Get a resource for a Copilot Space for a user”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”Get a resource for a Copilot Space for a user 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
username string 必须

The handle for the GitHub user account.

space_number integer 必须

The unique identifier of the Copilot Space.

space_resource_id integer 必须

The unique identifier of the resource.

“Get a resource for a Copilot Space for a user”的 HTTP 响应状态代码

状态代码说明
200

OK

403

Forbidden

404

Resource not found

“Get a resource for a Copilot Space for a user”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

get/users/{username}/copilot-spaces/{space_number}/resources/{space_resource_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/users/USERNAME/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID

Response

Status: 200
{ "id": 1, "resource_type": "free_text", "copilot_chat_attachment_id": null, "metadata": { "name": "notes.txt", "text": "Some helpful notes" }, "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T00:00:00Z" }

Set a resource for a Copilot Space for a user

Updates the metadata of a resource in a specific Copilot Space owned by a user. The authenticated user must have write permissions on the space.

OAuth app tokens and personal access tokens (classic) need the write:user scope to use this endpoint.

“Set a resource for a Copilot Space for a user”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”Set a resource for a Copilot Space for a user 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
username string 必须

The handle for the GitHub user account.

space_number integer 必须

The unique identifier of the Copilot Space.

space_resource_id integer 必须

The unique identifier of the resource.

主体参数
名称, 类型, 说明
metadata object

Updated resource-specific metadata.

“Set a resource for a Copilot Space for a user”的 HTTP 响应状态代码

状态代码说明
200

OK

403

Forbidden

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

“Set a resource for a Copilot Space for a user”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

put/users/{username}/copilot-spaces/{space_number}/resources/{space_resource_id}
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/users/USERNAME/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID \ -d '{"metadata":{"name":"updated-notes.txt","text":"Updated content"}}'

Response

Status: 200
{ "id": 1, "resource_type": "free_text", "copilot_chat_attachment_id": null, "metadata": { "name": "updated-notes.txt", "text": "Updated content" }, "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T12:00:00Z" }

Delete a resource from a Copilot Space for a user

Deletes a resource from a specific Copilot Space owned by a user. The authenticated user must have write permissions on the space.

OAuth app tokens and personal access tokens (classic) need the write:user scope to use this endpoint.

“Delete a resource from a Copilot Space for a user”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”Delete a resource from a Copilot Space for a user 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
username string 必须

The handle for the GitHub user account.

space_number integer 必须

The unique identifier of the Copilot Space.

space_resource_id integer 必须

The unique identifier of the resource.

“Delete a resource from a Copilot Space for a user”的 HTTP 响应状态代码

状态代码说明
204

No Content

403

Forbidden

404

Resource not found

“Delete a resource from a Copilot Space for a user”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

delete/users/{username}/copilot-spaces/{space_number}/resources/{space_resource_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/users/USERNAME/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID

Response

Status: 204