endpoint: "Create or update an environment secret"
description: "Creates or updates an environment secret with an encrypted value. Encrypt your secret using LibSodium."
authentication:
- type: "OAuth tokens"
required_scope: "repo"
- type: "personal access tokens (classic)"
required_scope: "repo"
- type: "GitHub App user access tokens"
required_permission:
- "Secrets: write"
- "Environments: write"
- type: "GitHub App installation access tokens"
required_permission:
- "Secrets: write"
- "Environments: write"
- type: "Fine-grained personal access tokens"
required_permission:
- "Secrets: write"
- "Environments: write"
headers:
accept:
type: "string"
description: "Setting to application/vnd.github+json is recommended."
path_parameters:
owner:
type: "string"
description: "The account owner of the repository. The name is not case sensitive."
required: true
repo:
type: "string"
description: "The name of the repository without the .git extension. The name is not case sensitive."
required: true
environment_name:
type: "string"
description: "The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F."
required: true
secret_name:
type: "string"
description: "The name of the secret."
required: true
body_parameters:
encrypted_value:
type: "string"
description: "Value for your secret, encrypted with LibSodium using the public key retrieved from the Get an environment public key endpoint."
required: true
key_id:
type: "string"
description: "ID of the key you used to encrypt the secret."
required: true
response_codes:
201:
description: "Response when creating a secret"
204:
description: "Response when updating a secret"
request_example:
method: "PUT"
url: "/repos/{owner}/{repo}/environments/{environment_name}/secrets/{secret_name}"
headers:
- "Accept: application/vnd.github+json"
- "Authorization: Bearer <YOUR-TOKEN>"
- "X-GitHub-Api-Version: 2022-11-28"
body: |
{
"encrypted_value": "c2VjcmV0",
"key_id": "012345678912345678"
}
response_examples:
201:
description: "Response when creating a secret"
204:
description: "Response when updating a secret"