Skip to content

GitHub: Get a codespace for the authenticated user

GitHub codespaces.codespacesGetForAuthenticatedUser: arguments, response, policy and SDK examples.

← Codespaces operations · Get started

Operation github.codespaces_get_for_authenticated_user

Provider route: GET /user/codespaces/{codespace_name}. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/github with npm, or alter-sdk-github with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { GitHubIntegration } from "@alter-ai/github";
async function execute(input: Parameters<GitHubIntegration["codespaces"]["codespacesGetForAuthenticatedUser"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new GitHubIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.codespaces.codespacesGetForAuthenticatedUser(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_github import GitHubIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = GitHubIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.codespaces.codespaces_get_for_authenticated_user(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.codespace_namestringRequired within parent

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Stop a codespace for an organization user — response body

Referenced models: Stop a codespace for an organization user — response body

5 more schemas are linked from the tables above, on the schema pages.

Stop a codespace for an organization user — response body
FieldTypePresenceDescription and constraints
$objectRootA codespace.
billable_ownerModelRequired within parentExpand List users — response body — item
created_atstringRequired within parentFormat: date-time
devcontainer_pathJSONOptional
devcontainer_path (anyOf 1)stringAlternativePath to devcontainer.json from repo root used to create Codespace.
devcontainer_path (anyOf 2)nullAlternative
display_nameJSONOptional
display_name (anyOf 1)stringAlternativeDisplay name for this codespace.
display_name (anyOf 2)nullAlternative
environment_idJSONRequired within parent
environment_id (anyOf 1)stringAlternativeUUID identifying this codespace's environment.
environment_id (anyOf 2)nullAlternative
git_statusModelRequired within parentExpand Stop a codespace for an organization user — response body — git status
idJSONRequired within parent
id (anyOf 1)integerAlternativeFormat: int64
id (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
idle_timeout_minutesJSONRequired within parent
idle_timeout_minutes (anyOf 1)JSONAlternative
idle_timeout_minutes (anyOf 1) (anyOf 1)integerAlternativeThe number of minutes of inactivity after which this codespace will be automatically stopped.
idle_timeout_minutes (anyOf 1) (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
idle_timeout_minutes (anyOf 2)nullAlternative
idle_timeout_noticeJSONOptional
idle_timeout_notice (anyOf 1)stringAlternativeText to show user when codespace idle timeout minutes has been overriden by an organization policy
idle_timeout_notice (anyOf 2)nullAlternative
last_known_stop_noticeJSONOptional
last_known_stop_notice (anyOf 1)stringAlternativeThe text to display to a user when a codespace has been stopped for a potentially actionable reason.
last_known_stop_notice (anyOf 2)nullAlternative
last_used_atstringRequired within parentLast known time this codespace was started.
Format: date-time
locationstringRequired within parentThe initally assigned location of a new codespace.
Known values: EastUs, SouthEastAsia, WestEurope, WestUs2
machineModelRequired within parentExpand Stop a codespace for an organization user — response body — machine
machines_urlstringRequired within parentAPI URL to access available alternate machine types for this codespace.
Format: uri
namestringRequired within parentAutomatically generated name of this codespace.
ownerModelRequired within parentExpand List users — response body — item
pending_operationJSONOptional
pending_operation (anyOf 1)booleanAlternativeWhether 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.
pending_operation (anyOf 2)nullAlternative
pending_operation_disabled_reasonJSONOptional
pending_operation_disabled_reason (anyOf 1)stringAlternativeText to show user when codespace is disabled by a pending operation
pending_operation_disabled_reason (anyOf 2)nullAlternative
prebuildJSONRequired within parent
prebuild (anyOf 1)booleanAlternativeWhether the codespace was created from a prebuild.
prebuild (anyOf 2)nullAlternative
publish_urlJSONOptional
publish_url (anyOf 1)stringAlternativeAPI URL to publish this codespace to a new repository.
Format: uri
publish_url (anyOf 2)nullAlternative
pulls_urlJSONRequired within parent
pulls_url (anyOf 1)stringAlternativeAPI URL for the Pull Request associated with this codespace, if any.
Format: uri
pulls_url (anyOf 2)nullAlternative
recent_foldersarrayRequired within parent
recent_folders[]stringEach item
repositoryModelRequired within parentExpand Transfer a repository — response body
retention_expires_atJSONOptional
retention_expires_at (anyOf 1)stringAlternativeWhen a codespace will be auto-deleted based on the "retention_period_minutes" and "last_used_at"
Format: date-time
retention_expires_at (anyOf 2)nullAlternative
retention_period_minutesJSONOptional
retention_period_minutes (anyOf 1)JSONAlternative
retention_period_minutes (anyOf 1) (anyOf 1)integerAlternativeDuration in minutes after codespace has gone idle in which it will be deleted. Must be integer minutes between 0 and 43200 (30 days).
retention_period_minutes (anyOf 1) (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
retention_period_minutes (anyOf 2)nullAlternative
runtime_constraintsobjectOptional
runtime_constraints.allowed_port_privacy_settingsJSONOptional
runtime_constraints.allowed_port_privacy_settings (anyOf 1)arrayAlternativeThe privacy settings a user can select from when forwarding a port.
runtime_constraints.allowed_port_privacy_settings (anyOf 1)[]stringEach item
runtime_constraints.allowed_port_privacy_settings (anyOf 2)nullAlternative
start_urlstringRequired within parentAPI URL to start this codespace.
Format: uri
statestringRequired within parentState of this codespace.
Known values: Unknown, Created, Queued, Provisioning, Available, Awaiting, Unavailable, Deleted, Moved, Shutdown, Archived, Starting, ShuttingDown, Failed, Exporting, Updating, Rebuilding
stop_urlstringRequired within parentAPI URL to stop this codespace.
Format: uri
updated_atstringRequired within parentFormat: date-time
urlstringRequired within parentAPI URL for this codespace.
Format: uri
web_urlstringRequired within parentURL to access this codespace on the web.
Format: uri

Referenced models: Transfer a repository — response body, Stop a codespace for an organization user — response body — machine, List users — response body — item, Stop a codespace for an organization user — response body — git status

Stop a codespace for an organization user — response body — machine
FieldTypePresenceDescription and constraints
$JSONRoot
$ (anyOf 1)ModelAlternativeExpand Stop a codespace for an organization user — response body — machine A description of the machine powering a codespace
$ (anyOf 2)nullAlternative

Referenced models: Stop a codespace for an organization user — response body — machine A description of the machine powering a codespace

List users — response body — item
FieldTypePresenceDescription and constraints
$objectRootA GitHub user.
avatar_urlstringRequired within parentFormat: uri
emailJSONOptional
email (anyOf 1)stringAlternative
email (anyOf 2)nullAlternative
events_urlstringRequired within parent
followers_urlstringRequired within parentFormat: uri
following_urlstringRequired within parent
gists_urlstringRequired within parent
gravatar_idJSONRequired within parent
gravatar_id (anyOf 1)stringAlternative
gravatar_id (anyOf 2)nullAlternative
html_urlstringRequired within parentFormat: uri
idJSONRequired within parent
id (anyOf 1)integerAlternativeFormat: int64
id (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
loginstringRequired within parent
nameJSONOptional
name (anyOf 1)stringAlternative
name (anyOf 2)nullAlternative
node_idstringRequired within parent
organizations_urlstringRequired within parentFormat: uri
received_events_urlstringRequired within parentFormat: uri
repos_urlstringRequired within parentFormat: uri
site_adminbooleanRequired within parent
starred_atstringOptional
starred_urlstringRequired within parent
subscriptions_urlstringRequired within parentFormat: uri
typestringRequired within parent
urlstringRequired within parentFormat: uri
user_view_typestringOptional

SDK function policy ID: github.codespaces_get_for_authenticated_user. Catalog operation: codespaces/get-for-authenticated-user. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Pinned headers: {"X-GitHub-Api-Version": "2026-03-10", "User-Agent": "Alter", "Accept": "application/vnd.github+json"}

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.