Skip to content

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.

API method documentation

owner
required
string

The account owner of the repository. The name is not case sensitive.

repo
required
string

The name of the repository without the .git extension. The name is not case sensitive.

pull_number
required
integer

The number that identifies the pull request.

Media type application/json
object
location

The requested location for a new codespace. Best efforts are made to respect this upon creation. Assigned by IP if not provided.

string
geo

The geographic area for this codespace. If not specified, the value is assigned by IP. This property replaces location, which is closing down.

string
Allowed values: EuropeWest SoutheastAsia UsEast UsWest
client_ip

IP for location auto-detection when proxying a request

string
machine

Machine type to use for this codespace

string
devcontainer_path

Path to devcontainer.json config to use for this codespace

string
multi_repo_permissions_opt_out

Whether to authorize requested permissions from devcontainer.json

boolean
working_directory

Working directory for this codespace

string
idle_timeout_minutes

Time in minutes before codespace stops from inactivity

integer
display_name

Display name for this codespace

string
retention_period_minutes

Duration in minutes after codespace has gone idle in which it will be deleted. Must be integer minutes between 0 and 43200 (30 days).

integer
Examples
Example default
{
"repository_id": 1,
"ref": "main"
}

Response when the codespace was successfully created

Media type application/json
Codespace

A codespace.

object
id
required
integer format: int64
name
required

Automatically generated name of this codespace.

string
display_name

Display name for this codespace.

string
nullable
environment_id
required

UUID identifying this codespace’s environment.

string
nullable
owner
required
Simple User

A GitHub user.

object
name
string
nullable
email
string
nullable
login
required
string
id
required
integer format: int64
node_id
required
string
avatar_url
required
string format: uri
gravatar_id
required
string
nullable
url
required
string format: uri
html_url
required
string format: uri
followers_url
required
string format: uri
following_url
required
string
gists_url
required
string
starred_url
required
string
subscriptions_url
required
string format: uri
organizations_url
required
string format: uri
repos_url
required
string format: uri
events_url
required
string
received_events_url
required
string format: uri
type
required
string
site_admin
required
boolean
starred_at
string
user_view_type
string
billable_owner
required
Simple User

A GitHub user.

object
name
string
nullable
email
string
nullable
login
required
string
id
required
integer format: int64
node_id
required
string
avatar_url
required
string format: uri
gravatar_id
required
string
nullable
url
required
string format: uri
html_url
required
string format: uri
followers_url
required
string format: uri
following_url
required
string
gists_url
required
string
starred_url
required
string
subscriptions_url
required
string format: uri
organizations_url
required
string format: uri
repos_url
required
string format: uri
events_url
required
string
received_events_url
required
string format: uri
type
required
string
site_admin
required
boolean
starred_at
string
user_view_type
string
repository
required
Minimal Repository

Minimal Repository

object
id
required
integer format: int64
node_id
required
string
name
required
string
full_name
required
string
owner
required
Simple User

A GitHub user.

object
name
string
nullable
email
string
nullable
login
required
string
id
required
integer format: int64
node_id
required
string
avatar_url
required
string format: uri
gravatar_id
required
string
nullable
url
required
string format: uri
html_url
required
string format: uri
followers_url
required
string format: uri
following_url
required
string
gists_url
required
string
starred_url
required
string
subscriptions_url
required
string format: uri
organizations_url
required
string format: uri
repos_url
required
string format: uri
events_url
required
string
received_events_url
required
string format: uri
type
required
string
site_admin
required
boolean
starred_at
string
user_view_type
string
private
required
boolean
html_url
required
string format: uri
description
required
string
nullable
fork
required
boolean
url
required
string format: uri
archive_url
required
string
assignees_url
required
string
blobs_url
required
string
branches_url
required
string
collaborators_url
required
string
comments_url
required
string
commits_url
required
string
compare_url
required
string
contents_url
required
string
contributors_url
required
string format: uri
deployments_url
required
string format: uri
downloads_url
required
string format: uri
events_url
required
string format: uri
forks_url
required
string format: uri
git_commits_url
required
string
git_refs_url
required
string
git_tags_url
required
string
git_url
string
issue_comment_url
required
string
issue_events_url
required
string
issues_url
required
string
keys_url
required
string
labels_url
required
string
languages_url
required
string format: uri
merges_url
required
string format: uri
milestones_url
required
string
notifications_url
required
string
pulls_url
required
string
releases_url
required
string
ssh_url
string
stargazers_url
required
string format: uri
statuses_url
required
string
subscribers_url
required
string format: uri
subscription_url
required
string format: uri
tags_url
required
string format: uri
teams_url
required
string format: uri
trees_url
required
string
clone_url
string
mirror_url
string
nullable
hooks_url
required
string format: uri
svn_url
string
homepage
string
nullable
language
string
nullable
forks_count
integer
stargazers_count
integer
watchers_count
integer
size

The size of the repository, in kilobytes. Size is calculated hourly. When a repository is initially created, the size is 0.

integer
default_branch
string
open_issues_count
integer
is_template
boolean
topics
Array<string>
has_issues
boolean
has_projects
boolean
has_wiki
boolean
has_pages
boolean
has_downloads
boolean
has_discussions
boolean
has_pull_requests
boolean
pull_request_creation_policy

The policy controlling who can create pull requests: all or collaborators_only.

string
Allowed values: all collaborators_only
archived
boolean
disabled
boolean
visibility
string
pushed_at
string format: date-time
nullable
created_at
string format: date-time
nullable
updated_at
string format: date-time
nullable
permissions
object
admin
boolean
maintain
boolean
push
boolean
triage
boolean
pull
boolean
role_name
string
temp_clone_token
string
delete_branch_on_merge
boolean
subscribers_count
integer
network_count
integer
code_of_conduct
Code Of Conduct

Code Of Conduct

object
key
required
string
name
required
string
url
required
string format: uri
body
string
html_url
required
string format: uri
nullable
license
object
key
string
name
string
spdx_id
string
url
string
nullable
node_id
string
forks
integer
open_issues
integer
watchers
integer
allow_forking
boolean
web_commit_signoff_required
boolean
security_and_analysis
object
advanced_security

Enable or disable GitHub Advanced Security for the repository.

For standalone Code Scanning or Secret Protection products, this parameter cannot be used.

object
status
string
Allowed values: enabled disabled
code_security
object
status
string
Allowed values: enabled disabled
dependabot_security_updates

Enable or disable Dependabot security updates for the repository.

object
status

The enablement status of Dependabot security updates for the repository.

string
Allowed values: enabled disabled
secret_scanning
object
status
string
Allowed values: enabled disabled
secret_scanning_push_protection
object
status
string
Allowed values: enabled disabled
secret_scanning_non_provider_patterns
object
status
string
Allowed values: enabled disabled
secret_scanning_ai_detection
object
status
string
Allowed values: enabled disabled
secret_scanning_delegated_alert_dismissal
object
status
string
Allowed values: enabled disabled
secret_scanning_delegated_bypass
object
status
string
Allowed values: enabled disabled
secret_scanning_delegated_bypass_options
object
reviewers

The bypass reviewers for secret scanning delegated bypass

Array<object>
object
reviewer_id
required

The ID of the team or role selected as a bypass reviewer

integer
reviewer_type
required

The type of the bypass reviewer

string
Allowed values: TEAM ROLE
mode

The bypass mode for the reviewer

string
default: ALWAYS
Allowed values: ALWAYS EXEMPT
custom_properties

The custom properties that were defined for the repository. The keys are the custom property names, and the values are the corresponding custom property values.

object
key
additional properties
any
machine
required
Codespace machine

A description of the machine powering a codespace.

object
name
required

The name of the machine.

string
display_name
required

The display name of the machine includes cores, memory, and storage.

string
operating_system
required

The operating system of the machine.

string
storage_in_bytes
required

How much storage is available to the codespace.

integer
memory_in_bytes
required

How much memory is available to the codespace.

integer
cpus
required

How many cores are available to the codespace.

integer
prebuild_availability
required

Whether a prebuild is currently available when creating a codespace for this machine and repository. If a branch was not specified as a ref, the default branch will be assumed. Value will be “null” if prebuilds are not supported or prebuild availability could not be determined. Value will be “none” if no prebuild is available. Latest values “ready” and “in_progress” indicate the prebuild availability status.

string
nullable
Allowed values: none ready in_progress
devcontainer_path

Path to devcontainer.json from repo root used to create Codespace.

string
nullable
prebuild
required

Whether the codespace was created from a prebuild.

boolean
nullable
created_at
required
string format: date-time
updated_at
required
string format: date-time
last_used_at
required

Last known time this codespace was started.

string format: date-time
state
required

State of this codespace.

string
Allowed values: Unknown Created Queued Provisioning Available Awaiting Unavailable Deleted Moved Shutdown Archived Starting ShuttingDown Failed Exporting Updating Rebuilding
url
required

API URL for this codespace.

string format: uri
git_status
required

Details about the codespace’s git repository.

object
ahead

The number of commits the local repository is ahead of the remote.

integer
behind

The number of commits the local repository is behind the remote.

integer
has_unpushed_changes

Whether the local repository has unpushed changes.

boolean
has_uncommitted_changes

Whether the local repository has uncommitted changes.

boolean
ref

The current branch (or SHA if in detached HEAD state) of the local repository.

string
location
required

The initally assigned location of a new codespace.

string
Allowed values: EastUs SouthEastAsia WestEurope WestUs2
idle_timeout_minutes
required

The number of minutes of inactivity after which this codespace will be automatically stopped.

integer
nullable
web_url
required

URL to access this codespace on the web.

string format: uri
machines_url
required

API URL to access available alternate machine types for this codespace.

string format: uri
start_url
required

API URL to start this codespace.

string format: uri
stop_url
required

API URL to stop this codespace.

string format: uri
publish_url

API URL to publish this codespace to a new repository.

string format: uri
nullable
pulls_url
required

API URL for the Pull Request associated with this codespace, if any.

string format: uri
nullable
recent_folders
required
Array<string>
runtime_constraints
object
allowed_port_privacy_settings

The privacy settings a user can select from when forwarding a port.

Array<string>
nullable
pending_operation

Whether or not a codespace has a pending async operation. This would mean that the codespace is temporarily unavailable. The only thing that you can do with a codespace in this state is delete it.

boolean
nullable
pending_operation_disabled_reason

Text to show user when codespace is disabled by a pending operation

string
nullable
idle_timeout_notice

Text to show user when codespace idle timeout minutes has been overriden by an organization policy

string
nullable
retention_period_minutes

Duration in minutes after codespace has gone idle in which it will be deleted. Must be integer minutes between 0 and 43200 (30 days).

integer
nullable
retention_expires_at

When a codespace will be auto-deleted based on the “retention_period_minutes” and “last_used_at”

string format: date-time
nullable
last_known_stop_notice

The text to display to a user when a codespace has been stopped for a potentially actionable reason.

string
nullable
Examples
Example default
{
"id": 1,
"name": "monalisa-octocat-hello-world-g4wpq6h95q",
"environment_id": "26a7c758-7299-4a73-b978-5a92a7ae98a0",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"billable_owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"repository": {
"id": 1296269,
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
"name": "Hello-World",
"full_name": "octocat/Hello-World",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/octocat/Hello-World",
"description": "This your first repo!",
"fork": false,
"url": "https://api.github.com/repos/octocat/Hello-World",
"archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
"assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}",
"blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}",
"collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}",
"commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}",
"compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}",
"contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors",
"deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments",
"downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads",
"events_url": "https://api.github.com/repos/octocat/Hello-World/events",
"forks_url": "https://api.github.com/repos/octocat/Hello-World/forks",
"git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
"git_url": "git:github.com/octocat/Hello-World.git",
"issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
"issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}",
"keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
"labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}",
"languages_url": "https://api.github.com/repos/octocat/Hello-World/languages",
"merges_url": "https://api.github.com/repos/octocat/Hello-World/merges",
"milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
"pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}",
"releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}",
"ssh_url": "git@github.com:octocat/Hello-World.git",
"stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers",
"statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription",
"tags_url": "https://api.github.com/repos/octocat/Hello-World/tags",
"teams_url": "https://api.github.com/repos/octocat/Hello-World/teams",
"trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
"hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks"
},
"machine": {
"name": "standardLinux",
"display_name": "4 cores, 16 GB RAM, 64 GB storage",
"operating_system": "linux",
"storage_in_bytes": 68719476736,
"memory_in_bytes": 17179869184,
"cpus": 4
},
"prebuild": false,
"devcontainer_path": ".devcontainer/devcontainer.json",
"created_at": "2021-10-14T00:53:30-06:00",
"updated_at": "2021-10-14T00:53:32-06:00",
"last_used_at": "2021-10-14T00:53:30-06:00",
"state": "Available",
"url": "https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q",
"git_status": {
"ahead": 0,
"behind": 0,
"has_unpushed_changes": false,
"has_uncommitted_changes": false,
"ref": "main"
},
"location": "WestUs2",
"idle_timeout_minutes": 60,
"retention_period_minutes": 43200,
"retention_expires_at": null,
"web_url": "https://monalisa-octocat-hello-world-g4wpq6h95q.github.dev",
"machines_url": "https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/machines",
"start_url": "https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/start",
"stop_url": "https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/stop",
"pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1",
"recent_folders": [],
"template": null
}

Response when the codespace creation partially failed but is being retried in the background

Media type application/json
Codespace

A codespace.

object
id
required
integer format: int64
name
required

Automatically generated name of this codespace.

string
display_name

Display name for this codespace.

string
nullable
environment_id
required

UUID identifying this codespace’s environment.

string
nullable
owner
required
Simple User

A GitHub user.

object
name
string
nullable
email
string
nullable
login
required
string
id
required
integer format: int64
node_id
required
string
avatar_url
required
string format: uri
gravatar_id
required
string
nullable
url
required
string format: uri
html_url
required
string format: uri
followers_url
required
string format: uri
following_url
required
string
gists_url
required
string
starred_url
required
string
subscriptions_url
required
string format: uri
organizations_url
required
string format: uri
repos_url
required
string format: uri
events_url
required
string
received_events_url
required
string format: uri
type
required
string
site_admin
required
boolean
starred_at
string
user_view_type
string
billable_owner
required
Simple User

A GitHub user.

object
name
string
nullable
email
string
nullable
login
required
string
id
required
integer format: int64
node_id
required
string
avatar_url
required
string format: uri
gravatar_id
required
string
nullable
url
required
string format: uri
html_url
required
string format: uri
followers_url
required
string format: uri
following_url
required
string
gists_url
required
string
starred_url
required
string
subscriptions_url
required
string format: uri
organizations_url
required
string format: uri
repos_url
required
string format: uri
events_url
required
string
received_events_url
required
string format: uri
type
required
string
site_admin
required
boolean
starred_at
string
user_view_type
string
repository
required
Minimal Repository

Minimal Repository

object
id
required
integer format: int64
node_id
required
string
name
required
string
full_name
required
string
owner
required
Simple User

A GitHub user.

object
name
string
nullable
email
string
nullable
login
required
string
id
required
integer format: int64
node_id
required
string
avatar_url
required
string format: uri
gravatar_id
required
string
nullable
url
required
string format: uri
html_url
required
string format: uri
followers_url
required
string format: uri
following_url
required
string
gists_url
required
string
starred_url
required
string
subscriptions_url
required
string format: uri
organizations_url
required
string format: uri
repos_url
required
string format: uri
events_url
required
string
received_events_url
required
string format: uri
type
required
string
site_admin
required
boolean
starred_at
string
user_view_type
string
private
required
boolean
html_url
required
string format: uri
description
required
string
nullable
fork
required
boolean
url
required
string format: uri
archive_url
required
string
assignees_url
required
string
blobs_url
required
string
branches_url
required
string
collaborators_url
required
string
comments_url
required
string
commits_url
required
string
compare_url
required
string
contents_url
required
string
contributors_url
required
string format: uri
deployments_url
required
string format: uri
downloads_url
required
string format: uri
events_url
required
string format: uri
forks_url
required
string format: uri
git_commits_url
required
string
git_refs_url
required
string
git_tags_url
required
string
git_url
string
issue_comment_url
required
string
issue_events_url
required
string
issues_url
required
string
keys_url
required
string
labels_url
required
string
languages_url
required
string format: uri
merges_url
required
string format: uri
milestones_url
required
string
notifications_url
required
string
pulls_url
required
string
releases_url
required
string
ssh_url
string
stargazers_url
required
string format: uri
statuses_url
required
string
subscribers_url
required
string format: uri
subscription_url
required
string format: uri
tags_url
required
string format: uri
teams_url
required
string format: uri
trees_url
required
string
clone_url
string
mirror_url
string
nullable
hooks_url
required
string format: uri
svn_url
string
homepage
string
nullable
language
string
nullable
forks_count
integer
stargazers_count
integer
watchers_count
integer
size

The size of the repository, in kilobytes. Size is calculated hourly. When a repository is initially created, the size is 0.

integer
default_branch
string
open_issues_count
integer
is_template
boolean
topics
Array<string>
has_issues
boolean
has_projects
boolean
has_wiki
boolean
has_pages
boolean
has_downloads
boolean
has_discussions
boolean
has_pull_requests
boolean
pull_request_creation_policy

The policy controlling who can create pull requests: all or collaborators_only.

string
Allowed values: all collaborators_only
archived
boolean
disabled
boolean
visibility
string
pushed_at
string format: date-time
nullable
created_at
string format: date-time
nullable
updated_at
string format: date-time
nullable
permissions
object
admin
boolean
maintain
boolean
push
boolean
triage
boolean
pull
boolean
role_name
string
temp_clone_token
string
delete_branch_on_merge
boolean
subscribers_count
integer
network_count
integer
code_of_conduct
Code Of Conduct

Code Of Conduct

object
key
required
string
name
required
string
url
required
string format: uri
body
string
html_url
required
string format: uri
nullable
license
object
key
string
name
string
spdx_id
string
url
string
nullable
node_id
string
forks
integer
open_issues
integer
watchers
integer
allow_forking
boolean
web_commit_signoff_required
boolean
security_and_analysis
object
advanced_security

Enable or disable GitHub Advanced Security for the repository.

For standalone Code Scanning or Secret Protection products, this parameter cannot be used.

object
status
string
Allowed values: enabled disabled
code_security
object
status
string
Allowed values: enabled disabled
dependabot_security_updates

Enable or disable Dependabot security updates for the repository.

object
status

The enablement status of Dependabot security updates for the repository.

string
Allowed values: enabled disabled
secret_scanning
object
status
string
Allowed values: enabled disabled
secret_scanning_push_protection
object
status
string
Allowed values: enabled disabled
secret_scanning_non_provider_patterns
object
status
string
Allowed values: enabled disabled
secret_scanning_ai_detection
object
status
string
Allowed values: enabled disabled
secret_scanning_delegated_alert_dismissal
object
status
string
Allowed values: enabled disabled
secret_scanning_delegated_bypass
object
status
string
Allowed values: enabled disabled
secret_scanning_delegated_bypass_options
object
reviewers

The bypass reviewers for secret scanning delegated bypass

Array<object>
object
reviewer_id
required

The ID of the team or role selected as a bypass reviewer

integer
reviewer_type
required

The type of the bypass reviewer

string
Allowed values: TEAM ROLE
mode

The bypass mode for the reviewer

string
default: ALWAYS
Allowed values: ALWAYS EXEMPT
custom_properties

The custom properties that were defined for the repository. The keys are the custom property names, and the values are the corresponding custom property values.

object
key
additional properties
any
machine
required
Codespace machine

A description of the machine powering a codespace.

object
name
required

The name of the machine.

string
display_name
required

The display name of the machine includes cores, memory, and storage.

string
operating_system
required

The operating system of the machine.

string
storage_in_bytes
required

How much storage is available to the codespace.

integer
memory_in_bytes
required

How much memory is available to the codespace.

integer
cpus
required

How many cores are available to the codespace.

integer
prebuild_availability
required

Whether a prebuild is currently available when creating a codespace for this machine and repository. If a branch was not specified as a ref, the default branch will be assumed. Value will be “null” if prebuilds are not supported or prebuild availability could not be determined. Value will be “none” if no prebuild is available. Latest values “ready” and “in_progress” indicate the prebuild availability status.

string
nullable
Allowed values: none ready in_progress
devcontainer_path

Path to devcontainer.json from repo root used to create Codespace.

string
nullable
prebuild
required

Whether the codespace was created from a prebuild.

boolean
nullable
created_at
required
string format: date-time
updated_at
required
string format: date-time
last_used_at
required

Last known time this codespace was started.

string format: date-time
state
required

State of this codespace.

string
Allowed values: Unknown Created Queued Provisioning Available Awaiting Unavailable Deleted Moved Shutdown Archived Starting ShuttingDown Failed Exporting Updating Rebuilding
url
required

API URL for this codespace.

string format: uri
git_status
required

Details about the codespace’s git repository.

object
ahead

The number of commits the local repository is ahead of the remote.

integer
behind

The number of commits the local repository is behind the remote.

integer
has_unpushed_changes

Whether the local repository has unpushed changes.

boolean
has_uncommitted_changes

Whether the local repository has uncommitted changes.

boolean
ref

The current branch (or SHA if in detached HEAD state) of the local repository.

string
location
required

The initally assigned location of a new codespace.

string
Allowed values: EastUs SouthEastAsia WestEurope WestUs2
idle_timeout_minutes
required

The number of minutes of inactivity after which this codespace will be automatically stopped.

integer
nullable
web_url
required

URL to access this codespace on the web.

string format: uri
machines_url
required

API URL to access available alternate machine types for this codespace.

string format: uri
start_url
required

API URL to start this codespace.

string format: uri
stop_url
required

API URL to stop this codespace.

string format: uri
publish_url

API URL to publish this codespace to a new repository.

string format: uri
nullable
pulls_url
required

API URL for the Pull Request associated with this codespace, if any.

string format: uri
nullable
recent_folders
required
Array<string>
runtime_constraints
object
allowed_port_privacy_settings

The privacy settings a user can select from when forwarding a port.

Array<string>
nullable
pending_operation

Whether or not a codespace has a pending async operation. This would mean that the codespace is temporarily unavailable. The only thing that you can do with a codespace in this state is delete it.

boolean
nullable
pending_operation_disabled_reason

Text to show user when codespace is disabled by a pending operation

string
nullable
idle_timeout_notice

Text to show user when codespace idle timeout minutes has been overriden by an organization policy

string
nullable
retention_period_minutes

Duration in minutes after codespace has gone idle in which it will be deleted. Must be integer minutes between 0 and 43200 (30 days).

integer
nullable
retention_expires_at

When a codespace will be auto-deleted based on the “retention_period_minutes” and “last_used_at”

string format: date-time
nullable
last_known_stop_notice

The text to display to a user when a codespace has been stopped for a potentially actionable reason.

string
nullable
Examples
Example default
{
"id": 1,
"name": "monalisa-octocat-hello-world-g4wpq6h95q",
"environment_id": "26a7c758-7299-4a73-b978-5a92a7ae98a0",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"billable_owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"repository": {
"id": 1296269,
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
"name": "Hello-World",
"full_name": "octocat/Hello-World",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/octocat/Hello-World",
"description": "This your first repo!",
"fork": false,
"url": "https://api.github.com/repos/octocat/Hello-World",
"archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
"assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}",
"blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}",
"collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}",
"commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}",
"compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}",
"contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors",
"deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments",
"downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads",
"events_url": "https://api.github.com/repos/octocat/Hello-World/events",
"forks_url": "https://api.github.com/repos/octocat/Hello-World/forks",
"git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
"git_url": "git:github.com/octocat/Hello-World.git",
"issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
"issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}",
"keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
"labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}",
"languages_url": "https://api.github.com/repos/octocat/Hello-World/languages",
"merges_url": "https://api.github.com/repos/octocat/Hello-World/merges",
"milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
"pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}",
"releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}",
"ssh_url": "git@github.com:octocat/Hello-World.git",
"stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers",
"statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription",
"tags_url": "https://api.github.com/repos/octocat/Hello-World/tags",
"teams_url": "https://api.github.com/repos/octocat/Hello-World/teams",
"trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
"hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks"
},
"machine": {
"name": "standardLinux",
"display_name": "4 cores, 16 GB RAM, 64 GB storage",
"operating_system": "linux",
"storage_in_bytes": 68719476736,
"memory_in_bytes": 17179869184,
"cpus": 4
},
"prebuild": false,
"devcontainer_path": ".devcontainer/devcontainer.json",
"created_at": "2021-10-14T00:53:30-06:00",
"updated_at": "2021-10-14T00:53:32-06:00",
"last_used_at": "2021-10-14T00:53:30-06:00",
"state": "Available",
"url": "https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q",
"git_status": {
"ahead": 0,
"behind": 0,
"has_unpushed_changes": false,
"has_uncommitted_changes": false,
"ref": "main"
},
"location": "WestUs2",
"idle_timeout_minutes": 60,
"retention_period_minutes": 43200,
"retention_expires_at": null,
"web_url": "https://monalisa-octocat-hello-world-g4wpq6h95q.github.dev",
"machines_url": "https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/machines",
"start_url": "https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/start",
"stop_url": "https://api.github.com/user/codespaces/monalisa-octocat-hello-world-g4wpq6h95q/stop",
"pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls/1",
"recent_folders": [],
"template": null
}

Requires authentication

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"
}

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"
}

Service unavailable

Media type application/json
object
code
string
message
string
documentation_url
string
Example generated
{
"code": "example",
"message": "example",
"documentation_url": "example"
}