Skip to content

Update a protected branch rule

PUT /api/v5/repos/{owner}/{repo}/branches/{wildcard}/setting

Updates the rule of a specific protected branch in the specified repository. By setting the members who may push code and the members who may merge requests, it controls push and merge permissions.

Supported access tokens

  • AtomGit user access tokens

Anonymous access allowed

This endpoint does not allow anonymous access.

Request parameters

Parameter Location Type Required Description
owner path string Yes Namespace address to which the repository belongs (address path of the organization or user)
repo path string Yes Repository path (path)
wildcard path string Yes Protected branch name
access_token query string Yes User authorization code

Request Body:

The request body is a JSON object containing the protected branch rule to update. Both pusher and merger are required fields.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "pusher": {
      "description": "Members who may push code. develop: repository administrators and developers; admin: repository administrators; maintainer: maintainers; separate multiple roles with a semicolon; to specify users, pass their usernames separated by semicolons; an empty string means nobody may push",
      "type": "string"
    },
    "merger": {
      "description": "Members who may merge pull requests. develop: repository administrators and developers; admin: repository administrators; maintainer: maintainers; separate multiple roles with a semicolon; to specify users, pass their usernames separated by semicolons; an empty string means nobody may merge",
      "type": "string"
    }
  },
  "required": ["pusher", "merger"]
}

Response parameters

On success the response body is an empty object {} with no response fields.

Error response

Callers need to know what an error response looks like in order to write error handling. The field names in the examples below follow what the backend actually returns.

400 Invalid parameters

{
  "error": "invalid_request",
  "message": "Parameter pusher cannot be empty"
}

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Missing or invalid access token"
}

HTTP status codes

Status code Description
200 Success (OK)
400 Invalid parameters (Bad request)
401 Authentication required (Requires authentication)
403 Access forbidden (Forbidden)
404 Resource does not exist (Not found)
500 Internal system error (Internal server error)

Request example

Parameter notes

The example is consistent with the rest of this page and can be used as-is. The placeholders mean:

Replace <owner> with the namespace address to which the repository belongs (address path of the organization or user); replace <repo> with the repository path (path); replace <wildcard> with the protected branch name; replace <token> with your AtomGit user access token.

cURL

curl -X PUT 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/branches/<wildcard>/setting?access_token=<token>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{
    "pusher": "admin",
    "merger": "develop"
  }'

JavaScript

// Native fetch (Node.js 18+ / browsers)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/branches/<wildcard>/setting?access_token=<token>", {
  method: "PUT",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    pusher: "admin",
    merger: "develop",
  }),
});

if (!response.ok) {
  throw new Error(`Request failed: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.put(
    "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/branches/<wildcard>/setting?access_token=<token>",
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
    },
    json={
        "pusher": "admin",
        "merger": "develop",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{}

Error codes

Error code Description
400 Invalid parameters or the request cannot be parsed
401 Unauthenticated or invalid credentials (missing or invalid access credentials)
403 Access forbidden (no permission to perform this operation)
404 The requested resource (repository or branch) does not exist
500 Internal system error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc