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.
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”The handle for the GitHub user account.
The unique identifier of the Copilot Space.
Request Body required
Section titled “ Request Body required ”object
The type of resource to create.
Resource-specific metadata.
object
Examples
{ "resource_type": "free_text", "metadata": { "name": "notes.txt", "text": "Some helpful notes" }}{ "resource_type": "repository", "metadata": { "repository_id": 42 }}{ "resource_type": "github_file", "metadata": { "repository_id": 42, "file_path": "README.md", "sha": "abc123" }}Responses
Section titled “ Responses ”Duplicate github_file resource already exists
A resource attached to a Copilot Space.
object
The unique identifier of the resource.
The type of the resource.
The ID of the associated chat attachment, if any.
Resource-specific metadata. The keys and values depend on the resource type.
object
The date and time the resource was created.
The date and time the resource was last updated.
Examples
{ "id": 1, "resource_type": "github_file", "copilot_chat_attachment_id": null, "metadata": { "repository_id": 42, "file_path": "README.md", "sha": "abc123" }, "created_at": "2025-01-01T00:00:00Z", "updated_at": "2025-01-01T00:00:00Z"}Resource created
A resource attached to a Copilot Space.
object
The unique identifier of the resource.
The type of the resource.
The ID of the associated chat attachment, if any.
Resource-specific metadata. The keys and values depend on the resource type.
object
The date and time the resource was created.
The date and time the resource was last updated.
Examples
{ "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"}Forbidden
Basic Error
object
Example generated
{ "message": "example", "documentation_url": "example", "url": "example", "status": "example"}Resource not found
Basic Error
object
Example generated
{ "message": "example", "documentation_url": "example", "url": "example", "status": "example"}Validation failed, or the endpoint has been spammed.
Validation Error
object
object
Example generated
{ "message": "example", "documentation_url": "example", "errors": [ { "resource": "example", "field": "example", "message": "example", "code": "example", "index": 1, "value": [ "example" ] } ]}