POST
/repos/{owner}/{repo}/rulesetsCreate a repository ruleset
Creates a ruleset for a repository. Supply name and enforcement, and use target, conditions, rules, and bypass_actors to define when the ruleset applies and who can bypass it. A 201 response returns the created repository ruleset.
- RetriesRetries up to 2×, 500ms backoff, 30s timeout.
ownerstringrequired
The account owner of the repository; the name is not case sensitive.
repostringrequired
The repository name without the `.git` extension; the name is not case sensitive.
Repository ruleset configuration. name and enforcement are required.
namestringrequired
The name of the ruleset.
targetstringoptional
The target of the ruleset
enforcementstringrequired
The enforcement level of the ruleset. `evaluate` allows admins to test rules before enforcing them. Admins can view insights on the Rule Insights page (`evaluate` is only available with GitHub Enterprise).
bypass_actorsarray<RepositoryRulesetBypassActor>optional
The actors that can bypass the rules in this ruleset
conditionsobjectoptional
Parameters for a repository ruleset ref name condition
rulesarray<RepositoryRule>optional
An array of rules within the ruleset.
201Returns the created repository ruleset, including its identifier, name, source, enforcement level, target, bypass actors, conditions, rules, and timestamps.
idintegerrequired
The ID of the ruleset
namestringrequired
The name of the ruleset
targetstringoptional
The target of the ruleset
source_typestringoptional
The type of the source of the ruleset
sourcestringrequired
The name of the source
enforcementstringrequired
The enforcement level of the ruleset. `evaluate` allows admins to test rules before enforcing them. Admins can view insights on the Rule Insights page (`evaluate` is only available with GitHub Enterprise).
bypass_actorsarray<RepositoryRulesetBypassActor>optional
The actors that can bypass the rules in this ruleset
current_user_can_bypassstringoptional
The bypass type of the user making the API request for this ruleset. This field is only returned when
querying the repository-level endpoint.
node_idstringoptional
_linksobjectoptional
conditionsobjectoptional
Parameters for a repository ruleset ref name condition
rulesarray<RepositoryRule>optional
created_atstringoptional
updated_atstringoptional
404Returned when the specified repository cannot be found.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Returned when the request fails validation or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional
500Returned when an internal server error occurs.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
Error handling
A 404 is returned when the repository cannot be found. A 422 is returned when the request fails validation or the endpoint has been spammed. A 500 is returned when the service encounters an internal error. name and enforcement are required, enforcement must be disabled, active, or evaluate, and each bypass actor must provide actor_type.