← All tags

Codespaces API Reference

Endpoints to manage Codespaces using the REST API.

48 endpoints tagged codespaces, each listing its parameters and possible responses. Search or scroll the index below to jump to a specific endpoint.

No endpoints match your search.

List codespaces for the organization

GET /orgs/{org}/codespaces

Lists the codespaces associated to a specified organization.

Parameters

NameInRequiredDescription
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
orgpathyesThe organization name. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

Manage access control for organization codespaces

PUT /orgs/{org}/codespaces/access

Sets which users can access codespaces in an organization. This is synonymous with granting or revoking codespaces access permissions for users according to the visibility.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Response when successfully modifying permissions.no
304Not modifiedno
400Users are neither members nor collaborators of this organization.no
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes
500Internal Erroryes

Add users to Codespaces access for an organization

POST /orgs/{org}/codespaces/access/selected_users

Codespaces for the specified users will be billed to the organization.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Response when successfully modifying permissions.no
304Not modifiedno
400Users are neither members nor collaborators of this organization.no
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes
500Internal Erroryes

Remove users from Codespaces access for an organization

DELETE /orgs/{org}/codespaces/access/selected_users

Codespaces for the specified users will no longer be billed to the organization.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Response when successfully modifying permissions.no
304Not modifiedno
400Users are neither members nor collaborators of this organization.no
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes
500Internal Erroryes

List organization secrets

GET /orgs/{org}/codespaces/secrets

Lists all Codespaces development environment secrets available at the organization-level without revealing their encrypted

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Get an organization public key

GET /orgs/{org}/codespaces/secrets/public-key

Gets a public key for an organization, which is required in order to encrypt secrets. You need to encrypt the value of a secret before you can create or update secrets.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes

Get an organization secret

GET /orgs/{org}/codespaces/secrets/{secret_name}

Gets an organization development environment secret without revealing its encrypted value.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
200Responseyes

Create or update an organization secret

PUT /orgs/{org}/codespaces/secrets/{secret_name}

Creates or updates an organization development environment secret with an encrypted value. Encrypt your secret using

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
201Response when creating a secretyes
204Response when updating a secretno
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

Delete an organization secret

DELETE /orgs/{org}/codespaces/secrets/{secret_name}

Deletes an organization development environment secret using the secret name.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes

List selected repositories for an organization secret

GET /orgs/{org}/codespaces/secrets/{secret_name}/repositories

Lists all repositories that have been selected when the visibility

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
secret_namepathyesThe name of the secret.
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Set selected repositories for an organization secret

PUT /orgs/{org}/codespaces/secrets/{secret_name}/repositories

Replaces all repositories for an organization development environment secret when the visibility

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes
409Conflict when visibility type not set to selectedno

Add selected repository to an organization secret

PUT /orgs/{org}/codespaces/secrets/{secret_name}/repositories/{repository_id}

Adds a repository to an organization development environment secret when the visibility for repository access is set to selected. The visibility is set when you Create or update an organization secret.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
secret_namepathyesThe name of the secret.
repository_idpathyes

Responses

StatusDescriptionHas JSON body
204No Content when repository was added to the selected listno
404Resource not foundyes
409Conflict when visibility type is not set to selectedno
422Validation failed, or the endpoint has been spammed.yes

Remove selected repository from an organization secret

DELETE /orgs/{org}/codespaces/secrets/{secret_name}/repositories/{repository_id}

Removes a repository from an organization development environment secret when the visibility

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
secret_namepathyesThe name of the secret.
repository_idpathyes

Responses

StatusDescriptionHas JSON body
204Response when repository was removed from the selected listno
404Resource not foundyes
409Conflict when visibility type not set to selectedno
422Validation failed, or the endpoint has been spammed.yes

List codespaces for a user in organization

GET /orgs/{org}/members/{username}/codespaces

Lists the codespaces that a member of an organization has for repositories in that organization.

Parameters

NameInRequiredDescription
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
orgpathyesThe organization name. The name is not case sensitive.
usernamepathyesThe handle for the GitHub user account.

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

Delete a codespace from the organization

DELETE /orgs/{org}/members/{username}/codespaces/{codespace_name}

Deletes a user's codespace.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
usernamepathyesThe handle for the GitHub user account.
codespace_namepathyesThe name of the codespace.

Responses

StatusDescriptionHas JSON body
202Acceptedyes
304Not modifiedno
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

Stop a codespace for an organization user

POST /orgs/{org}/members/{username}/codespaces/{codespace_name}/stop

Stops a user's codespace.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
usernamepathyesThe handle for the GitHub user account.
codespace_namepathyesThe name of the codespace.

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

List codespaces in a repository for the authenticated user

GET /repos/{owner}/{repo}/codespaces

Lists the codespaces associated to a specified repository and the authenticated user.

Parameters

NameInRequiredDescription
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

Create a codespace in a repository

POST /repos/{owner}/{repo}/codespaces

Creates a codespace owned by the authenticated user in the specified repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Response when the codespace was successfully createdyes
202Response when the codespace creation partially failed but is being retried in the backgroundyes
400Bad Requestyes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes
503Service unavailableyes

List devcontainer configurations in a repository for the authenticated user

GET /repos/{owner}/{repo}/codespaces/devcontainers

Lists the devcontainer.json files associated with a specified repository and the authenticated user. These files

Parameters

NameInRequiredDescription
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
500Internal Erroryes
400Bad Requestyes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

List available machine types for a repository

GET /repos/{owner}/{repo}/codespaces/machines

List the machine types available for a given repository based on its configuration.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
locationquerynoThe location to check for available machines. Assigned by IP if not provided.
client_ipquerynoIP for location auto-detection when proxying a request
refquerynoThe branch or commit to check for prebuild availability and devcontainer restrictions.

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

Get default attributes for a codespace

GET /repos/{owner}/{repo}/codespaces/new

Gets the default attributes for codespaces created by the user with the repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
refquerynoThe branch or commit to check for a default devcontainer path. If not specified, the default branch will be checked.
client_ipquerynoAn alternative IP for default location auto-detection, such as when proxying a request.

Responses

StatusDescriptionHas JSON body
200Response when a user is able to create codespaces from the repository.yes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

Check if permissions defined by a devcontainer have been accepted by the authenticated user

GET /repos/{owner}/{repo}/codespaces/permissions_check

Checks whether the permissions defined by a given devcontainer configuration have been accepted by the authenticated user.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
refqueryyesThe git reference that points to the location of the devcontainer configuration to use for the permission check. The value of ref will typically be a branch name (heads/BRANCH_NAME). For more information, see "Git References" in the Git documentation.
devcontainer_pathqueryyesPath to the devcontainer.json configuration to use for the permission check.

Responses

StatusDescriptionHas JSON body
200Response when the permission check is successfulyes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes
503Service unavailableyes

List repository secrets

GET /repos/{owner}/{repo}/codespaces/secrets

Lists all development environment secrets available in a repository without revealing their encrypted

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Get a repository public key

GET /repos/{owner}/{repo}/codespaces/secrets/public-key

Gets your public key, which you need to encrypt secrets. You need to

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes

Get a repository secret

GET /repos/{owner}/{repo}/codespaces/secrets/{secret_name}

Gets a single repository development environment secret without revealing its encrypted value.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
200Responseyes

Create or update a repository secret

PUT /repos/{owner}/{repo}/codespaces/secrets/{secret_name}

Creates or updates a repository development environment secret with an encrypted value. Encrypt your secret using

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
201Response when creating a secretyes
204Response when updating a secretno

Delete a repository secret

DELETE /repos/{owner}/{repo}/codespaces/secrets/{secret_name}

Deletes a development environment secret in a repository using the secret name.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
204Responseno

Create a codespace from a pull request

POST /repos/{owner}/{repo}/pulls/{pull_number}/codespaces

Creates a codespace owned by the authenticated user for the specified pull request.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
pull_numberpathyesThe number that identifies the pull request.

Responses

StatusDescriptionHas JSON body
201Response when the codespace was successfully createdyes
202Response when the codespace creation partially failed but is being retried in the backgroundyes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes
503Service unavailableyes

List codespaces for the authenticated user

GET /user/codespaces

Lists the authenticated user's codespaces.

Parameters

NameInRequiredDescription
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
repository_idquerynoID of the Repository to filter on

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

Create a codespace for the authenticated user

POST /user/codespaces

Creates a new codespace, owned by the authenticated user.

Parameters

No parameters.

Responses

StatusDescriptionHas JSON body
201Response when the codespace was successfully createdyes
202Response when the codespace creation partially failed but is being retried in the backgroundyes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes
503Service unavailableyes

List secrets for the authenticated user

GET /user/codespaces/secrets

Lists all development environment secrets available for a user's codespaces without revealing their

Parameters

NameInRequiredDescription
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Get public key for the authenticated user

GET /user/codespaces/secrets/public-key

Gets your public key, which you need to encrypt secrets. You need to encrypt a secret before you can create or update secrets.

Parameters

No parameters.

Responses

StatusDescriptionHas JSON body
200Responseyes

Get a secret for the authenticated user

GET /user/codespaces/secrets/{secret_name}

Gets a development environment secret available to a user's codespaces without revealing its encrypted value.

Parameters

NameInRequiredDescription
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
200Responseyes

Create or update a secret for the authenticated user

PUT /user/codespaces/secrets/{secret_name}

Creates or updates a development environment secret for a user's codespace with an encrypted value. Encrypt your secret using

Parameters

NameInRequiredDescription
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
201Response after successfully creating a secretyes
204Response after successfully updating a secretno
422Validation failed, or the endpoint has been spammed.yes
404Resource not foundyes

Delete a secret for the authenticated user

DELETE /user/codespaces/secrets/{secret_name}

Deletes a development environment secret from a user's codespaces using the secret name. Deleting the secret will remove access from all codespaces that were allowed to access the secret.

Parameters

NameInRequiredDescription
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
204Responseno

List selected repositories for a user secret

GET /user/codespaces/secrets/{secret_name}/repositories

List the repositories that have been granted the ability to use a user's development environment secret.

Parameters

NameInRequiredDescription
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
200Responseyes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes
500Internal Erroryes

Set selected repositories for a user secret

PUT /user/codespaces/secrets/{secret_name}/repositories

Select the repositories that will use a user's development environment secret.

Parameters

NameInRequiredDescription
secret_namepathyesThe name of the secret.

Responses

StatusDescriptionHas JSON body
204No Content when repositories were added to the selected listno
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes
500Internal Erroryes

Add a selected repository to a user secret

PUT /user/codespaces/secrets/{secret_name}/repositories/{repository_id}

Adds a repository to the selected repositories for a user's development environment secret.

Parameters

NameInRequiredDescription
secret_namepathyesThe name of the secret.
repository_idpathyes

Responses

StatusDescriptionHas JSON body
204No Content when repository was added to the selected listno
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes
500Internal Erroryes

Remove a selected repository from a user secret

DELETE /user/codespaces/secrets/{secret_name}/repositories/{repository_id}

Removes a repository from the selected repositories for a user's development environment secret.

Parameters

NameInRequiredDescription
secret_namepathyesThe name of the secret.
repository_idpathyes

Responses

StatusDescriptionHas JSON body
204No Content when repository was removed from the selected listno
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes
500Internal Erroryes

Get a codespace for the authenticated user

GET /user/codespaces/{codespace_name}

Gets information about a user's codespace.

Parameters

NameInRequiredDescription
codespace_namepathyesThe name of the codespace.

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

Update a codespace for the authenticated user

PATCH /user/codespaces/{codespace_name}

Updates a codespace owned by the authenticated user. Currently only the codespace's machine type and recent folders can be modified using this endpoint.

Parameters

NameInRequiredDescription
codespace_namepathyesThe name of the codespace.

Responses

StatusDescriptionHas JSON body
200Responseyes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

Delete a codespace for the authenticated user

DELETE /user/codespaces/{codespace_name}

Deletes a user's codespace.

Parameters

NameInRequiredDescription
codespace_namepathyesThe name of the codespace.

Responses

StatusDescriptionHas JSON body
202Acceptedyes
304Not modifiedno
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

Export a codespace for the authenticated user

POST /user/codespaces/{codespace_name}/exports

Triggers an export of the specified codespace and returns a URL and ID where the status of the export can be monitored.

Parameters

NameInRequiredDescription
codespace_namepathyesThe name of the codespace.

Responses

StatusDescriptionHas JSON body
202Responseyes
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

Get details about a codespace export

GET /user/codespaces/{codespace_name}/exports/{export_id}

Gets information about an export of a codespace.

Parameters

NameInRequiredDescription
codespace_namepathyesThe name of the codespace.
export_idpathyesThe ID of the export operation, or latest. Currently only latest is currently supported.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

List machine types for a codespace

GET /user/codespaces/{codespace_name}/machines

List the machine types a codespace can transition to use.

Parameters

NameInRequiredDescription
codespace_namepathyesThe name of the codespace.

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes

Create a repository from an unpublished codespace

POST /user/codespaces/{codespace_name}/publish

Publishes an unpublished codespace, creating a new repository and assigning it to the codespace.

Parameters

NameInRequiredDescription
codespace_namepathyesThe name of the codespace.

Responses

StatusDescriptionHas JSON body
201Responseyes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

Start a codespace for the authenticated user

POST /user/codespaces/{codespace_name}/start

Starts a user's codespace.

Parameters

NameInRequiredDescription
codespace_namepathyesThe name of the codespace.

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
500Internal Erroryes
400Bad Requestyes
401Requires authenticationyes
402Payment requiredyes
403Forbiddenyes
404Resource not foundyes
409Conflictyes

Stop a codespace for the authenticated user

POST /user/codespaces/{codespace_name}/stop

Stops a user's codespace.

Parameters

NameInRequiredDescription
codespace_namepathyesThe name of the codespace.

Responses

StatusDescriptionHas JSON body
200Responseyes
500Internal Erroryes
401Requires authenticationyes
403Forbiddenyes
404Resource not foundyes