Set main branch protection

<Info>This API is in beta. Endpoints, fields, and behavior may still change, so avoid depending on it in production.</Info>

Turns protection of the app's main branch on or off.

While main is protected, calls that change main directly are refused with a 409, and the builder's AI can't edit main either. Make changes on a branch and merge it back instead. Setting the value the app already has changes nothing. Read the current value from main_branch_protected in Get app.

Only the app owner or an admin of the app's workspace can change it. Editors can't, even though they can edit the app. This endpoint is limited to 10 requests per minute.

<Note>This endpoint accepts a personal API key belonging to the app owner or a workspace admin. A read-only key is refused, and workspace API keys are not accepted.</Note>

put/api/apps/{app_id}/branches/main/protection

Path parameters

app_idstring required

ID of the app whose main branch to protect or unprotect.

ID of the app whose main branch to protect or unprotect.

Request body

protectedboolean required

Whether the app's main branch is protected. While it is, changes to main have to go through a branch that you merge back.

Example request

{
  "protected": true
}

Response

The main branch's protection after the change.

protectedboolean required

Whether the app's main branch is protected. While it is, changes to main have to go through a branch that you merge back.

Example response

{
  "protected": true
}

Changes

Changed in 1 of the 14 revisions of this API.1