How to enable the sponsor button in a repository using GitHub API?

On the tutorial Displaying a sponsor button in your repository it is showed how to enable the sponsor button, using the GitHub web interface:

Checkbox to enable Sponsorships

But how to enable it using the GitHub API?

I use this to enable the issue tracker on my repositories:

curl \
    -H "Authorization: Token {token}" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X PATCH \
    --data '{"name": "repository_name", "has_issues": True}' \
    https://api.github.com/repos/user/repository_name

This only works because the repository has a has_issues setting, but I cannot find any has_sponsor setting available.

1 Like