Change the environment's protection policy. Stricter policies need `env-write`; anything weaker needs an owner.
const url = 'https://example.com/api/v1/projects/example/environments/example/policy';const options = { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: '{"requiredApprovals":1,"deployRole":"developer","approveRole":"admin","approvalTtlSecs":604800,"scan":{"mode":"block","severity":"critical","requireScan":true,"maxAgeSecs":604800}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://example.com/api/v1/projects/example/environments/example/policy \ --header 'Content-Type: application/json' \ --data '{ "requiredApprovals": 1, "deployRole": "developer", "approveRole": "admin", "approvalTtlSecs": 604800, "scan": { "mode": "block", "severity": "critical", "requireScan": true, "maxAgeSecs": 604800 } }'Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Project name
Environment short name
Request Bodyrequired
Section titled “Request Bodyrequired”object
Distinct approvers a deployment needs (0–5).
Example
1The weakest role that may deploy: developer, admin or owner.
Example
developerThe weakest role that may approve: admin or owner.
Example
adminHow long a deployment waits for approvals (300 s – 30 days).
Example
604800The vulnerability gate; the current one is kept when omitted.
object
off, warn or block.
Example
blockFindings at or above this severity count: high or critical.
Example
criticalAn image without a fresh successful scan counts as a finding.
A scan older than this no longer counts (1 hour – 90 days).
Example
604800Responses
Section titled “Responses”object
0 when the environment has no policy of its own yet.
What vulnerability findings a deployment may carry.
object
off, warn or block.
Findings at or above this severity count: high or critical.
An image without a fresh successful scan counts as a finding.
A scan older than this no longer counts (1 hour – 90 days).
Example
{ "scan": { "mode": "block", "severity": "critical", "maxAgeSecs": 604800 }}Weakening needs an owner; tokens cannot change policies
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"}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"}