REST API endpoints for variables

Use the REST API to manage variables.

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 variables

GET /orgs/{org}/agents/variables

Lists all agent variables available in an organization.
Returned variables include their values.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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/variables

Response schema (Status: 200):

Create an organization variable

POST /orgs/{org}/agents/variables

Creates an organization agent variable that you can reference in a GitHub Actions workflow.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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

Request:

curl -L \
  -X POST \
  https://api.github.com/orgs/ORG/agents/variables \
  -d '{
  "name": "USERNAME",
  "value": "octocat",
  "visibility": "selected",
  "selected_repository_ids": [
    1296269,
    1296280
  ]
}'

Response schema (Status: 201):

Get an organization variable

GET /orgs/{org}/agents/variables/{name}

Gets a specific agent variable in an organization.
The authenticated user must have collaborator access to a repository to create, update, or read variables.
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/variables/NAME

Response schema (Status: 200):

Update an organization variable

PATCH /orgs/{org}/agents/variables/{name}

Updates an organization agent variable that you can reference in a GitHub Actions workflow.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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 PATCH \
  https://api.github.com/orgs/ORG/agents/variables/NAME \
  -d '{
  "name": "USERNAME",
  "value": "octocat",
  "visibility": "selected",
  "selected_repository_ids": [
    1296269,
    1296280
  ]
}'

Response schema (Status: 204):

Delete an organization variable

DELETE /orgs/{org}/agents/variables/{name}

Deletes an organization agent variable using the variable name.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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/variables/NAME

Response schema (Status: 204):

List selected repositories for an organization variable

GET /orgs/{org}/agents/variables/{name}/repositories

Lists all repositories that can access an organization agent variable
that is available to selected repositories.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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/variables/NAME/repositories

Response schema (Status: 200):

Set selected repositories for an organization variable

PUT /orgs/{org}/agents/variables/{name}/repositories

Replaces all repositories for an organization agent variable that is available
to selected repositories. Organization variables that are available to selected
repositories have their visibility field set to selected.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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/variables/NAME/repositories \
  -d '{
  "selected_repository_ids": [
    64780797
  ]
}'

Response schema (Status: 204):

Add selected repository to an organization variable

PUT /orgs/{org}/agents/variables/{name}/repositories/{repository_id}

Adds a repository to an organization agent variable that is available to selected repositories.
Organization variables that are available to selected repositories have their visibility field set to selected.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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/variables/NAME/repositories/REPOSITORY_ID

Response schema (Status: 204):

Remove selected repository from an organization variable

DELETE /orgs/{org}/agents/variables/{name}/repositories/{repository_id}

Removes a repository from an organization agent variable that is
available to selected repositories. Organization variables that are available to
selected repositories have their visibility field set to selected.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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/variables/NAME/repositories/REPOSITORY_ID

Response schema (Status: 204):

List repository organization variables

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

Lists all organization variables shared with a repository.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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-variables

Response schema (Status: 200):

List repository variables

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

Lists all repository variables.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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/variables

Response schema (Status: 200):

Same response schema as List repository organization variables.

Create a repository variable

POST /repos/{owner}/{repo}/agents/variables

Creates a repository variable that you can reference in a GitHub Actions workflow.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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

Request:

curl -L \
  -X POST \
  https://api.github.com/repos/OWNER/REPO/agents/variables \
  -d '{
  "name": "USERNAME",
  "value": "octocat"
}'

Response schema (Status: 201):

Get a repository variable

GET /repos/{owner}/{repo}/agents/variables/{name}

Gets a specific variable in a repository.
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/variables/NAME

Response schema (Status: 200):

Update a repository variable

PATCH /repos/{owner}/{repo}/agents/variables/{name}

Updates a repository variable that you can reference in a GitHub Actions workflow.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
OAuth app 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

Request:

curl -L \
  -X PATCH \
  https://api.github.com/repos/OWNER/REPO/agents/variables/NAME \
  -d '{
  "name": "USERNAME",
  "value": "octocat"
}'

Response schema (Status: 204):

Delete a repository variable

DELETE /repos/{owner}/{repo}/agents/variables/{name}

Deletes a repository variable using the variable name.
Authenticated users must have collaborator access to a repository to create, update, or read variables.
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/variables/NAME

Response schema (Status: 204):