How to make a public GitHub repository private using REST API?

Step 1: Create a personal access token on GitHub.

Step 2: Update the GitHub repository using REST API

To get additional details, please refer to the below documentation.
https://docs.github.com/en/rest/repos