Skip to main content
Die REST-API verfügt jetzt über eine Versionskontrolle. Weitere Informationen findest du unter Informationen zur API-Versionsverwaltung.

REST-API-Endpunkte für geheime Codespaces-Repositoryschlüssel

Verwende die REST-API, um Geheimnisse für Repositorys zu verwalten, auf die der Benutzer Zugriff in einem Codespace hat.

Wer kann dieses Feature verwenden?

Users with write access to a repository can manage Codespaces repository secrets.

Informationen zu Codespaces-Repositorygeheimnissen

Du kannst Geheimnisse (z. B. Zugriffstoken für Clouddienste) für die Repositorys erstellen, auflisten und löschen, auf die der Benutzer Zugriff hat. Diese Geheimnisse werden dem Codespace zur Laufzeit zur Verfügung gestellt. Weitere Informationen findest du unter Verwalten deiner kontospezifischen Geheimnisse für GitHub Codespaces.

List repository 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.

Differenzierte Zugriffstoken für "List repository secrets"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • codespaces_secrets:write

Parameter für „List repository secrets“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Pfadparameter
Name, type, BESCHREIBUNG
owner string Erforderlich

The account owner of the repository. The name is not case sensitive.

repo string Erforderlich

The name of the repository without the .git extension. The name is not case sensitive.

Abfrageparameter
Name, type, BESCHREIBUNG
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Standard: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Standard: 1

HTTP-Antwortstatuscodes für „List repository secrets“

StatuscodeBESCHREIBUNG
200

OK

Codebeispiele für „List repository secrets“

Beispiel für eine Anfrage

get/repos/{owner}/{repo}/codespaces/secrets
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/codespaces/secrets

Response

Status: 200
{ "total_count": 2, "secrets": [ { "name": "GH_TOKEN", "created_at": "2019-08-10T14:59:22Z", "updated_at": "2020-01-10T14:59:22Z", "visibility": "all" }, { "name": "GIST_ID", "created_at": "2020-01-10T10:59:22Z", "updated_at": "2020-01-11T11:59:22Z", "visibility": "all" } ] }

Get a repository 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.

Anyone with read access to the repository can use this endpoint.

If the repository is private, OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Differenzierte Zugriffstoken für "Get a repository public key"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • codespaces_secrets:write

Parameter für „Get a repository public key“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Pfadparameter
Name, type, BESCHREIBUNG
owner string Erforderlich

The account owner of the repository. The name is not case sensitive.

repo string Erforderlich

The name of the repository without the .git extension. The name is not case sensitive.

HTTP-Antwortstatuscodes für „Get a repository public key“

StatuscodeBESCHREIBUNG
200

OK

Codebeispiele für „Get a repository public key“

Beispiel für eine Anfrage

get/repos/{owner}/{repo}/codespaces/secrets/public-key
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/codespaces/secrets/public-key

Response

Status: 200
{ "key_id": "012345678912345678", "key": "2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234" }

Get a repository secret

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.

Differenzierte Zugriffstoken für "Get a repository secret"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • codespaces_secrets:write

Parameter für „Get a repository secret“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Pfadparameter
Name, type, BESCHREIBUNG
owner string Erforderlich

The account owner of the repository. The name is not case sensitive.

repo string Erforderlich

The name of the repository without the .git extension. The name is not case sensitive.

secret_name string Erforderlich

The name of the secret.

HTTP-Antwortstatuscodes für „Get a repository secret“

StatuscodeBESCHREIBUNG
200

OK

Codebeispiele für „Get a repository secret“

Beispiel für eine Anfrage

get/repos/{owner}/{repo}/codespaces/secrets/{secret_name}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME

Response

Status: 200
{ "name": "GH_TOKEN", "created_at": "2019-08-10T14:59:22Z", "updated_at": "2020-01-10T14:59:22Z", "visibility": "all" }

Create or update a repository secret

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.

Differenzierte Zugriffstoken für "Create or update a repository secret"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • codespaces_secrets:write and administration:write

Parameter für „Create or update a repository secret“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Pfadparameter
Name, type, BESCHREIBUNG
owner string Erforderlich

The account owner of the repository. The name is not case sensitive.

repo string Erforderlich

The name of the repository without the .git extension. The name is not case sensitive.

secret_name string Erforderlich

The name of the secret.

Textparameter
Name, type, BESCHREIBUNG
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.

HTTP-Antwortstatuscodes für „Create or update a repository secret“

StatuscodeBESCHREIBUNG
201

Response when creating a secret

204

Response when updating a secret

Codebeispiele für „Create or update a repository secret“

Beispiele für Anforderungen

put/repos/{owner}/{repo}/codespaces/secrets/{secret_name}
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME \ -d '{"encrypted_value":"c2VjcmV0","key_id":"012345678912345678"}'

Response when creating a secret

Delete a repository secret

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.

Differenzierte Zugriffstoken für "Delete a repository secret"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • codespaces_secrets:write and administration:write

Parameter für „Delete a repository secret“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Pfadparameter
Name, type, BESCHREIBUNG
owner string Erforderlich

The account owner of the repository. The name is not case sensitive.

repo string Erforderlich

The name of the repository without the .git extension. The name is not case sensitive.

secret_name string Erforderlich

The name of the secret.

HTTP-Antwortstatuscodes für „Delete a repository secret“

StatuscodeBESCHREIBUNG
204

No Content

Codebeispiele für „Delete a repository secret“

Beispiel für eine Anfrage

delete/repos/{owner}/{repo}/codespaces/secrets/{secret_name}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME

Response

Status: 204