{"meta":{"title":"Points de terminaison d’API REST pour les secrets du référentiel Codespaces","intro":"Utilisez l’API REST pour gérer les secrets des dépôts auxquels l’utilisateur a accès dans un codespace.","product":"API REST","breadcrumbs":[{"href":"/fr/enterprise-cloud@latest/rest","title":"API REST"},{"href":"/fr/enterprise-cloud@latest/rest/codespaces","title":"Codespaces"},{"href":"/fr/enterprise-cloud@latest/rest/codespaces/repository-secrets","title":"Secrets de référentiel"}],"documentType":"article"},"body":"# Points de terminaison d’API REST pour les secrets du référentiel Codespaces\n\nUtilisez l’API REST pour gérer les secrets des dépôts auxquels l’utilisateur a accès dans un codespace.\n\n## À propos des secrets de dépôt Codespaces\n\nVous pouvez créer, lister et supprimer des secrets (comme les jetons d’accès pour les services cloud) pour les dépôts auxquels l’utilisateur a accès. Ces secrets sont mis à la disposition de l’espace de code au moment de l’exécution. Pour plus d’informations, consultez « [Gestion des secrets spécifiques à votre compte pour GitHub Codespaces](/fr/enterprise-cloud@latest/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):**"}