Use the REST API to interact with Copilot Spaces resources.
Note
Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.
GET /orgs/{org}/copilot-spaces/{space_number}/resources
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.
Fine-grained tokens and GitHub App user access tokens must have been granted access to the organization that owns the space. They must also have been granted access to every repository referenced by resources in the space.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
space_number (integer) (required)
The unique identifier of the Copilot Space.
200 - OK
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/orgs/ORG/copilot-spaces/SPACE_NUMBER/resources
Response schema (Status: 200):
resources: required, array of Copilot Space Resource:
id: required, integerresource_type: required, string, enum: repository, github_file, free_text, github_issue, github_pull_request, media_content, uploaded_text_filecopilot_chat_attachment_id: integer or nullmetadata: required, object, additional properties allowedcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timePOST /orgs/{org}/copilot-spaces/{space_number}/resources
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.
Fine-grained tokens and GitHub App user access tokens must have been granted access to the organization that owns the space. They must also have been granted access to every repository referenced by resources in the space, including the resource being created.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
space_number (integer) (required)
The unique identifier of the Copilot Space.
resource_type (string) (required)
The type of resource to create.
Can be one of: repository, github_file, free_text, github_issue, github_pull_request
metadata (object) (required)
Resource-specific metadata.
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.
Request:
curl -L \
-X POST \
https://api.github.com/orgs/ORG/copilot-spaces/SPACE_NUMBER/resources \
-d '{
"resource_type": "free_text",
"metadata": {
"name": "notes.txt",
"text": "Some helpful notes"
}
}'
Response schema (Status: 201):
id: required, integerresource_type: required, string, enum: repository, github_file, free_text, github_issue, github_pull_request, media_content, uploaded_text_filecopilot_chat_attachment_id: integer or nullmetadata: required, object, additional properties allowedcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeRequest:
curl -L \
-X POST \
https://api.github.com/orgs/ORG/copilot-spaces/SPACE_NUMBER/resources \
-d '{
"resource_type": "repository",
"metadata": {
"repository_id": 42
}
}'
Response schema (Status: 201):
id: required, integerresource_type: required, string, enum: repository, github_file, free_text, github_issue, github_pull_request, media_content, uploaded_text_filecopilot_chat_attachment_id: integer or nullmetadata: required, object, additional properties allowedcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeRequest:
curl -L \
-X POST \
https://api.github.com/orgs/ORG/copilot-spaces/SPACE_NUMBER/resources \
-d '{
"resource_type": "github_file",
"metadata": {
"repository_id": 42,
"file_path": "README.md",
"sha": "abc123"
}
}'
Response schema (Status: 201):
id: required, integerresource_type: required, string, enum: repository, github_file, free_text, github_issue, github_pull_request, media_content, uploaded_text_filecopilot_chat_attachment_id: integer or nullmetadata: required, object, additional properties allowedcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeGET /orgs/{org}/copilot-spaces/{space_number}/resources/{space_resource_id}
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.
Fine-grained tokens and GitHub App user access tokens must have been granted access to the organization that owns the space. They must also have been granted access to every repository referenced by resources in the space.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
space_number (integer) (required)
The unique identifier of the Copilot Space.
space_resource_id (integer) (required)
The unique identifier of the resource.
200 - OK
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/orgs/ORG/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID
Response schema (Status: 200):
Same response schema as Create a resource for an organization Copilot Space.
PUT /orgs/{org}/copilot-spaces/{space_number}/resources/{space_resource_id}
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.
Fine-grained tokens and GitHub App user access tokens must have been granted access to the organization that owns the space. They must also have been granted access to every repository referenced by resources in the space, including the resource being updated.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
space_number (integer) (required)
The unique identifier of the Copilot Space.
space_resource_id (integer) (required)
The unique identifier of the resource.
metadata (object)200 - OK
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PUT \
https://api.github.com/orgs/ORG/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID \
-d '{
"metadata": {
"name": "updated-notes.txt",
"text": "Updated content"
}
}'
Response schema (Status: 200):
Same response schema as Create a resource for an organization Copilot Space.
DELETE /orgs/{org}/copilot-spaces/{space_number}/resources/{space_resource_id}
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.
Fine-grained tokens and GitHub App user access tokens must have been granted access to the organization that owns the space. They must also have been granted access to every repository referenced by resources in the space.
accept (string)application/vnd.github+json is recommended.org (string) (required)
The organization name. The name is not case sensitive.
space_number (integer) (required)
The unique identifier of the Copilot Space.
space_resource_id (integer) (required)
The unique identifier of the resource.
204 - No Content
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X DELETE \
https://api.github.com/orgs/ORG/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID
Response schema (Status: 204):
GET /users/{username}/copilot-spaces/{space_number}/resources
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.
accept (string)application/vnd.github+json is recommended.username (string) (required)
The handle for the GitHub user account.
space_number (integer) (required)
The unique identifier of the Copilot Space.
200 - OK
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/users/USERNAME/copilot-spaces/SPACE_NUMBER/resources
Response schema (Status: 200):
Same response schema as List resources for an organization Copilot Space.
POST /users/{username}/copilot-spaces/{space_number}/resources
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.
accept (string)application/vnd.github+json is recommended.username (string) (required)
The handle for the GitHub user account.
space_number (integer) (required)
The unique identifier of the Copilot Space.
resource_type (string) (required)
The type of resource to create.
Can be one of: repository, github_file, free_text, github_issue, github_pull_request
metadata (object) (required)
Resource-specific metadata.
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.
Request:
curl -L \
-X POST \
https://api.github.com/users/USERNAME/copilot-spaces/SPACE_NUMBER/resources \
-d '{
"resource_type": "free_text",
"metadata": {
"name": "notes.txt",
"text": "Some helpful notes"
}
}'
Response schema (Status: 201):
Same response schema as Create a resource for an organization Copilot Space.
Request:
curl -L \
-X POST \
https://api.github.com/users/USERNAME/copilot-spaces/SPACE_NUMBER/resources \
-d '{
"resource_type": "repository",
"metadata": {
"repository_id": 42
}
}'
Response schema (Status: 201):
Same response schema as Create a resource for an organization Copilot Space.
Request:
curl -L \
-X POST \
https://api.github.com/users/USERNAME/copilot-spaces/SPACE_NUMBER/resources \
-d '{
"resource_type": "github_file",
"metadata": {
"repository_id": 42,
"file_path": "README.md",
"sha": "abc123"
}
}'
Response schema (Status: 201):
Same response schema as Create a resource for an organization Copilot Space.
GET /users/{username}/copilot-spaces/{space_number}/resources/{space_resource_id}
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.
accept (string)application/vnd.github+json is recommended.username (string) (required)
The handle for the GitHub user account.
space_number (integer) (required)
The unique identifier of the Copilot Space.
space_resource_id (integer) (required)
The unique identifier of the resource.
200 - OK
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/users/USERNAME/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID
Response schema (Status: 200):
Same response schema as Create a resource for an organization Copilot Space.
PUT /users/{username}/copilot-spaces/{space_number}/resources/{space_resource_id}
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.
accept (string)application/vnd.github+json is recommended.username (string) (required)
The handle for the GitHub user account.
space_number (integer) (required)
The unique identifier of the Copilot Space.
space_resource_id (integer) (required)
The unique identifier of the resource.
metadata (object)200 - OK
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X PUT \
https://api.github.com/users/USERNAME/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID \
-d '{
"metadata": {
"name": "updated-notes.txt",
"text": "Updated content"
}
}'
Response schema (Status: 200):
Same response schema as Create a resource for an organization Copilot Space.
DELETE /users/{username}/copilot-spaces/{space_number}/resources/{space_resource_id}
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.
accept (string)application/vnd.github+json is recommended.username (string) (required)
The handle for the GitHub user account.
space_number (integer) (required)
The unique identifier of the Copilot Space.
space_resource_id (integer) (required)
The unique identifier of the resource.
204 - No Content
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X DELETE \
https://api.github.com/users/USERNAME/copilot-spaces/SPACE_NUMBER/resources/SPACE_RESOURCE_ID
Response schema (Status: 204):