Skip to content
Connect an agent

Auth

Exchange a GitHub Actions ID token for a Plotwork token

For CI.

POST/oidc/token

TL;DR

QuestionAnswer
What does it do?Exchange a GitHub Actions ID token for a Plotwork token.
What does it take?A JSON body of type OidcTokenBody.
What does it return?Status 200 with a body of type OidcToken.
What can go wrong?400 the body is not valid; 401 the ID token failed a check (oidc.token_invalid), or was exchanged already (oidc.token_reused); 403 no trusted publisher trusts this run (oidc.no_trusted_publisher), the organisation's plan has none (plan.trusted_publishers_not_included), or its owner is suspended (auth.account_suspended); 409 several organisations trust this run; name one (oidc.organization_required); 429 too many requests; 503 exchanging is not available on this server, or GitHub's keys cannot be read at the moment (oidc.unavailable). Every failure uses the one error envelope.

What it does

For CI. A job of a workflow an organisation trusts sends the ID token GitHub gave it, with this API's origin as the audience. It is checked against GitHub's keys and the organisation's trusted publishers, and the answer is a token that acts as that trusted publisher for 15 minutes on the routes the GitHub Action calls. Only hashes are stored; one ID token is exchanged once. A refusal never says which check failed; the organisation's audit log does.

Request body

The body has the type OidcTokenBody.

FieldTypeRequiredDescription
tokenstringyesThe job's GitHub Actions ID token, asked for with this API's origin as the audience. at least 1 character; at most 16384 characters.
organizationstringnoThe organisation to sign in to, by slug or id. Needed only when several organisations trust the run. at least 1 character; at most 64 characters.

Responses

StatusMeaningBody
200The Plotwork token, when it stops working, and who it acts as.OidcToken
400The body is not valid.ErrorResponse
401The ID token failed a check (oidc.token_invalid), or was exchanged already (oidc.token_reused).ErrorResponse
403No trusted publisher trusts this run (oidc.no_trusted_publisher), the organisation's plan has none (plan.trusted_publishers_not_included), or its owner is suspended (auth.account_suspended).ErrorResponse
409Several organisations trust this run; name one (oidc.organization_required).ErrorResponse
429Too many requests.ErrorResponse
503Exchanging is not available on this server, or GitHub's keys cannot be read at the moment (oidc.unavailable).ErrorResponse

Response body

A 200 answer has the type OidcToken.

FieldTypeRequiredDescription
tokenstringyesA Plotwork token, pwo_ and 64 hex characters. Send it as X-API-Key or Authorization: Bearer. Never stored by Plotwork, only its hash.
tokenType"Bearer"yes
expiresAtintegeryesWhen it stops working, in milliseconds since the epoch.
expiresInintegeryesSeconds until it stops working.
organizationobjectyes
organization.idstringyes
organization.slugstringyes
organization.namestringyes
publisherobjectyes
publisher.idstringyes
publisher.namestringyes
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.

See also

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