Use the REST API to manage 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.
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.
accept (string)application/vnd.github+json is recommended.per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
200 - OK
401 - Requires authentication
403 - Forbidden
404 - Resource not found
500 - Internal Error
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/codespaces
Response schema (Status: 200):
total_count: required, integercodespaces: required, array of Codespace:
id: required, integer, format: int64name: required, stringdisplay_name: string or nullenvironment_id: required, string or nullowner: required, Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringbillable_owner: required, Simple User (see above)repository: required, Minimal Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringowner: required, Simple User (see above)private: required, booleanhtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringgit_url: stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringssh_url: stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringclone_url: stringmirror_url: string or nullhooks_url: required, string, format: urisvn_url: stringhomepage: string or nulllanguage: string or nullforks_count: integerstargazers_count: integerwatchers_count: integersize: integerdefault_branch: stringopen_issues_count: integeris_template: booleantopics: array of stringhas_issues: booleanhas_projects: booleanhas_wiki: booleanhas_pages: booleanhas_discussions: booleanhas_pull_requests: booleanpull_request_creation_policy: string, enum: all, collaborators_onlyarchived: booleandisabled: booleanvisibility: stringpushed_at: string or null, format: date-timecreated_at: string or null, format: date-timeupdated_at: string or null, format: date-timepermissions: object:
admin: booleanmaintain: booleanpush: booleantriage: booleanpull: booleanrole_name: stringtemp_clone_token: stringdelete_branch_on_merge: booleansubscribers_count: integernetwork_count: integercode_of_conduct: Code Of Conduct:
key: required, stringname: required, stringurl: required, string, format: uribody: stringhtml_url: required, string or null, format: urilicense: object or null:
key: stringname: stringspdx_id: stringurl: string or nullnode_id: stringforks: integeropen_issues: integerwatchers: integerallow_forking: booleanweb_commit_signoff_required: booleansecurity_and_analysis: object or null:
advanced_security: object:
status: string, enum: enabled, disabledcode_security: object:
status: string, enum: enabled, disableddependabot_security_updates: object:
status: string, enum: enabled, disabledsecret_scanning: object:
status: string, enum: enabled, disabledsecret_scanning_push_protection: object:
status: string, enum: enabled, disabledsecret_scanning_non_provider_patterns: object:
status: string, enum: enabled, disabledsecret_scanning_ai_detection: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_alert_dismissal: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_bypass: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_bypass_options: object:
reviewers: array of objectcustom_properties: object, additional properties allowedmachine: required, any of:
name: required, stringdisplay_name: required, stringoperating_system: required, stringstorage_in_bytes: required, integermemory_in_bytes: required, integercpus: required, integerprebuild_availability: required, string or null, enum: none, ready, in_progress, nulldevcontainer_path: string or nullprebuild: required, boolean or nullcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timelast_used_at: required, string, format: date-timestate: required, string, enum: Unknown, Created, Queued, Provisioning, Available, Awaiting, Unavailable, Deleted, Moved, Shutdown, Archived, Starting, ShuttingDown, Failed, Exporting, Updating, Rebuildingurl: required, string, format: urigit_status: required, object:
ahead: integerbehind: integerhas_unpushed_changes: booleanhas_uncommitted_changes: booleanref: stringlocation: required, string, enum: EastUs, SouthEastAsia, WestEurope, WestUs2idle_timeout_minutes: required, integer or nullweb_url: required, string, format: urimachines_url: required, string, format: uristart_url: required, string, format: uristop_url: required, string, format: uripublish_url: string or null, format: uripulls_url: required, string or null, format: urirecent_folders: required, array of stringruntime_constraints: object:
allowed_port_privacy_settings: array of string or nullpending_operation: boolean or nullpending_operation_disabled_reason: string or nullidle_timeout_notice: string or nullretention_period_minutes: integer or nullretention_expires_at: string or null, format: date-timelast_known_stop_notice: string or nullPOST /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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
ref (string)
Git ref (typically a branch name) for this codespace
location (string)
The requested location for a new codespace. Best efforts are made to respect this upon creation. Assigned by IP if not provided.
geo (string)
The geographic area for this codespace. If not specified, the value is assigned by IP. This property replaces location, which is closing down.
Can be one of: EuropeWest, SoutheastAsia, UsEast, UsWest
client_ip (string)
IP for location auto-detection when proxying a request
machine (string)
Machine type to use for this codespace
devcontainer_path (string)
Path to devcontainer.json config to use for this codespace
multi_repo_permissions_opt_out (boolean)
Whether to authorize requested permissions from devcontainer.json
working_directory (string)
Working directory for this codespace
idle_timeout_minutes (integer)
Time in minutes before codespace stops from inactivity
display_name (string)
Display name for this codespace
retention_period_minutes (integer)
Duration in minutes after codespace has gone idle in which it will be deleted. Must be integer minutes between 0 and 43200 (30 days).
201 - Response when the codespace was successfully created
202 - Response when the codespace creation partially failed but is being retried in the background
400 - Bad Request
401 - Requires authentication
403 - Forbidden
404 - Resource not found
503 - Service unavailable
Request:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/codespaces \
-d '{
"ref": "main",
"machine": "standardLinux32gb"
}'
Response schema (Status: 201):
id: required, integer, format: int64name: required, stringdisplay_name: string or nullenvironment_id: required, string or nullowner: required, Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringbillable_owner: required, Simple User (see above)repository: required, Minimal Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringowner: required, Simple User (see above)private: required, booleanhtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringgit_url: stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringssh_url: stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringclone_url: stringmirror_url: string or nullhooks_url: required, string, format: urisvn_url: stringhomepage: string or nulllanguage: string or nullforks_count: integerstargazers_count: integerwatchers_count: integersize: integerdefault_branch: stringopen_issues_count: integeris_template: booleantopics: array of stringhas_issues: booleanhas_projects: booleanhas_wiki: booleanhas_pages: booleanhas_discussions: booleanhas_pull_requests: booleanpull_request_creation_policy: string, enum: all, collaborators_onlyarchived: booleandisabled: booleanvisibility: stringpushed_at: string or null, format: date-timecreated_at: string or null, format: date-timeupdated_at: string or null, format: date-timepermissions: object:
admin: booleanmaintain: booleanpush: booleantriage: booleanpull: booleanrole_name: stringtemp_clone_token: stringdelete_branch_on_merge: booleansubscribers_count: integernetwork_count: integercode_of_conduct: Code Of Conduct:
key: required, stringname: required, stringurl: required, string, format: uribody: stringhtml_url: required, string or null, format: urilicense: object or null:
key: stringname: stringspdx_id: stringurl: string or nullnode_id: stringforks: integeropen_issues: integerwatchers: integerallow_forking: booleanweb_commit_signoff_required: booleansecurity_and_analysis: object or null:
advanced_security: object:
status: string, enum: enabled, disabledcode_security: object:
status: string, enum: enabled, disableddependabot_security_updates: object:
status: string, enum: enabled, disabledsecret_scanning: object:
status: string, enum: enabled, disabledsecret_scanning_push_protection: object:
status: string, enum: enabled, disabledsecret_scanning_non_provider_patterns: object:
status: string, enum: enabled, disabledsecret_scanning_ai_detection: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_alert_dismissal: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_bypass: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_bypass_options: object:
reviewers: array of objects:
reviewer_id: required, integerreviewer_type: required, string, enum: TEAM, ROLEmode: string, enum: ALWAYS, EXEMPT, default: "ALWAYS"custom_properties: object, additional properties allowedmachine: required, any of:
name: required, stringdisplay_name: required, stringoperating_system: required, stringstorage_in_bytes: required, integermemory_in_bytes: required, integercpus: required, integerprebuild_availability: required, string or null, enum: none, ready, in_progress, nulldevcontainer_path: string or nullprebuild: required, boolean or nullcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timelast_used_at: required, string, format: date-timestate: required, string, enum: Unknown, Created, Queued, Provisioning, Available, Awaiting, Unavailable, Deleted, Moved, Shutdown, Archived, Starting, ShuttingDown, Failed, Exporting, Updating, Rebuildingurl: required, string, format: urigit_status: required, object:
ahead: integerbehind: integerhas_unpushed_changes: booleanhas_uncommitted_changes: booleanref: stringlocation: required, string, enum: EastUs, SouthEastAsia, WestEurope, WestUs2idle_timeout_minutes: required, integer or nullweb_url: required, string, format: urimachines_url: required, string, format: uristart_url: required, string, format: uristop_url: required, string, format: uripublish_url: string or null, format: uripulls_url: required, string or null, format: urirecent_folders: required, array of stringruntime_constraints: object:
allowed_port_privacy_settings: array of string or nullpending_operation: boolean or nullpending_operation_disabled_reason: string or nullidle_timeout_notice: string or nullretention_period_minutes: integer or nullretention_expires_at: string or null, format: date-timelast_known_stop_notice: string or nullRequest:
curl -L \
-X POST \
https://api.github.com/repos/OWNER/REPO/codespaces \
-d '{
"ref": "main",
"machine": "standardLinux32gb"
}'
Response schema (Status: 202):
id: required, integer, format: int64name: required, stringdisplay_name: string or nullenvironment_id: required, string or nullowner: required, Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringbillable_owner: required, Simple User (see above)repository: required, Minimal Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringowner: required, Simple User (see above)private: required, booleanhtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringgit_url: stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringssh_url: stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringclone_url: stringmirror_url: string or nullhooks_url: required, string, format: urisvn_url: stringhomepage: string or nulllanguage: string or nullforks_count: integerstargazers_count: integerwatchers_count: integersize: integerdefault_branch: stringopen_issues_count: integeris_template: booleantopics: array of stringhas_issues: booleanhas_projects: booleanhas_wiki: booleanhas_pages: booleanhas_discussions: booleanhas_pull_requests: booleanpull_request_creation_policy: string, enum: all, collaborators_onlyarchived: booleandisabled: booleanvisibility: stringpushed_at: string or null, format: date-timecreated_at: string or null, format: date-timeupdated_at: string or null, format: date-timepermissions: object:
admin: booleanmaintain: booleanpush: booleantriage: booleanpull: booleanrole_name: stringtemp_clone_token: stringdelete_branch_on_merge: booleansubscribers_count: integernetwork_count: integercode_of_conduct: Code Of Conduct:
key: required, stringname: required, stringurl: required, string, format: uribody: stringhtml_url: required, string or null, format: urilicense: object or null:
key: stringname: stringspdx_id: stringurl: string or nullnode_id: stringforks: integeropen_issues: integerwatchers: integerallow_forking: booleanweb_commit_signoff_required: booleansecurity_and_analysis: object or null:
advanced_security: object:
status: string, enum: enabled, disabledcode_security: object:
status: string, enum: enabled, disableddependabot_security_updates: object:
status: string, enum: enabled, disabledsecret_scanning: object:
status: string, enum: enabled, disabledsecret_scanning_push_protection: object:
status: string, enum: enabled, disabledsecret_scanning_non_provider_patterns: object:
status: string, enum: enabled, disabledsecret_scanning_ai_detection: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_alert_dismissal: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_bypass: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_bypass_options: object:
reviewers: array of objects:
reviewer_id: required, integerreviewer_type: required, string, enum: TEAM, ROLEmode: string, enum: ALWAYS, EXEMPT, default: "ALWAYS"custom_properties: object, additional properties allowedmachine: required, any of:
name: required, stringdisplay_name: required, stringoperating_system: required, stringstorage_in_bytes: required, integermemory_in_bytes: required, integercpus: required, integerprebuild_availability: required, string or null, enum: none, ready, in_progress, nulldevcontainer_path: string or nullprebuild: required, boolean or nullcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timelast_used_at: required, string, format: date-timestate: required, string, enum: Unknown, Created, Queued, Provisioning, Available, Awaiting, Unavailable, Deleted, Moved, Shutdown, Archived, Starting, ShuttingDown, Failed, Exporting, Updating, Rebuildingurl: required, string, format: urigit_status: required, object:
ahead: integerbehind: integerhas_unpushed_changes: booleanhas_uncommitted_changes: booleanref: stringlocation: required, string, enum: EastUs, SouthEastAsia, WestEurope, WestUs2idle_timeout_minutes: required, integer or nullweb_url: required, string, format: urimachines_url: required, string, format: uristart_url: required, string, format: uristop_url: required, string, format: uripublish_url: string or null, format: uripulls_url: required, string or null, format: urirecent_folders: required, array of stringruntime_constraints: object:
allowed_port_privacy_settings: array of string or nullpending_operation: boolean or nullpending_operation_disabled_reason: string or nullidle_timeout_notice: string or nullretention_period_minutes: integer or nullretention_expires_at: string or null, format: date-timelast_known_stop_notice: string or nullGET /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.
accept (string)application/vnd.github+json is recommended.per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
200 - OK
400 - Bad Request
401 - Requires authentication
403 - Forbidden
404 - Resource not found
500 - Internal Error
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/codespaces/devcontainers
Response schema (Status: 200):
total_count: required, integerdevcontainers: required, array of objects:
path: required, stringname: stringdisplay_name: stringGET /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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
ref (string)
The branch or commit to check for a default devcontainer path. If not specified, the default branch will be checked.
client_ip (string)
An alternative IP for default location auto-detection, such as when proxying a request.
200 - Response when a user is able to create codespaces from the repository.
401 - Requires authentication
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/codespaces/new
Response schema (Status: 200):
billable_owner: Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringdefaults: object:
location: required, stringdevcontainer_path: required, string or nullGET /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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
ref (string) (required)
The 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_path (string) (required)
Path to the devcontainer.json configuration to use for the permission check.
200 - Response when the permission check is successful
401 - Requires authentication
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
503 - Service unavailable
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):
accepted: required, booleanPOST /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.
accept (string)application/vnd.github+json is recommended.owner (string) (required)
The account owner of the repository. The name is not case sensitive.
repo (string) (required)
The name of the repository without the .git extension. The name is not case sensitive.
pull_number (integer) (required)
The number that identifies the pull request.
location (string)
The requested location for a new codespace. Best efforts are made to respect this upon creation. Assigned by IP if not provided.
geo (string)
The geographic area for this codespace. If not specified, the value is assigned by IP. This property replaces location, which is closing down.
Can be one of: EuropeWest, SoutheastAsia, UsEast, UsWest
client_ip (string)
IP for location auto-detection when proxying a request
machine (string)
Machine type to use for this codespace
devcontainer_path (string)
Path to devcontainer.json config to use for this codespace
multi_repo_permissions_opt_out (boolean)
Whether to authorize requested permissions from devcontainer.json
working_directory (string)
Working directory for this codespace
idle_timeout_minutes (integer)
Time in minutes before codespace stops from inactivity
display_name (string)
Display name for this codespace
retention_period_minutes (integer)
Duration in minutes after codespace has gone idle in which it will be deleted. Must be integer minutes between 0 and 43200 (30 days).
201 - Response when the codespace was successfully created
202 - Response when the codespace creation partially failed but is being retried in the background
401 - Requires authentication
403 - Forbidden
404 - Resource not found
503 - Service unavailable
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.
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.
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.
accept (string)application/vnd.github+json is recommended.per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
repository_id (integer)
ID of the Repository to filter on
200 - OK
304 - Not modified
401 - Requires authentication
403 - Forbidden
404 - Resource not found
500 - Internal Error
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.
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.
accept (string)application/vnd.github+json is recommended.repository_id (integer) (required)
Repository id for this codespace
ref (string)
Git ref (typically a branch name) for this codespace
location (string)
The requested location for a new codespace. Best efforts are made to respect this upon creation. Assigned by IP if not provided.
geo (string)
The geographic area for this codespace. If not specified, the value is assigned by IP. This property replaces location, which is closing down.
Can be one of: EuropeWest, SoutheastAsia, UsEast, UsWest
client_ip (string)
IP for location auto-detection when proxying a request
machine (string)
Machine type to use for this codespace
devcontainer_path (string)
Path to devcontainer.json config to use for this codespace
multi_repo_permissions_opt_out (boolean)
Whether to authorize requested permissions from devcontainer.json
working_directory (string)
Working directory for this codespace
idle_timeout_minutes (integer)
Time in minutes before codespace stops from inactivity
display_name (string)
Display name for this codespace
retention_period_minutes (integer)
Duration in minutes after codespace has gone idle in which it will be deleted. Must be integer minutes between 0 and 43200 (30 days).
pull_request (object) (required)
Pull request number for this codespace
pull_request_number (integer) (required)repository_id (integer) (required)201 - Response when the codespace was successfully created
202 - Response when the codespace creation partially failed but is being retried in the background
401 - Requires authentication
403 - Forbidden
404 - Resource not found
503 - Service unavailable
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.
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 /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.
accept (string)application/vnd.github+json is recommended.codespace_name (string) (required)200 - OK
304 - Not modified
401 - Requires authentication
403 - Forbidden
404 - Resource not found
500 - Internal Error
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.
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.
accept (string)application/vnd.github+json is recommended.codespace_name (string) (required)machine (string)
A valid machine to transition this codespace to.
display_name (string)
Display name for this codespace
recent_folders (array of strings)
Recently opened folders inside the codespace. It is currently used by the clients to determine the folder path to load the codespace in.
200 - OK
401 - Requires authentication
403 - Forbidden
404 - Resource not found
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 /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.
accept (string)application/vnd.github+json is recommended.codespace_name (string) (required)202 - Accepted
304 - Not modified
401 - Requires authentication
403 - Forbidden
404 - Resource not found
500 - Internal Error
Request:
curl -L \
-X DELETE \
https://api.github.com/user/codespaces/CODESPACE_NAME
Response schema (Status: 202):
object
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.
accept (string)application/vnd.github+json is recommended.codespace_name (string) (required)202 - Accepted
401 - Requires authentication
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
500 - Internal Error
Request:
curl -L \
-X POST \
https://api.github.com/user/codespaces/CODESPACE_NAME/exports
Response schema (Status: 202):
state: string or nullcompleted_at: string or null, format: date-timebranch: string or nullsha: string or nullid: stringexport_url: stringhtml_url: string or nullGET /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.
accept (string)application/vnd.github+json is recommended.codespace_name (string) (required)
The name of the codespace.
export_id (string) (required)
The ID of the export operation, or latest. Currently only latest is currently supported.
200 - OK
404 - Resource not found
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.
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.
accept (string)application/vnd.github+json is recommended.codespace_name (string) (required)name (string)
A name for the new repository.
private (boolean)
Whether the new repository should be private.
Default: false
201 - Created
401 - Requires authentication
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
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):
id: required, integer, format: int64name: required, stringdisplay_name: string or nullenvironment_id: required, string or nullowner: required, Simple User:
name: string or nullemail: string or nulllogin: required, stringid: required, integer, format: int64node_id: required, stringavatar_url: required, string, format: urigravatar_id: required, string or nullurl: required, string, format: urihtml_url: required, string, format: urifollowers_url: required, string, format: urifollowing_url: required, stringgists_url: required, stringstarred_url: required, stringsubscriptions_url: required, string, format: uriorganizations_url: required, string, format: urirepos_url: required, string, format: urievents_url: required, stringreceived_events_url: required, string, format: uritype: required, stringsite_admin: required, booleanstarred_at: stringuser_view_type: stringbillable_owner: required, Simple User (see above)repository: required, Full Repository:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringowner: required, Simple User (see above)private: required, booleanhtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringgit_url: required, stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringssh_url: required, stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringclone_url: required, stringmirror_url: required, string or null, format: urihooks_url: required, string, format: urisvn_url: required, string, format: urihomepage: required, string or null, format: urilanguage: required, string or nullforks_count: required, integerstargazers_count: required, integerwatchers_count: required, integersize: required, integerdefault_branch: required, stringopen_issues_count: required, integeris_template: booleantopics: array of stringhas_issues: required, booleanhas_projects: required, booleanhas_wiki: required, booleanhas_pages: required, booleanhas_discussions: required, booleanhas_pull_requests: booleanpull_request_creation_policy: string, enum: all, collaborators_onlyarchived: required, booleandisabled: required, booleanvisibility: stringpushed_at: required, string, format: date-timecreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timepermissions: object:
admin: required, booleanmaintain: booleanpush: required, booleantriage: booleanpull: required, booleanallow_rebase_merge: booleantemplate_repository: any of:
id: required, integer, format: int64node_id: required, stringname: required, stringfull_name: required, stringlicense: required, any of:
key: required, stringname: required, stringurl: required, string or null, format: urispdx_id: required, string or nullnode_id: required, stringhtml_url: string, format: uriforks: required, integerpermissions: object:
admin: required, booleanpull: required, booleantriage: booleanpush: required, booleanmaintain: booleanowner: required, Simple User (see above)private: required, boolean, default: falsehtml_url: required, string, format: uridescription: required, string or nullfork: required, booleanurl: required, string, format: uriarchive_url: required, stringassignees_url: required, stringblobs_url: required, stringbranches_url: required, stringcollaborators_url: required, stringcomments_url: required, stringcommits_url: required, stringcompare_url: required, stringcontents_url: required, stringcontributors_url: required, string, format: urideployments_url: required, string, format: uridownloads_url: required, string, format: urievents_url: required, string, format: uriforks_url: required, string, format: urigit_commits_url: required, stringgit_refs_url: required, stringgit_tags_url: required, stringgit_url: required, stringissue_comment_url: required, stringissue_events_url: required, stringissues_url: required, stringkeys_url: required, stringlabels_url: required, stringlanguages_url: required, string, format: urimerges_url: required, string, format: urimilestones_url: required, stringnotifications_url: required, stringpulls_url: required, stringreleases_url: required, stringssh_url: required, stringstargazers_url: required, string, format: uristatuses_url: required, stringsubscribers_url: required, string, format: urisubscription_url: required, string, format: uritags_url: required, string, format: uriteams_url: required, string, format: uritrees_url: required, stringclone_url: required, stringmirror_url: required, string or null, format: urihooks_url: required, string, format: urisvn_url: required, string, format: urihomepage: required, string or null, format: urilanguage: required, string or nullforks_count: required, integerstargazers_count: required, integerwatchers_count: required, integersize: required, integerdefault_branch: required, stringopen_issues_count: required, integeris_template: boolean, default: falsetopics: array of stringhas_issues: required, boolean, default: truehas_projects: required, boolean, default: truehas_wiki: required, boolean, default: truehas_pages: required, booleanhas_discussions: boolean, default: falsehas_pull_requests: boolean, default: truepull_request_creation_policy: string, enum: all, collaborators_onlyarchived: required, boolean, default: falsedisabled: required, booleanvisibility: string, default: "public"pushed_at: required, string or null, format: date-timecreated_at: required, string or null, format: date-timeupdated_at: required, string or null, format: date-timeallow_rebase_merge: boolean, default: truetemp_clone_token: stringallow_squash_merge: boolean, default: trueallow_auto_merge: boolean, default: falsedelete_branch_on_merge: boolean, default: falseallow_update_branch: boolean, default: falsesquash_merge_commit_title: string, enum: PR_TITLE, COMMIT_OR_PR_TITLEsquash_merge_commit_message: string, enum: PR_BODY, COMMIT_MESSAGES, BLANKmerge_commit_title: string, enum: PR_TITLE, MERGE_MESSAGEmerge_commit_message: string, enum: PR_BODY, PR_TITLE, BLANKallow_merge_commit: boolean, default: trueallow_forking: booleanweb_commit_signoff_required: boolean, default: falseopen_issues: required, integerwatchers: required, integerstarred_at: stringanonymous_access_enabled: booleancode_search_index_status: object:
lexical_search_ok: booleanlexical_commit_sha: stringtemp_clone_token: string or nullallow_squash_merge: booleanallow_auto_merge: booleandelete_branch_on_merge: booleanallow_merge_commit: booleanallow_update_branch: booleansquash_merge_commit_title: string, enum: PR_TITLE, COMMIT_OR_PR_TITLEsquash_merge_commit_message: string, enum: PR_BODY, COMMIT_MESSAGES, BLANKmerge_commit_title: string, enum: PR_TITLE, MERGE_MESSAGEmerge_commit_message: string, enum: PR_BODY, PR_TITLE, BLANKallow_forking: booleanweb_commit_signoff_required: booleansubscribers_count: required, integernetwork_count: required, integerlicense: required, any of:
organization: any of:
parent: Repository (see above)source: Repository (see above)forks: required, integermaster_branch: stringopen_issues: required, integerwatchers: required, integeranonymous_access_enabled: boolean, default: truecode_of_conduct: Code Of Conduct Simple:
url: required, string, format: urikey: required, stringname: required, stringhtml_url: required, string or null, format: urisecurity_and_analysis: object or null:
advanced_security: object:
status: string, enum: enabled, disabledcode_security: object:
status: string, enum: enabled, disableddependabot_security_updates: object:
status: string, enum: enabled, disabledsecret_scanning: object:
status: string, enum: enabled, disabledsecret_scanning_push_protection: object:
status: string, enum: enabled, disabledsecret_scanning_non_provider_patterns: object:
status: string, enum: enabled, disabledsecret_scanning_ai_detection: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_alert_dismissal: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_bypass: object:
status: string, enum: enabled, disabledsecret_scanning_delegated_bypass_options: object:
reviewers: array of objects:
reviewer_id: required, integerreviewer_type: required, string, enum: TEAM, ROLEmode: string, enum: ALWAYS, EXEMPT, default: "ALWAYS"custom_properties: object, additional properties allowedmachine: required, any of:
name: required, stringdisplay_name: required, stringoperating_system: required, stringstorage_in_bytes: required, integermemory_in_bytes: required, integercpus: required, integerprebuild_availability: required, string or null, enum: none, ready, in_progress, nulldevcontainer_path: string or nullprebuild: required, boolean or nullcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timelast_used_at: required, string, format: date-timestate: required, string, enum: Unknown, Created, Queued, Provisioning, Available, Awaiting, Unavailable, Deleted, Moved, Shutdown, Archived, Starting, ShuttingDown, Failed, Exporting, Updating, Rebuildingurl: required, string, format: urigit_status: required, object:
ahead: integerbehind: integerhas_unpushed_changes: booleanhas_uncommitted_changes: booleanref: stringlocation: required, string, enum: EastUs, SouthEastAsia, WestEurope, WestUs2idle_timeout_minutes: required, integer or nullweb_url: required, string, format: urimachines_url: required, string, format: uristart_url: required, string, format: uristop_url: required, string, format: uripublish_url: string or null, format: uripulls_url: required, string or null, format: urirecent_folders: required, array of stringruntime_constraints: object:
allowed_port_privacy_settings: array of string or nullpending_operation: boolean or nullpending_operation_disabled_reason: string or nullidle_timeout_notice: string or nullretention_period_minutes: integer or nullretention_expires_at: string or null, format: date-timePOST /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.
accept (string)application/vnd.github+json is recommended.codespace_name (string) (required)200 - OK
304 - Not modified
400 - Bad Request
401 - Requires authentication
402 - Payment required
403 - Forbidden
404 - Resource not found
409 - Conflict
500 - Internal Error
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.
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.
accept (string)application/vnd.github+json is recommended.codespace_name (string) (required)200 - OK
401 - Requires authentication
403 - Forbidden
404 - Resource not found
500 - Internal Error
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.