REST API endpoints for Codespaces

Use the REST API to manage GitHub Codespaces.

About GitHub Codespaces

You can manage Codespaces using the REST API. These endpoints are available for authenticated users, OAuth apps, and GitHub Apps. For more information, see Codespaces documentation.

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.

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.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/codespaces

Response schema (Status: 200):

Create a codespace in a repository

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

Creates a codespace owned by the authenticated user in the specified repository.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example 1: Status Code 201

Request:

curl -L \
  -X POST \
  https://api.github.com/repos/OWNER/REPO/codespaces \
  -d '{
  "ref": "main",
  "machine": "standardLinux32gb"
}'

Response schema (Status: 201):

Example 2: Status Code 202

Request:

curl -L \
  -X POST \
  https://api.github.com/repos/OWNER/REPO/codespaces \
  -d '{
  "ref": "main",
  "machine": "standardLinux32gb"
}'

Response schema (Status: 202):

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
specify launchpoint configurations for codespaces created within the repository.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/codespaces/devcontainers

Response schema (Status: 200):

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.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/codespaces/new

Response schema (Status: 200):

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.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  "https://api.github.com/repos/OWNER/REPO/codespaces/permissions_check?ref=REF&devcontainer_path=DEVCONTAINER_PATH"

Response schema (Status: 200):

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.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example 1: Status Code 201

Request:

curl -L \
  -X POST \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/codespaces \
  -d '{
  "repository_id": 1,
  "ref": "main"
}'

Response schema (Status: 201):

Same response schema as Create a codespace in a repository.

Example 2: Status Code 202

Request:

curl -L \
  -X POST \
  https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER/codespaces \
  -d '{
  "repository_id": 1,
  "ref": "main"
}'

Response schema (Status: 202):

Same response schema as Create a codespace in a repository.

List codespaces for the authenticated user

GET /user/codespaces

Lists the authenticated user's codespaces.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/user/codespaces

Response schema (Status: 200):

Same response schema as List codespaces in a repository for the authenticated user.

Create a codespace for the authenticated user

POST /user/codespaces

Creates a new codespace, owned by the authenticated user.
This endpoint requires either a repository_id OR a pull_request but not both.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Body parameters

HTTP response status codes

Code examples

Example 1: Status Code 201

Request:

curl -L \
  -X POST \
  https://api.github.com/user/codespaces \
  -d '{
  "repository_id": 1,
  "ref": "main",
  "geo": "UsWest"
}'

Response schema (Status: 201):

Same response schema as Create a codespace in a repository.

Example 2: Status Code 202

Request:

curl -L \
  -X POST \
  https://api.github.com/user/codespaces \
  -d '{
  "repository_id": 1,
  "ref": "main",
  "geo": "UsWest"
}'

Response schema (Status: 202):

Same response schema as Create a codespace in a repository.

Get a codespace for the authenticated user

GET /user/codespaces/{codespace_name}

Gets information about a user's codespace.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/user/codespaces/CODESPACE_NAME

Response schema (Status: 200):

Same response schema as Create a codespace in a repository.

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.
If you specify a new machine type it will be applied the next time your codespace is started.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X PATCH \
  https://api.github.com/user/codespaces/CODESPACE_NAME \
  -d '{
  "machine": "standardLinux"
}'

Response schema (Status: 200):

Same response schema as Create a codespace in a repository.

Delete a codespace for the authenticated user

DELETE /user/codespaces/{codespace_name}

Deletes a user's codespace.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/user/codespaces/CODESPACE_NAME

Response schema (Status: 202):

object

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.
If changes cannot be pushed to the codespace's repository, they will be pushed to a new or previously-existing fork instead.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X POST \
  https://api.github.com/user/codespaces/CODESPACE_NAME/exports

Response schema (Status: 202):

Get details about a codespace export

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

Gets information about an export of a codespace.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/user/codespaces/CODESPACE_NAME/exports/EXPORT_ID

Response schema (Status: 200):

Same response schema as Export a codespace for the authenticated user.

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.
The codespace's token is granted write permissions to the repository, allowing the user to push their changes.
This will fail for a codespace that is already published, meaning it has an associated repository.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X POST \
  https://api.github.com/user/codespaces/CODESPACE_NAME/publish \
  -d '{
  "repository": "monalisa-octocat-hello-world-g4wpq6h95q",
  "private": false
}'

Response schema (Status: 201):

Start a codespace for the authenticated user

POST /user/codespaces/{codespace_name}/start

Starts a user's codespace.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X POST \
  https://api.github.com/user/codespaces/CODESPACE_NAME/start

Response schema (Status: 200):

Same response schema as Create a codespace in a repository.

Stop a codespace for the authenticated user

POST /user/codespaces/{codespace_name}/stop

Stops a user's codespace.
OAuth app tokens and personal access tokens (classic) need the codespace scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X POST \
  https://api.github.com/user/codespaces/CODESPACE_NAME/stop

Response schema (Status: 200):

Same response schema as Create a codespace in a repository.