Skip to content
Connect an agent

Organisations

Add a trusted publisher

Trusts one GitHub Actions workflow of one repository to act for the organisation with no API key, by the ID token GitHub gives each job, exchanged at POST /oidc/token.

POST/orgs/{org}/trusted-publishers

TL;DR

QuestionAnswer
What does it do?Add a trusted publisher.
What does it take?A JSON body of type TrustedPublisherBody.
What does it return?Status 201 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 the caller is not a member of it; 409 the organisation already trusts that run (trusted_publishers.duplicate), or has twenty (trusted_publishers.limit_reached); 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

Trusts one GitHub Actions workflow of one repository to act for the organisation with no API key, by the ID token GitHub gives each job, exchanged at POST /oidc/token. environment and ref narrow it; permissions is diagrams, drift:write or both. GitHub's ids for the repository and its owner are pinned. At most twenty. The owner and an admin, on Pro and Enterprise.

Path parameters

FieldTypeRequiredDescription
orgstringyesThe organisation's id or its slug.

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
201The new trusted publisher.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 the caller is not a member of it.ErrorResponse
409The organisation already trusts that run (trusted_publishers.duplicate), or has twenty (trusted_publishers.limit_reached).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 201 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