REST API endpoints for Codespaces organization secrets

Use the REST API to manage your organization-level Codespaces secrets.

Note

These endpoints are currently in public preview and subject to change.

Note

Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.

List organization secrets

GET /orgs/{org}/codespaces/secrets

Lists all Codespaces development environment secrets available at the organization-level without revealing their encrypted
values.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/codespaces/secrets

Response schema (Status: 200):

Get an organization public key

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

Gets a public key for an organization, which is required in order to encrypt secrets. You need to encrypt the value of a secret before you can create or update secrets.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/codespaces/secrets/public-key

Response schema (Status: 200):

Get an organization secret

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

Gets an organization development environment secret without revealing its encrypted value.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/codespaces/secrets/SECRET_NAME

Response schema (Status: 200):

Create or update an organization secret

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

Creates or updates an organization development environment secret with an encrypted value. Encrypt your secret using
LibSodium. For more information, see "Encrypting secrets for the REST API."
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example 1: Status Code 201

Request:

curl -L \
  -X PUT \
  https://api.github.com/orgs/ORG/codespaces/secrets/SECRET_NAME \
  -d '{
  "encrypted_value": "c2VjcmV0",
  "key_id": "012345678912345678",
  "visibility": "selected",
  "selected_repository_ids": [
    1296269,
    1296280
  ]
}'

Response schema (Status: 201):

Example 2: Status Code 204

Request:

curl -L \
  -X PUT \
  https://api.github.com/orgs/ORG/codespaces/secrets/SECRET_NAME \
  -d '{
  "encrypted_value": "c2VjcmV0",
  "key_id": "012345678912345678",
  "visibility": "selected",
  "selected_repository_ids": [
    1296269,
    1296280
  ]
}'

Response schema (Status: 204):

Delete an organization secret

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

Deletes an organization development environment secret using the secret name.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/orgs/ORG/codespaces/secrets/SECRET_NAME

Response schema (Status: 204):

List selected repositories for an organization secret

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

Lists all repositories that have been selected when the visibility
for repository access to a secret is set to selected.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/codespaces/secrets/SECRET_NAME/repositories

Response schema (Status: 200):

Set selected repositories for an organization secret

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

Replaces all repositories for an organization development environment secret when the visibility
for repository access is set to selected. The visibility is set when you Create
or update an organization secret.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X PUT \
  https://api.github.com/orgs/ORG/codespaces/secrets/SECRET_NAME/repositories \
  -d '{
  "selected_repository_ids": [
    64780797
  ]
}'

Response schema (Status: 204):

Add selected repository to an organization secret

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

Adds a repository to an organization development environment secret when the visibility for repository access is set to selected. The visibility is set when you Create or update an organization secret.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X PUT \
  https://api.github.com/orgs/ORG/codespaces/secrets/SECRET_NAME/repositories/REPOSITORY_ID

Response schema (Status: 204):

Remove selected repository from an organization secret

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

Removes a repository from an organization development environment secret when the visibility
for repository access is set to selected. The visibility is set when you Create
or update an organization secret.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/orgs/ORG/codespaces/secrets/SECRET_NAME/repositories/REPOSITORY_ID

Response schema (Status: 204):