{"meta":{"title":"REST API endpoints for Codespaces repository secrets","intro":"Use the REST API to manage secrets for repositories that the user has access to in a codespace.","product":"REST API","breadcrumbs":[{"href":"/en/rest","title":"REST API"},{"href":"/en/rest/codespaces","title":"Codespaces"},{"href":"/en/rest/codespaces/repository-secrets","title":"Repository secrets"}],"documentType":"article"},"body":"# REST API endpoints for Codespaces repository secrets\n\nUse the REST API to manage secrets for repositories that the user has access to in a codespace.\n\n## About Codespaces repository secrets\n\nYou 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](/en/codespaces/managing-your-codespaces/managing-your-account-specific-secrets-for-github-codespaces).\n\n> \\[!NOTE]\n> 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.\n\n## List repository secrets\n\n```\nGET /repos/{owner}/{repo}/codespaces/secrets\n```\n\nLists all development environment secrets available in a repository without revealing their encrypted\nvalues.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n* **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n* **`page`** (integer)\n  The page number of the results to fetch. For more information, see \"Using pagination in the REST API.\"\n  Default: `1`\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/repos/OWNER/REPO/codespaces/secrets\n```\n\n**Response schema (Status: 200):**\n\n* `total_count`: required, integer\n* `secrets`: required, array of `Codespaces Secret`:\n  * `name`: required, string\n  * `created_at`: required, string, format: date-time\n  * `updated_at`: required, string, format: date-time\n\n## Get a repository public key\n\n```\nGET /repos/{owner}/{repo}/codespaces/secrets/public-key\n```\n\nGets your public key, which you need to encrypt secrets. You need to\nencrypt a secret before you can create or update secrets.\nIf the repository is private, OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/repos/OWNER/REPO/codespaces/secrets/public-key\n```\n\n**Response schema (Status: 200):**\n\n* `key_id`: required, string\n* `key`: required, string\n* `id`: integer\n* `url`: string\n* `title`: string\n* `created_at`: string\n\n## Get a repository secret\n\n```\nGET /repos/{owner}/{repo}/codespaces/secrets/{secret_name}\n```\n\nGets a single repository development environment secret without revealing its encrypted value.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n* **`secret_name`** (string) (required)\n  The name of the secret.\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME\n```\n\n**Response schema (Status: 200):**\n\n* `name`: required, string\n* `created_at`: required, string, format: date-time\n* `updated_at`: required, string, format: date-time\n\n## Create or update a repository secret\n\n```\nPUT /repos/{owner}/{repo}/codespaces/secrets/{secret_name}\n```\n\nCreates or updates a repository development environment secret with an encrypted value. Encrypt your secret using\nLibSodium. For more information, see \"Encrypting secrets for the REST API.\"\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint. The associated user must be a repository admin.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n* **`secret_name`** (string) (required)\n  The name of the secret.\n\n#### Body parameters\n\n* **`encrypted_value`** (string)\n  Value for your secret, encrypted with LibSodium using the public key retrieved from the Get a repository public key endpoint.\n\n* **`key_id`** (string)\n  ID of the key you used to encrypt the secret.\n\n### HTTP response status codes\n\n* **201** - Response when creating a secret\n\n* **204** - Response when updating a secret\n\n### Code examples\n\n#### Example 1: Status Code 201\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PUT \\\n  https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME \\\n  -d '{\n  \"encrypted_value\": \"c2VjcmV0\",\n  \"key_id\": \"012345678912345678\"\n}'\n```\n\n**Response schema (Status: 201):**\n\n#### Example 2: Status Code 204\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PUT \\\n  https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME \\\n  -d '{\n  \"encrypted_value\": \"c2VjcmV0\",\n  \"key_id\": \"012345678912345678\"\n}'\n```\n\n**Response schema (Status: 204):**\n\n## Delete a repository secret\n\n```\nDELETE /repos/{owner}/{repo}/codespaces/secrets/{secret_name}\n```\n\nDeletes a development environment secret in a repository using the secret name.\nOAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint. The associated user must be a repository admin.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n* **`secret_name`** (string) (required)\n  The name of the secret.\n\n### HTTP response status codes\n\n* **204** - No Content\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME\n```\n\n**Response schema (Status: 204):**"}