Skip to content
Connect an agent

Organisations

Change a trusted publisher

Replaces what one trusted publisher trusts and may do.

PUT/orgs/{org}/trusted-publishers/{id}

TL;DR

QuestionAnswer
What does it do?Change a trusted publisher.
What does it take?A JSON body of type TrustedPublisherBody.
What does it return?Status 200 with a body of type TrustedPublisher.
What can go wrong?400 the body is not valid; 401 not signed in; 403 a member may not (orgs.forbidden), the plan has no trusted publishers (plan.trusted_publishers_not_included), or the request came from an origin that may not make changes; 404 no such organisation or trusted publisher, or the caller is not a member of the organisation; 409 another entry already trusts that run (trusted_publishers.duplicate); 422 GitHub has no such account, or names the repository another (trusted_publishers.invalid); 429 too many requests; 503 organisations are not set up on this server. Every failure uses the one error envelope.

What it does

Replaces what one trusted publisher trusts and may do. A new repository is asked of GitHub again; otherwise the pinned ids stay. When what it trusts or may do changes, the tokens it gave stop working. The owner and an admin, on Pro and Enterprise.

Path parameters

FieldTypeRequiredDescription
orgstringyesThe organisation's id or its slug.
idstringyes

Request body

The body has the type TrustedPublisherBody.

FieldTypeRequiredDescription
namestringnoA name to recognise it by in the usage, the call history and the audit log. Left out or blank, the repository name and the workflow. at most 60 characters.
provider"github"noThe CI provider. github, the default, is the only one.
repositorystringyesThe repository, owner/name. at most 140 characters.
workflowstringyesThe workflow file in .github/workflows, with no folder. at most 100 characters.
environmentstring | nullnoThe deployment environment the job must run in. Left out, null or blank, any job of the workflow. at most 255 characters.
refstring | nullnoA branch (main) or a ref pattern (refs/tags/v*, * for any characters) the run must be for. Left out, null or blank, any ref. at most 255 characters.
permissions("diagrams" | "drift:write")[]noWhat its runs may do. Left out, both.

Responses

StatusMeaningBody
200The trusted publisher as it is now.TrustedPublisher
400The body is not valid.ErrorResponse
401Not signed in.ErrorResponse
403A member may not (orgs.forbidden), the plan has no trusted publishers (plan.trusted_publishers_not_included), or the request came from an origin that may not make changes.ErrorResponse
404No such organisation or trusted publisher, or the caller is not a member of the organisation.ErrorResponse
409Another entry already trusts that run (trusted_publishers.duplicate).ErrorResponse
422GitHub has no such account, or names the repository another (trusted_publishers.invalid).ErrorResponse
429Too many requests.ErrorResponse
503Organisations are not set up on this server.ErrorResponse

Response body

A 200 answer has the type TrustedPublisher.

FieldTypeRequiredDescription
idstringyes
namestringyes
provider"github"yes
repositorystringyesThe repository, owner/name.
repositoryIdstring | nullyesGitHub's id of the repository, which a run's token must carry. Null until known: a private repository's is pinned by its first run.
repositoryOwnerIdstring | nullyesGitHub's id of the repository's owner, which a run's token must carry. Null until known.
workflowstringyesThe workflow file in .github/workflows the run must start from.
environmentstring | nullyesThe deployment environment the job must run in, or null for any.
refstring | nullyesThe ref pattern the run must match, such as refs/heads/main, or null for any ref.
permissions("diagrams" | "drift:write")[]yesdiagrams: publish to the organisation's library (and read it and the style rules). drift:write: report drift runs to the Drift tab and read the style rules.
createdAtintegeryesMilliseconds since the epoch.
createdByobject | nullyesWho added it, or null when that account is gone.
createdBy.idstringyes
createdBy.emailstringyes
updatedAtintegeryesMilliseconds since the epoch.
lastUsedAtinteger | nullyesWhen a run last signed in with it, in milliseconds since the epoch, or null for never.

See also

DocWhy
API referenceEvery endpoint, and the error envelope
SchemasEvery request and response type
Tool referenceThe operations as callable tools