You can't do it without an Access Token. Also, please feel free to look at my GitHub open source project Git-Captain.

I created a web-application with a Node.js back-end and HTML/JS front-end that you can setup to have an API do many of these calls for you. It has a step-by-step for a windows server and I'll be adding a Linux step-by-step soon.

It would only take a slight tweak to the project to add a new end-point to the source to do this for you.

To answer your question,

The GitHub API documentation explains exactly how to do what you are requesting on this link.

Giving this example:

as you requested in CURL and obviously replace the token "5199..." with your own:

curl -i -H "Authorization: token 5199831f4dd3b79e7c5b7e0ebe75d67aa66e79d4" \
    -d '{ \
        "name": "blog", \
        "auto_init": true, \
        "private": true, \
        "gitignore_template": "nanoc" \
      }' \
    https://api.github.com/user/repos

OR

Not in CURL and according to this StackOverflow question you can do the following:

https://api.github.com/orgs/<organisation_name>/repos?access_token=<generated token>
       or
https://api.github.com/users/<username>/repos?access_token=<generated token> 

In body, pass this as a payload:

{
  <br/>"name": "<Repo Name>",<br/>
  "description": "<Whateveryour description is>",<br/>
  "homepage": "https://github.com",<br/>
  "private": false,<br/>
}

You can get a "personal access token in GitHub" by going to Settings->Developer Settings-> Personal Access Tokens->Generate new token


OR do all of the following

  • Write a script (let's call this script #1) that takes the username,password, and repoName as a parameter.
  • That script will call script #2, which is curl -u ' USER-NAME-HERE' https://api.github.com/user/repos -d '{"name": "REPO-NAME-HERE"}' which will prompt for your user password,
  • have your script #1 listen for script #2's response and then have it enter in the password which the user passed in as a parameter in script#1
  • Finally programmatically hit enter which fires off the curl to create your repo.

UPDATE*

So for some reason, the CURL won't work at all, but the Git-Hub API end point https://api.github.com/user/repos does indeed work. Using POSTMAN, I was able to create a new POST with the URL being https://api.github.com/user/repos and the BODY set to:

{
  "name": "Hello-World",
  "description": "This is your first repository",
  "homepage": "https://github.com",
  "private": false,
  "has_issues": true,
  "has_projects": true,
  "has_wiki": true
}

Then I went to the 'Authorization' section of postman and under 'Type' I selected "Basic Auth" entered my username and password. Clicked update request and then send and my repo was created!

Answer from JoeTavarez on Stack Overflow
๐ŸŒ
GitHub
docs.github.com โ€บ rest โ€บ guides โ€บ getting-started-with-the-rest-api
Getting started with the REST API - GitHub Docs
If you get a message similar to command not found: curl, that means curl is not installed. Download and install curl. For more information, see the curl download page. Choose an endpoint to make a request to. You can explore GitHub's REST API documentation to discover endpoints that you can use to interact with GitHub.
Top answer
1 of 1
1

You can't do it without an Access Token. Also, please feel free to look at my GitHub open source project Git-Captain.

I created a web-application with a Node.js back-end and HTML/JS front-end that you can setup to have an API do many of these calls for you. It has a step-by-step for a windows server and I'll be adding a Linux step-by-step soon.

It would only take a slight tweak to the project to add a new end-point to the source to do this for you.

To answer your question,

The GitHub API documentation explains exactly how to do what you are requesting on this link.

Giving this example:

as you requested in CURL and obviously replace the token "5199..." with your own:

curl -i -H "Authorization: token 5199831f4dd3b79e7c5b7e0ebe75d67aa66e79d4" \
    -d '{ \
        "name": "blog", \
        "auto_init": true, \
        "private": true, \
        "gitignore_template": "nanoc" \
      }' \
    https://api.github.com/user/repos

OR

Not in CURL and according to this StackOverflow question you can do the following:

https://api.github.com/orgs/<organisation_name>/repos?access_token=<generated token>
       or
https://api.github.com/users/<username>/repos?access_token=<generated token> 

In body, pass this as a payload:

{
  <br/>"name": "<Repo Name>",<br/>
  "description": "<Whateveryour description is>",<br/>
  "homepage": "https://github.com",<br/>
  "private": false,<br/>
}

You can get a "personal access token in GitHub" by going to Settings->Developer Settings-> Personal Access Tokens->Generate new token


OR do all of the following

  • Write a script (let's call this script #1) that takes the username,password, and repoName as a parameter.
  • That script will call script #2, which is curl -u ' USER-NAME-HERE' https://api.github.com/user/repos -d '{"name": "REPO-NAME-HERE"}' which will prompt for your user password,
  • have your script #1 listen for script #2's response and then have it enter in the password which the user passed in as a parameter in script#1
  • Finally programmatically hit enter which fires off the curl to create your repo.

UPDATE*

So for some reason, the CURL won't work at all, but the Git-Hub API end point https://api.github.com/user/repos does indeed work. Using POSTMAN, I was able to create a new POST with the URL being https://api.github.com/user/repos and the BODY set to:

{
  "name": "Hello-World",
  "description": "This is your first repository",
  "homepage": "https://github.com",
  "private": false,
  "has_issues": true,
  "has_projects": true,
  "has_wiki": true
}

Then I went to the 'Authorization' section of postman and under 'Type' I selected "Basic Auth" entered my username and password. Clicked update request and then send and my repo was created!

Author: wick3dr0se
๐ŸŒ
GitHub
docs.github.com โ€บ en โ€บ rest โ€บ quickstart
Quickstart for GitHub REST API - GitHub Docs
If you want to make API requests from the command line, GitHub recommends that you use GitHub CLI, which simplifies authentication and requests. For more information about getting started with the REST API using GitHub CLI, see the GitHub CLI version of this article. Install curl if it isn't already installed on your machine.
๐ŸŒ
LornaJane
lornajane.net โ€บ posts โ€บ 2012 โ€บ github-api-access-tokens-via-curl
Github API Access Tokens via Curl | LornaJane
September 25, 2012 - They have the usual web flow but I'm cutting as many corners as I can to keep the demos nice and quick, so I looked into the support Github has for generating an API key programmatically. You can log in with basic auth to generate the token (and then revoke the token later, which works for me as I'll be demo-ing with it!). To do so, you make a POST request to the /authorizations endpoint: curl -v -u lornajane -X POST https://api.github.com/authorizations --data @github.json
Find elsewhere
๐ŸŒ
Kranthi Lakum
lakum.in โ€บ blog โ€บ using-curl-with-github
cURL with GitHub | Kranthi Lakum
curl -i -H "Authorization: token <TOKEN>" \ https://api.github.com/<USERNAME>/repos curl -i https://api.github.com/users/<USERNAME>/repos ... curl -i -H "Authorization: token <TOKEN>" \ -d '{ \ "name": "sample-repo", \ "auto_init": true, \ "private": true, \ "gitignore_template": "nanoc" \ }' \ https://api.github.com/user/repos
๐ŸŒ
GitHub
docs.github.com โ€บ en โ€บ rest โ€บ authentication โ€บ authenticating-to-the-rest-api
Authenticating to the REST API - GitHub Docs
curl --request GET \ --url "https://api.github.com/octocat" \ --header "Authorization: Bearer YOUR-TOKEN" \ --header "X-GitHub-Api-Version: 2026-03-10"
๐ŸŒ
GitHub
docs2.lfe.io โ€บ guides โ€บ getting-started
Getting Started | GitHub API
The easiest way to authenticate with the GitHub API is by simply using your GitHub username and password via Basic Authentication. $ curl -i -u <your_username> https://api.github.com/users/defunkt Enter host password for user '<your_username>':
๐ŸŒ
LoginRadius
loginradius.com โ€บ home
Introduction to Github APIs
February 17, 2026 - Request type: POST API endpoint: /user/{repos} Required data: name ยท Example :- curl -H "Authorization: token ${token}" -d '{"name":"Github API Testing"}' https://api.github.com/user/repos
๐ŸŒ
RJS
ralphjsmit.com โ€บ api-endpoint-webhook-github-actions
How to use GitHub Actions with webhooks & API endpoints
As you see, with curl you can hit up any API endpoint or webhook! It is very easy to use curl. It is already a tool on the command line and GitHub allows you to run CLI commands from GitHub Actions.
๐ŸŒ
GitHub
docs2.lfe.io โ€บ v3
GitHub API v3
$ curl -i https://api.github.com/user HTTP/1.1 200 OK Cache-Control: private, max-age=60 ETag: "644b5b0155e6404a9cc4bd9d8b1ae730" Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT Status: 200 OK Vary: Accept, Authorization, Cookie X-RateLimit-Limit: 5000 X-RateLimit-Remaining: 4996 X-RateLimit-Reset: 1372700873 $ curl -i https://api.github.com/user -H 'If-None-Match: "644b5b0155e6404a9cc4bd9d8b1ae730"' HTTP/1.1 304 Not Modified Cache-Control: private, max-age=60 ETag: "644b5b0155e6404a9cc4bd9d8b1ae730" Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT Status: 304 Not Modified Vary: Accept, Authorization
Top answer
1 of 2
9

You were close:) Lets assume, that

1) your login: YourUsername

2) your access token: 123a321

3) repository to be updated: YourRepo

4) file to be created: file.txt

5) folder that will contains new file: f1/f2

According to those assumptions your request should be following:

type : PUT

url : https://api.github.com/repos/YourUsername/YourRepo/contents/f1/f2/file.txt

headers :

{
 "Content-Type" : "application/vnd.github.v3+json",
 "Authorization" : "token 123a321"
}

body :

{
  "message": "my commit message",
  "committer": {
    "name": "My name",
    "email": "my email"
  },
  "content": "base64encoded"
}


UPD If you write in java, you can use GitHubFileAPI library, that I recently pushed to the maven central repository.

2 of 2
0

Solution: In order to perform action on github api you can use curl according to Github doc:

  1. first make sure you have specific privileges and authentication token generated to your account in order to interact with Github api:

profile Settings -> Developer Settings -> Personal access tokens -> Generate new token

  1. the command should be in http PUT method on path /repos/:owner/:repo/contents/:path
  2. The required params for editing or adding new files (according to api) message (String), Content (String) and sha(String), additional params are branch(String) commiter(String) and author(String)

Lets perform some curl message in order to perform your action, the simple formula for this case would be:

curl --user <userName>:<token>
--data '{"key":"value"}'
--header <HeaderType>
--request <HTTPMethod>
<fullURL>

for demonstration lets fill some details:

 curl --user johnDoe:abc123!@#
 --data '{"message":"my message","content":"my content","sha":"abcjfhtenf736gd843ji43903"}'
 --header Content-Type:application/json
 --request PUT
https://api.github.com/repos/MyOrganization/MyCoolApp/contents/app/models
  1. Verify on Github the content has been inserted correctly to your branch