Trust one GitHub repository's workflows to deploy into a project. Exchanged tokens act with the creator's authority, capped at `role`.
const url = 'https://example.com/api/v1/ci/trust-policies';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"name":"shop-deploy","project":"shop","environment":"example","repository":"acme/shop","repositoryId":1,"repositoryOwnerId":1,"refs":["example"],"environments":["example"],"events":["example"],"role":"example","tokenTtlSecs":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/v1/ci/trust-policies \ --header 'Content-Type: application/json' \ --data '{ "name": "shop-deploy", "project": "shop", "environment": "example", "repository": "acme/shop", "repositoryId": 1, "repositoryOwnerId": 1, "refs": [ "example" ], "environments": [ "example" ], "events": [ "example" ], "role": "example", "tokenTtlSecs": 1 }'Request Bodyrequired
Section titled “Request Bodyrequired”object
Unique in the organization, 1–64 characters.
Example
shop-deployExample
shopNarrows the tokens to one environment of project.
owner/name, for people; the ids decide.
Example
acme/shopGitHub’s numeric repository id (repository_id claim).
GitHub’s numeric owner id (repository_owner_id claim).
refs/heads/main, refs/tags/v*, …
GitHub environments allowed; empty for any.
Workflow events allowed; push, workflow_dispatch and release
when empty.
developer (deploy) or admin (deploy and promote).
Life of an exchanged token, 60–3600 seconds (default 900).
Responses
Section titled “Responses”object
Examplegenerated
{ "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "name": "example", "project": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "environment": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "repository": "example", "repositoryId": 1, "repositoryOwnerId": 1, "refs": [ "example" ], "environments": [ "example" ], "events": [ "example" ], "role": "example", "tokenTtlSecs": 1, "createdBy": "example", "createdAt": 1, "revokedAt": 1}Problem Details body.
object
Stable machine-readable code, e.g. forbidden.
Short human readable title.
HTTP status.
Details, if safe to expose.
Example
{ "code": "forbidden"}Problem Details body.
object
Stable machine-readable code, e.g. forbidden.
Short human readable title.
HTTP status.
Details, if safe to expose.
Example
{ "code": "forbidden"}The name is taken
Problem Details body.
object
Stable machine-readable code, e.g. forbidden.
Short human readable title.
HTTP status.
Details, if safe to expose.
Example
{ "code": "forbidden"}Problem Details body.
object
Stable machine-readable code, e.g. forbidden.
Short human readable title.
HTTP status.
Details, if safe to expose.
Example
{ "code": "forbidden"}