PUT/repos/{owner}/{repo}/rulesets/{ruleset_id}

Replace a repository ruleset

Replaces a repository ruleset with the supplied configuration. Supply the ruleset properties you want to set, including its target, enforcement level, bypass actors, conditions, or rules. Use evaluate to test rules before enforcement; this option is available only with GitHub Enterprise.

3 parameters · 6 body fields
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.
ruleset_idintegerrequired
The ID of the ruleset to replace.

Repository ruleset configuration. Supply the properties to set; each bypass actor must include an actor_type.

namestringoptional
The name of the ruleset.
targetstringoptional
The target of the ruleset
Allowed:branchtagpush
enforcementstringoptional
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).
Allowed:disabledactiveevaluate
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.

4 status codes
200Returns the updated repository ruleset, including its ID, name, source, enforcement level, bypass actors, conditions, and rules.
idintegerrequired
The ID of the ruleset
namestringrequired
The name of the ruleset
targetstringoptional
The target of the ruleset
Allowed:branchtagpushrepository
source_typestringoptional
The type of the source of the ruleset
Allowed:RepositoryOrganizationEnterprise
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).
Allowed:disabledactiveevaluate
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.
Allowed:alwayspull_requests_onlyneverexempt
node_idstringoptional
_linksobjectoptional
conditionsobjectoptional
Parameters for a repository ruleset ref name condition
rulesarray<RepositoryRule>optional
created_atstringoptional
updated_atstringoptional
404Returned when the repository or ruleset cannot be found.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Returned when the ruleset configuration fails validation or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional
500Returned when an internal error occurs.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional

Error handling

A 404 is returned when the owner path parameter and repo path parameter do not identify a repository, or the ruleset_id path parameter does not identify a ruleset in that repository. A 422 is returned when the ruleset configuration fails validation or the endpoint has been spammed; target must be branch, tag, or push, and enforcement must be disabled, active, or evaluate. A 500 indicates an internal error.