Sample - GitHub REST API
PUT/orgs/{org}/actions/variables/{name}/repositories/{repository_id}

Add a repository to an organization variable

Adds a repository to an organization variable that is available to selected repositories. Use this endpoint when the variable's visibility is set to selected, and ensure the authenticated user has collaborator access to the repository. OAuth tokens and classic personal access tokens require the admin:org scope, plus the repo scope for private repositories.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

3 parameters
orgstringrequired
The organization name; matching is case-insensitive.
namestringrequired
The name of the organization variable.
repository_idintegerrequired
The numeric identifier of the repository to add to the organization variable.

2 status codes
204Returns no content after the repository is added to the organization variable.
409Returned when the variable's visibility is not set to `selected`.

Error handling

A 409 is returned when the variable's visibility is not set to selected. The authenticated user must have collaborator access to the repository, and the token must include admin:org plus repo when the repository is private.