GitHub - List Rulesets using the REST API


by
Jeremy Canfield |
Updated: April 19 2025
| GitHub articles
In the following examples, the authentication to GitHub is being done using a token, meaning the authentication is being done using a classic token or a fine grained token. For example, if using a classic Personal Access Token, the token will need the repo permission.

Here is an example of how to list the Rulesets using curl.
curl --location \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer <your token>" \
--header "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/<your organization>/<repo>/rulesets
For example.
curl --location \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer abc123" \
--header "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/acme/foo/rulesets
Something like this should be returned.
[
{
"id": 3568331,
"name": "my ruleset",
"target": "branch",
"source_type": "Repository",
"source": "acme/foo",
"enforcement": "active",
"node_id": "RRS_lACqUmsfgsfdgec421hFzzgAsdfg",
"_links": {
"self": {
"href": "https://api.github.com/repos/acme/foo/rulesets/3568331"
},
"html": {
"href": "https://github.com/acme/foo/rules/3568331"
}
},
"created_at": "2025-02-05T04:52:51.754-06:00",
"updated_at": "2025-02-05T04:52:51.754-06:00"
},
]
Did you find this article helpful?
If so, consider buying me a coffee over at