Environments
Preview

Set an environment's protected-branch guardrail

PUT
/environments/{environmentId}/branch-guard
cookiebetter-auth.session_token<token>

Better Auth session cookie. Production uses the __Secure- prefixed name.

environmentId*string
Formatuuid
Idempotency-Key?string

Makes retries safe. A repeated key with the same request returns the first result and sets Idempotent-Replayed: true. The same key with a different request answers 409 idempotency.key_reused, and while the first request is still running 409 idempotency.in_progress. Results are kept for 24 hours. Server errors and refusals for lack of sign-in or permission are not kept, so a retry runs again.

Match^[A-Za-z0-9_.:-]+$
Length1 <= length <= 255
application/json
  1. body
enforced*boolean
protectedBranch?string
Lengthlength <= 255
Default""

Response Body

The guardrail as saved.

application/json
  1. response
enforced*boolean
protectedBranch*string

The branch snapshots must come from. Empty means the branch the git host protects.

isDefault*boolean

True when nobody set it and the environment's class decides.

Example Request
curl -X PUT 'https://wardn.example.com/api/v1/environments/497f6eca-6276-4993-bfeb-53cbbbba6f08/branch-guard' \  -H 'Content-Type: application/json' \  -d '{  "enforced": true}'
Example Response
{  "enforced": true,  "protectedBranch": "string",  "isDefault": true}