REST API endpoints for agent secrets

Use the REST API to manage secrets for agents.

Note

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.

List organization secrets

GET /orgs/{org}/agents/secrets

Lists all secrets available in an organization without revealing their
encrypted values.
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint. If the repository is private, the repo scope is also required.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/agents/secrets

Response schema (Status: 200):

Get an organization public key

GET /orgs/{org}/agents/secrets/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.
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint. If the repository is private, the repo scope is also required.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/agents/secrets/public-key

Response schema (Status: 200):

Get an organization secret

GET /orgs/{org}/agents/secrets/{secret_name}

Gets a single organization secret without revealing its encrypted value.
The authenticated user must have collaborator access to a repository to create, update, or read secrets.
OAuth tokens and personal access tokens (classic) need the admin:org scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/agents/secrets/SECRET_NAME

Response schema (Status: 200):

Create or update an organization secret

PUT /orgs/{org}/agents/secrets/{secret_name}

Creates or updates an organization secret with an encrypted value. Encrypt your secret using
LibSodium. For more information, see "Encrypting secrets for the REST API."
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth tokens and personal access tokens (classic) need the admin:org scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example 1: Status Code 201

Request:

curl -L \
  -X PUT \
  https://api.github.com/orgs/ORG/agents/secrets/SECRET_NAME \
  -d '{
  "encrypted_value": "c2VjcmV0",
  "key_id": "012345678912345678",
  "visibility": "selected",
  "selected_repository_ids": [
    1296269,
    1296280
  ]
}'

Response schema (Status: 201):

Example 2: Status Code 204

Request:

curl -L \
  -X PUT \
  https://api.github.com/orgs/ORG/agents/secrets/SECRET_NAME \
  -d '{
  "encrypted_value": "c2VjcmV0",
  "key_id": "012345678912345678",
  "visibility": "selected",
  "selected_repository_ids": [
    1296269,
    1296280
  ]
}'

Response schema (Status: 204):

Delete an organization secret

DELETE /orgs/{org}/agents/secrets/{secret_name}

Deletes a secret in an organization using the secret name.
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth tokens and personal access tokens (classic) need the admin:org scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/orgs/ORG/agents/secrets/SECRET_NAME

Response schema (Status: 204):

List selected repositories for an organization secret

GET /orgs/{org}/agents/secrets/{secret_name}/repositories

Lists all repositories that have been selected when the visibility
for repository access to a secret is set to selected.
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint. If the repository is private, the repo scope is also required.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/orgs/ORG/agents/secrets/SECRET_NAME/repositories

Response schema (Status: 200):

Set selected repositories for an organization secret

PUT /orgs/{org}/agents/secrets/{secret_name}/repositories

Replaces all repositories for an organization secret when the visibility
for repository access is set to selected. The visibility is set when you Create
or update an organization secret.
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint. If the repository is private, the repo scope is also required.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X PUT \
  https://api.github.com/orgs/ORG/agents/secrets/SECRET_NAME/repositories \
  -d '{
  "selected_repository_ids": [
    64780797
  ]
}'

Response schema (Status: 204):

Add selected repository to an organization secret

PUT /orgs/{org}/agents/secrets/{secret_name}/repositories/{repository_id}

Adds a repository to an organization secret when the visibility for
repository access is set to selected. For more information about setting the visibility, see Create or
update an organization secret.
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth tokens and personal access tokens (classic) need the admin:org scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X PUT \
  https://api.github.com/orgs/ORG/agents/secrets/SECRET_NAME/repositories/REPOSITORY_ID

Response schema (Status: 204):

Remove selected repository from an organization secret

DELETE /orgs/{org}/agents/secrets/{secret_name}/repositories/{repository_id}

Removes a repository from an organization secret when the visibility
for repository access is set to selected. The visibility is set when you Create
or update an organization secret.
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint. If the repository is private, the repo scope is also required.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/orgs/ORG/agents/secrets/SECRET_NAME/repositories/REPOSITORY_ID

Response schema (Status: 204):

List repository organization secrets

GET /repos/{owner}/{repo}/agents/organization-secrets

Lists all organization secrets shared with a repository without revealing their encrypted
values.
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/agents/organization-secrets

Response schema (Status: 200):

List repository secrets

GET /repos/{owner}/{repo}/agents/secrets

Lists all secrets available in a repository without revealing their encrypted
values.
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/agents/secrets

Response schema (Status: 200):

Same response schema as List repository organization secrets.

Get a repository public key

GET /repos/{owner}/{repo}/agents/secrets/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 tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/agents/secrets/public-key

Response schema (Status: 200):

Same response schema as Get an organization public key.

Get a repository secret

GET /repos/{owner}/{repo}/agents/secrets/{secret_name}

Gets a single repository secret without revealing its encrypted value.
The authenticated user must have collaborator access to the repository to use this endpoint.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/agents/secrets/SECRET_NAME

Response schema (Status: 200):

Create or update a repository secret

PUT /repos/{owner}/{repo}/agents/secrets/{secret_name}

Creates or updates a repository secret with an encrypted value. Encrypt your secret using
LibSodium. For more information, see "Encrypting secrets for the REST API."
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example 1: Status Code 201

Request:

curl -L \
  -X PUT \
  https://api.github.com/repos/OWNER/REPO/agents/secrets/SECRET_NAME \
  -d '{
  "encrypted_value": "c2VjcmV0",
  "key_id": "012345678912345678"
}'

Response schema (Status: 201):

Example 2: Status Code 204

Request:

curl -L \
  -X PUT \
  https://api.github.com/repos/OWNER/REPO/agents/secrets/SECRET_NAME \
  -d '{
  "encrypted_value": "c2VjcmV0",
  "key_id": "012345678912345678"
}'

Response schema (Status: 204):

Delete a repository secret

DELETE /repos/{owner}/{repo}/agents/secrets/{secret_name}

Deletes a secret in a repository using the secret name.
Authenticated users must have collaborator access to a repository to create, update, or read secrets.
OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/repos/OWNER/REPO/agents/secrets/SECRET_NAME

Response schema (Status: 204):