REST API endpoints for rules
Use the REST API to manage rulesets for an enterprise. Rulesets control how people can interact with repositories and code.
Create an enterprise repository ruleset
Create a repository ruleset for an enterprise.
Fine-grained access tokens for "Create an enterprise repository ruleset"
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
- "Enterprise administration" enterprise permissions (write)
Parameters for "Create an enterprise repository ruleset"
| Name, Type, Description |
|---|
accept string Setting to |
| Name, Type, Description |
|---|
enterprise string RequiredThe slug version of the enterprise name. |
| Name, Type, Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name string RequiredThe name of the ruleset. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
target string The target of the ruleset Default: Can be one of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
enforcement string RequiredThe enforcement level of the ruleset. Can be one of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bypass_actors array of objects The actors that can bypass the rules in this ruleset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Properties of |
| Name, Type, Description |
|---|
actor_id integer or null The ID of the actor that can bypass a ruleset. Required for |
actor_type string RequiredThe type of actor that can bypass a ruleset Can be one of: |
bypass_mode string When the specified actor can bypass the ruleset. Default: Can be one of: |
conditions object Conditions for an enterprise ruleset.
The conditions object supports either of the following combinations: - organization_id and repository_name - organization_id and repository_property - organization_name and repository_name - organization_name and repository_property - organization_property and repository_name - organization_property and repository_property
For branch and tag rulesets, the conditions object should also contain the ref_name property.
Can be one of these objects:
| Name, Type, Description | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
organization_name_and_repository_name object Conditions to target organizations by name and all repositories | ||||||||||||||||||||||||||||||||||
Properties of |
| Name, Type, Description | ||||
|---|---|---|---|---|
organization_name object Required | ||||
Properties of |
| Name, Type, Description |
|---|
include array of strings Array of organization names or patterns to include. One of these patterns must match for the condition to pass. Also accepts |
exclude array of strings Array of organization names or patterns to exclude. The condition will not pass if any of these patterns match. |
repository_name object RequiredProperties of repository_name
| Name, Type, Description |
|---|
include array of strings Array of repository names or patterns to include. One of these patterns must match for the condition to pass. Also accepts |
exclude array of strings Array of repository names or patterns to exclude. The condition will not pass if any of these patterns match. |
protected boolean Whether renaming of target repositories is prevented. |
ref_name object Properties of ref_name
| Name, Type, Description |
|---|
include array of strings Array of ref names or patterns to include. One of these patterns must match for the condition to pass. Also accepts |
exclude array of strings Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match. |
organization_name_and_repository_property object Conditions to target organizations by name and repositories by property
Properties of organization_name_and_repository_property
| Name, Type, Description | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
organization_name object Required | |||||||||||||
Properties of |
| Name, Type, Description |
|---|
include array of strings Array of organization names or patterns to include. One of these patterns must match for the condition to pass. Also accepts |
exclude array of strings Array of organization names or patterns to exclude. The condition will not pass if any of these patterns match. |
repository_property object RequiredProperties of repository_property
| Name, Type, Description | ||||
|---|---|---|---|---|
include array of objects The repository properties and values to include. All of these properties must match for the condition to pass. | ||||
Properties of |
| Name, Type, Description |
|---|
name string RequiredThe name of the repository property to target |
property_values array of strings RequiredThe values to match for the repository property |
source string The source of the repository property. Defaults to 'custom' if not specified. Can be one of: |
exclude array of objects The repository properties and values to exclude. The condition will not pass if any of these properties match.
Properties of exclude
| Name, Type, Description |
|---|
name string RequiredThe name of the repository property to target |
property_values array of strings RequiredThe values to match for the repository property |
source string The source of the repository property. Defaults to 'custom' if not specified. Can be one of: |
ref_name object Properties of ref_name
| Name, Type, Description |
|---|
include array of strings Array of ref names or patterns to include. One of these patterns must match for the condition to pass. Also accepts |
exclude array of strings Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match. |
organization_id_and_repository_name object Conditions to target organizations by id and all repositories
Properties of organization_id_and_repository_name
| Name, Type, Description | ||||
|---|---|---|---|---|
organization_id object Required | ||||
Properties of |
| Name, Type, Description |
|---|
organization_ids array of integers The organization IDs that the ruleset applies to. One of these IDs must match for the condition to pass. |
repository_name object RequiredProperties of repository_name
| Name, Type, Description |
|---|
include array of strings Array of repository names or patterns to include. One of these patterns must match for the condition to pass. Also accepts |
exclude array of strings Array of repository names or patterns to exclude. The condition will not pass if any of these patterns match. |
protected boolean Whether renaming of target repositories is prevented. |
ref_name object Properties of ref_name
| Name, Type, Description |
|---|
include array of strings Array of ref names or patterns to include. One of these patterns must match for the condition to pass. Also accepts |
exclude array of strings Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match. |
organization_id_and_repository_property object Conditions to target organization by id and repositories by property
Properties of organization_id_and_repository_property
| Name, Type, Description | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
organization_id object Required | |||||||||||||
Properties of |
| Name, Type, Description |
|---|
organization_ids array of integers The organization IDs that the ruleset applies to. One of these IDs must match for the condition to pass. |
repository_property object RequiredProperties of repository_property
| Name, Type, Description | ||||
|---|---|---|---|---|
include array of objects The repository properties and values to include. All of these properties must match for the condition to pass. | ||||
Properties of |
| Name, Type, Description |
|---|
name string RequiredThe name of the repository property to target |
property_values array of strings RequiredThe values to match for the repository property |
source string The source of the repository property. Defaults to 'custom' if not specified. Can be one of: |
exclude array of objects The repository properties and values to exclude. The condition will not pass if any of these properties match.
Properties of exclude
| Name, Type, Description |
|---|
name string RequiredThe name of the repository property to target |
property_values array of strings RequiredThe values to match for the repository property |
source string The source of the repository property. Defaults to 'custom' if not specified. Can be one of: |
ref_name object Properties of ref_name
| Name, Type, Description |
|---|
include array of strings Array of ref names or patterns to include. One of these patterns must match for the condition to pass. Also accepts |
exclude array of strings Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match. |
organization_property_and_repository_name object Conditions to target organizations by property and all repositories
Properties of organization_property_and_repository_name
| Name, Type, Description | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
organization_property object Required | |||||||||||
Properties of |
| Name, Type, Description | |||
|---|---|---|---|
include array of objects The organization properties and values to include. All of these properties must match for the condition to pass. | |||
Properties of |
| Name, Type, Description |
|---|
name string RequiredThe name of the organization property to target |
property_values array of strings RequiredThe values to match for the organization property |
exclude array of objects The organization properties and values to exclude. The condition will not pass if any of these properties match.
Properties of exclude
| Name, Type, Description |
|---|
name string RequiredThe name of the organization property to target |
property_values array of strings RequiredThe values to match for the organization property |
repository_name object RequiredProperties of repository_name
| Name, Type, Description |
|---|
include array of strings Array of repository names or patterns to include. One of these patterns must match for the condition to pass. Also accepts |
exclude array of strings Array of repository names or patterns to exclude. The condition will not pass if any of these patterns match. |
protected boolean Whether renaming of target repositories is prevented. |
ref_name object Properties of ref_name
| Name, Type, Description |
|---|
include array of strings Array of ref names or patterns to include. One of these patterns must match for the condition to pass. Also accepts |
exclude array of strings Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match. |
organization_property_and_repository_property object Conditions to target organizations by property and repositories by property
Properties of organization_property_and_repository_property
| Name, Type, Description | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
organization_property object Required | |||||||||||||
Properties of |
| Name, Type, Description | |||
|---|---|---|---|
include array of objects The organization properties and values to include. All of these properties must match for the condition to pass. | |||
Properties of |
| Name, Type, Description |
|---|
name string RequiredThe name of the organization property to target |
property_values array of strings RequiredThe values to match for the organization property |
exclude array of objects The organization properties and values to exclude. The condition will not pass if any of these properties match.
Properties of exclude
| Name, Type, Description |
|---|
name string RequiredThe name of the organization property to target |
property_values array of strings RequiredThe values to match for the organization property |
repository_property object RequiredProperties of repository_property
| Name, Type, Description | ||||
|---|---|---|---|---|
include array of objects The repository properties and values to include. All of these properties must match for the condition to pass. | ||||
Properties of |
| Name, Type, Description |
|---|
name string RequiredThe name of the repository property to target |
property_values array of strings RequiredThe values to match for the repository property |
source string The source of the repository property. Defaults to 'custom' if not specified. Can be one of: |
exclude array of objects The repository properties and values to exclude. The condition will not pass if any of these properties match.
Properties of exclude
| Name, Type, Description |
|---|
name string RequiredThe name of the repository property to target |
property_values array of strings RequiredThe values to match for the repository property |
source string The source of the repository property. Defaults to 'custom' if not specified. Can be one of: |
ref_name object Properties of ref_name
| Name, Type, Description |
|---|
include array of strings Array of ref names or patterns to include. One of these patterns must match for the condition to pass. Also accepts |
exclude array of strings Array of ref names or patterns to exclude. The condition will not pass if any of these patterns match. |
rules array of objects An array of rules within the ruleset.
Can be one of these objects:
| Name, Type, Description | ||
|---|---|---|
creation object Only allow users with bypass permission to create matching refs. | ||
Properties of |
| Name, Type, Description |
|---|
type string RequiredValue: |
update object Only allow users with bypass permission to update matching refs.