Skip to content

Set project push rules

PUT /api/v5/repos/{owner}/{repo}/push_config

Call this endpoint to set the project push rules.

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)
access_token query string Yes User authorization code

Request Body:

The request body is JSON (Content-Type: application/json), and form submission is also supported (application/x-www-form-urlencoded / multipart/form-data). Submit only the rule fields you want to change and leave the rest empty.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "reject_not_signed_by_gpg": {
      "description": "Only allow signed commits with a verified signature",
      "type": "boolean"
    },
    "commit_message_regex": {
      "description": "Commit message validation (regular expression)",
      "type": "string"
    },
    "max_file_size": {
      "description": "Committed file size limit (in MB)",
      "type": "integer",
      "format": "int64"
    },
    "skip_rule_for_owner": {
      "description": "Commits by project administrators are exempt from the rules above",
      "type": "boolean"
    },
    "deny_force_push": {
      "description": "Forbid force pushes (including by administrators)",
      "type": "boolean"
    }
  }
}

Response parameters

Field Type Always returned Nullable Description
reject_not_signed_by_gpg boolean No Yes Only allow signed commits with a verified signature
commit_message_regex string No Yes Commit message validation
max_file_size integer No Yes Committed file size limit (in MB)
skip_rule_for_owner boolean No Yes Commits by project administrators are exempt from the rules above
deny_force_push boolean No Yes Forbid force pushes (including by administrators)

Error response

400 Invalid parameters

{
  "error": "invalid_request",
  "message": "Failed to parse the request body or the content-type is not supported"
}

401 Unauthenticated

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

403 No permission

{
  "error": "forbidden",
  "message": "The current user has no permission to set the push rules of this project"
}

HTTP status codes

Status code Description
200 Success (OK)
400 Invalid request parameters or the request body cannot be parsed
401 Authentication required (Requires authentication)
403 Access forbidden (Forbidden); the current user has no permission for this operation
404 Request path does not exist
405 Request method not supported
429 Too many requests; rate limit triggered
500 Internal system error

Request example

Parameter notes

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 <token> with your AtomGit user access token.

cURL

curl -X PUT 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/push_config?access_token=<token>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{
    "reject_not_signed_by_gpg": false,
    "commit_message_regex": "",
    "max_file_size": 10,
    "skip_rule_for_owner": false,
    "deny_force_push": true
  }'

JavaScript

// Native fetch (Node.js 18+ / browsers)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/push_config?access_token=<token>", {
  method: "PUT",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    reject_not_signed_by_gpg: false,
    commit_message_regex: "",
    max_file_size: 10,
    skip_rule_for_owner: false,
    deny_force_push: true,
  }),
});

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>/push_config",
    params={"access_token": "<token>"},
    json={
        "reject_not_signed_by_gpg": False,
        "commit_message_regex": "",
        "max_file_size": 10,
        "skip_rule_for_owner": False,
        "deny_force_push": True,
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "reject_not_signed_by_gpg": false,
  "deny_force_push": true,
  "max_file_size": 10,
  "skip_rule_for_owner": false
}

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing or invalid access credentials)
400 Invalid parameters or the request cannot be parsed
403 Access forbidden; no permission for this operation
404 Request path does not exist
405 Request method not supported
429 Too many requests; rate limit triggered
500 Internal system error

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