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

Add a selected repository to an organization variable

Adds a repository to an organization agent variable that is available to selected repositories. Use org, name, and repository_id to identify the organization variable and repository, and ensure the variable visibility is set to selected. Use an OAuth token or classic personal access token with the admin:org scope, and add the repo scope when the repository is private.

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

3 parameters
orgstringrequired
The organization name. The name is not case sensitive.
namestringrequired
The name of the organization agent variable.
repository_idintegerrequired
The numeric identifier of the repository to add to the variable.

2 status codes
204Returns no content after adding the repository 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 OAuth tokens or classic personal access tokens must include admin:org; private repositories also require repo.