---
title: "Create or update a repository secret"
method: PUT
path: "/repos/{owner}/{repo}/actions/secrets/{secret_name}"
tags: ["actions"]
---

# Create or update a repository secret

`PUT /repos/{owner}/{repo}/actions/secrets/{secret_name}`

Creates or updates a repository secret with an encrypted value. Encrypt your secret using
[LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see "[Encrypting secrets for the REST API](https://docs.github.com/enterprise-server@3.6/rest/guides/encrypting-secrets-for-the-rest-api)."

You must authenticate using an access token with the `repo` scope to use this endpoint.
GitHub Apps must have the `secrets` repository permission to use this endpoint.
Authenticated users must have collaborator access to a repository to create, update, or read secrets.

## Path parameters

- `owner` string, required
- `repo` string, required
- `secret_name` string, required

## Request body

- object
  - `encrypted_value` string — Value for your secret, encrypted with [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages) using the public key retrieved from the [Get a repository public key](https://docs.github.com/enterprise-server@3.6/rest/actions/secrets#get-a-repository-public-key) endpoint.
  - `key_id` string — ID of the key you used to encrypt the secret.

## Response `201`

Response when creating a secret

- EmptyObject — An object without any properties.

## Other responses

- `204` — Response when updating a secret

---

[API](https://skmtc.net/github/apis/github-v3-rest-api-5.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api-5/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api-5/versions/50ae54440071/schema)
