Skip to main content
The REST API is now versioned. For more information, see "About API versioning."

REST API endpoints for GitHub Actions variables

Use the REST API to interact with variables in GitHub Actions.

About variables in GitHub Actions

You can use the REST API to create, update, delete, and retrieve information about variables that can be used in workflows in GitHub Actions. Variables allow you to store non-sensitive information, such as a username, in your repository, repository environments, or organization. For more information, see Store information in variables in the GitHub Actions documentation.

List organization variables

Lists all organization 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 admin:org scope to use this endpoint. If the repository is private, the repo scope is also required.

Fine-grained access tokens for "List organization variables"

This endpoint works with the following fine-grained token types:

The fine-grained token must have the following permission set:

  • "Variables" organization permissions (read)

Parameters for "List organization variables"

Headers
Name, Type, Description
accept string

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

Path parameters
Name, Type, Description
org string Required

The organization name. The name is not case sensitive.

Query parameters
Name, Type, Description
per_page integer

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

Default: 10

page integer

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

Default: 1

HTTP response status codes for "List organization variables"

Status codeDescription
200

OK

Code samples for "List organization variables"

Request example

get/orgs/{org}/actions/variables
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ http(s)://HOSTNAME/api/v3/orgs/ORG/actions/variables

Response

Status: 200
{ "total_count": 3, "variables": [ { "name": "USERNAME", "value": "octocat", "created_at": "2019-08-10T14:59:22Z", "updated_at": "2020-01-10T14:59:22Z", "visibility": "private" }, { "name": "ACTIONS_RUNNER_DEBUG", "value": true, "created_at": "2019-08-10T14:59:22Z", "updated_at": "2020-01-10T14:59:22Z", "visibility": "all" }, { "name": "ADMIN_EMAIL", "value": "octocat@github.com", "created_at": "2019-08-10T14:59:22Z", "updated_at": "2020-01-10T14:59:22Z", "visibility": "selected", "selected_repositories_url": "https://HOSTNAME/orgs/octo-org/actions/variables/ADMIN_EMAIL/repositories" } ] }

Create an organization variable

Creates an organization 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 theadmin: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.

Fine-grained access tokens for "Create an organization variable"

This endpoint works with the following fine-grained token types:

The fine-grained token must have the following permission set:

  • "Variables" organization permissions (write)

Parameters for "Create an organization variable"

Headers
Name, Type, Description
accept string

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

Path parameters
Name, Type, Description
org string Required

The organization name. The name is not case sensitive.

Body parameters
Name, Type, Description
name string Required

The name of the variable.

value string Required

The value of the variable.

visibility string Required

The type of repositories in the organization that can access the variable. selected means only the repositories specified by selected_repository_ids can access the variable.

Can be one of: all, private, selected

selected_repository_ids array of integers

An array of repository ids that can access the organization variable. You can only provide a list of repository ids when the visibility is set to selected.

HTTP response status codes for "Create an organization variable"

Status codeDescription
201

Response when creating a variable

Code samples for "Create an organization variable"

Request example

post/orgs/{org}/actions/variables
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ http(s)://HOSTNAME/api/v3/orgs/ORG/actions/variables \ -d '{"name":"USERNAME","value":"octocat","visibility":"selected","selected_repository_ids":[1296269,1296280]}'

Response when creating a variable

Status: 201

Get an organization variable

Gets a specific 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 theadmin: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.

Fine-grained access tokens for "Get an organization variable"

This endpoint works with the following fine-grained token types:

The fine-grained token must have the following permission set:

  • "Variables" organization permissions (read)

Parameters for "Get an organization variable"

Headers
Name, Type, Description
accept string

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

Path parameters
Name, Type, Description
org string Required

The organization name. The name is not case sensitive.

name string Required

The name of the variable.

HTTP response status codes for "Get an organization variable"

Status codeDescription
200

OK

Code samples for "Get an organization variable"

Request example

get/orgs/{org}/actions/variables/{name}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ http(s)://HOSTNAME/api/v3/orgs/ORG/actions/variables/NAME

Response

Status: 200
{ "name": "USERNAME", "value": "octocat", "created_at": "2019-08-10T14:59:22Z", "updated_at": "2020-01-10T14:59:22Z", "visibility": "selected", "selected_repositories_url": "https://HOSTNAME/orgs/octo-org/actions/variables/USERNAME/repositories" }

Update an organization variable

Updates an organization 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.

Fine-grained access tokens for "Update an organization variable"

This endpoint works with the following fine-grained token types:

The fine-grained token must have the following permission set:

  • "Variables" organization permissions (write)

Parameters for "Update an organization variable"

Headers
Name, Type, Description
accept string

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

Path parameters
Name, Type, Description
org string Required

The organization name. The name is not case sensitive.

name string Required

The name of the variable.

Body parameters
Name, Type, Description
name string

The name of the variable.

value string

The value of the variable.

visibility string

The type of repositories in the organization that can access the variable. selected means only the repositories specified by selected_repository_ids can access the variable.

Can be one of: all, private, selected

selected_repository_ids array of integers

An array of repository ids that can access the organization variable. You can only provide a list of repository ids when the visibility is set to selected.

HTTP response status codes for "Update an organization variable"

Status codeDescription
204

No Content

Code samples for "Update an organization variable"

Request example

patch/orgs/{org}/actions/variables/{name}
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ http(s)://HOSTNAME/api/v3/orgs/ORG/actions/variables/NAME \ -d '{"name":"USERNAME","value":"octocat","visibility":"selected","selected_repository_ids":[1296269,1296280]}'

Response

Status: 204

Delete an organization variable

Deletes an organization 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 theadmin: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.

Fine-grained access tokens for "Delete an organization variable"

This endpoint works with the following fine-grained token types:

The fine-grained token must have the following permission set:

  • "Variables" organization permissions (write)

Parameters for "Delete an organization variable"

Headers
Name, Type, Description
accept string

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

Path parameters
Name, Type, Description
org string Required

The organization name. The name is not case sensitive.

name string Required

The name of the variable.

HTTP response status codes for "Delete an organization variable"

Status codeDescription
204

No Content

Code samples for "Delete an organization variable"

Request example

delete/orgs/{org}/actions/variables/{name}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ http(s)://HOSTNAME/api/v3/orgs/ORG/actions/variables/NAME

Response

Status: 204

List selected repositories for an organization variable

Lists all repositories that can access an organization 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.

Fine-grained access tokens for "List selected repositories for an organization variable"

This endpoint works with the following fine-grained token types:

The fine-grained token must have the following permission set:

  • "Variables" organization permissions (read)

Parameters for "List selected repositories for an organization variable"

Headers
Name, Type, Description
accept string

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

Path parameters
Name, Type, Description
org string Required

The organization name. The name is not case sensitive.

name string Required

The name of the variable.

Query parameters
Name, Type, Description
page integer

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

Default: