Skip to content

Create a resource for an organization Copilot Space

POST
/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.

API method documentation

org
required
string

The organization name. The name is not case sensitive.

space_number
required
integer

The unique identifier of the Copilot Space.

Media type application/json
object
resource_type
required

The type of resource to create.

string
Allowed values: repository github_file free_text github_issue github_pull_request
metadata
required

Resource-specific metadata.

object
key
additional properties
any
Examples
{
"resource_type": "free_text",
"metadata": {
"name": "notes.txt",
"text": "Some helpful notes"
}
}

Duplicate github_file resource already exists

Media type application/json
Copilot Space Resource

A resource attached to a Copilot Space.

object
id
required

The unique identifier of the resource.

integer
resource_type
required

The type of the resource.

string
Allowed values: repository github_file free_text github_issue github_pull_request media_content uploaded_text_file
copilot_chat_attachment_id

The ID of the associated chat attachment, if any.

integer
nullable
metadata
required

Resource-specific metadata. The keys and values depend on the resource type.

object
key
additional properties
any
created_at
required

The date and time the resource was created.

string format: date-time
updated_at
required

The date and time the resource was last updated.

string format: date-time
Examples
Example default
{
"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

Media type application/json
Copilot Space Resource

A resource attached to a Copilot Space.

object
id
required

The unique identifier of the resource.

integer
resource_type
required

The type of the resource.

string
Allowed values: repository github_file free_text github_issue github_pull_request media_content uploaded_text_file
copilot_chat_attachment_id

The ID of the associated chat attachment, if any.

integer
nullable
metadata
required

Resource-specific metadata. The keys and values depend on the resource type.

object
key
additional properties
any
created_at
required

The date and time the resource was created.

string format: date-time
updated_at
required

The date and time the resource was last updated.

string format: date-time
Examples
Example default
{
"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

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Resource not found

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Validation failed, or the endpoint has been spammed.

Media type application/json
Validation Error

Validation Error

object
message
required
string
documentation_url
required
string
errors
Array<object>
object
resource
string
field
string
message
string
code
required
string
index
integer
value
One of:
string
nullable
Example generated
{
"message": "example",
"documentation_url": "example",
"errors": [
{
"resource": "example",
"field": "example",
"message": "example",
"code": "example",
"index": 1,
"value": [
"example"
]
}
]
}