Use the REST API to manage secrets for repositories that the user has access to in a codespace.
You can create, list, and delete secrets (such as access tokens for cloud services) for repositories that the user has access to. These secrets are made available to the codespace at runtime. For more information, see Managing your account-specific secrets for GitHub Codespaces.
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/secrets
Lists all development environment secrets available in a repository without revealing their encrypted
values.
OAuth app tokens and personal access tokens (classic) need the repo 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.
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
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/codespaces/secrets
Response schema (Status: 200):
total_count: required, integersecrets: required, array of Codespaces Secret:
name: required, stringcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timeGET /repos/{owner}/{repo}/codespaces/secrets/public-key
Gets your public key, which you need to encrypt secrets. You need to
encrypt a secret before you can create or update secrets.
If the repository is private, OAuth app tokens and personal access tokens (classic) need the repo 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.
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/codespaces/secrets/public-key
Response schema (Status: 200):
key_id: required, stringkey: required, stringid: integerurl: stringtitle: stringcreated_at: stringGET /repos/{owner}/{repo}/codespaces/secrets/{secret_name}
Gets a single repository development environment secret without revealing its encrypted value.
OAuth app tokens and personal access tokens (classic) need the repo 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.
secret_name (string) (required)
The name of the secret.
Request:
curl -L \
-X GET \
https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME
Response schema (Status: 200):
name: required, stringcreated_at: required, string, format: date-timeupdated_at: required, string, format: date-timePUT /repos/{owner}/{repo}/codespaces/secrets/{secret_name}
Creates or updates a repository 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 repo scope to use this endpoint. The associated user must be a repository admin.
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.
secret_name (string) (required)
The name of the secret.
encrypted_value (string)
Value for your secret, encrypted with LibSodium using the public key retrieved from the Get a repository public key endpoint.
key_id (string)
ID of the key you used to encrypt the secret.
201 - Response when creating a secret
204 - Response when updating a secret
Request:
curl -L \
-X PUT \
https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME \
-d '{
"encrypted_value": "c2VjcmV0",
"key_id": "012345678912345678"
}'
Response schema (Status: 201):
Request:
curl -L \
-X PUT \
https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME \
-d '{
"encrypted_value": "c2VjcmV0",
"key_id": "012345678912345678"
}'
Response schema (Status: 204):
DELETE /repos/{owner}/{repo}/codespaces/secrets/{secret_name}
Deletes a development environment secret in a repository using the secret name.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint. The associated user must be a repository admin.
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.
secret_name (string) (required)
The name of the secret.
Request:
curl -L \
-X DELETE \
https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME
Response schema (Status: 204):