How to create Organization name through Github API instead of creating manually?

Related searches

I am trying to use github api to create organization and repositories instead of creating them manually. I was looking at this site which talks about how to create repositories under a particular organization.

My github instance url is like this -

And I want my repository to be like this after getting created -

Here Mobile is the organization name and CustomerSystem is the repository name. In my case, I don't have Mobile organization name already created before as I want to create it through Github API along with repository as well.

So I am executing below curl url thinking it will create organization name and repository under them as well but everytime I am getting 404 Not Found -

curl -i -u david -d '{ "name": "CustomerSystem", "auto_init": true, "private": true, "gitignore_template": "nanoc" }'

Below is the result I am getting -

HTTP/1.1 404 Not Found
Date: Sat, 07 Feb 2015 20:43:32 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 102
Status: 404 Not Found
X-GitHub-Media-Type: github.v3
X-XSS-Protection: 1; mode=block
X-Frame-Options: deny
Content-Security-Policy: default-src 'none'
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
X-GitHub-Request-Id: fv4af52e-617c-4ga1-br2f-5cb51b1df3bb
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Content-Type-Options: nosniff

  "message": "Not Found",
  "documentation_url": ""

Is there anything wrong I am doing?

It looks to me if organization name is already created, then my above CURL call works fine and the repository gets created fine without any issues. But if the organization name is not there already then it gives me 404 error message.

Is there any way to create organization name as well through github API? In some cases, I might have Organization name already created before, so I will create new repository under them but in some cases, I might not have Organization name already created before so I need to create Organization name through Github API.

You can check out how a wrapper like go-gihub proposes to manage an organization, reflecting the Organization API.

You can list, get or edit an organization, but apparently not create one.

Organizations, Lists all organizations, in the order that they were created on GitHub. Name, Type, Description user, use the List organizations for the authenticated user API instead. true - all organization members can create internal repositories. Click the + icon on the top-right corner and click New organization. Enter the organization name, billing email, and click Create an Organization.

Is there any way to create organization name as well through github API?

Currently it's not possible to create organizations nor user accounts via the GitHub API.

Creating a new repository, You can create a new repository on your personal account or any organization where you have sufficient permissions. GitHub Actions is available with GitHub Free, GitHub Pro, GitHub Free for organizations, GitHub Team, GitHub Enterprise Cloud, and GitHub One. GitHub Actions is not available for private repositories owned by accounts using legacy per-repository plans.

GitHub doesn't privide a public api for that.

But say if you want to automate the organization creation process, you can inspect the network activity (press F12 in your browser and navigate to the network tab) on this page

to find out the private api for checking name availability and creating an organization, then export the request as curl command, put it in a shell script and parameterize the organization name.

I won't go into details or post my script here because the script is fairly to trivial to write and it will leak my browser cookie and session information

btw if you are using GitHub Enterprise then it's documented here


WARNING!!! Be careful not to create too many organizations. I currently have created over 500+ organizations with my personal account. Now each time I visit a page on github with my account logged in, it will either take seconds to load or doesn't load at all, showing the unicorn page like If I log out of my account, the page loads quickly again. I've pretty much given up using the github web ui.

In the left sidebar, click GitHub Apps. Click New GitHub App. In "GitHub App name", type the name of your app. Give your app a clear and succinct name. Your app cannot have the same name as an existing GitHub user, unless it is your own user or organization name.

You could try something like this

curl --include -u victor-raul-hernandez-contreras:your-personal-access-token-here -X POST --data '{"login":"loko200","profile_name":"lokosoft, inc.", "admin":"victor-raul-hernandez-contreras"}'

It worked for me at github enterprise.

Note: If you prefer to set up CI/CD run org-formation init-pipeline instead. It will create a CodeCommit repository and CodePipeline that will update your organization upon every commit! You can make changes to the file you generated and update your organization using the update command.

You can also manage secrets using the REST API. For more information, see "Secrets." Limiting credential permissions. When generating credentials, we recommend that you grant the minimum permissions possible. For example, instead of using personal credentials, use deploy keys or a service account. Consider granting read-only permissions if that

In order to provide quality service on GitHub, additional rate limits may apply to some actions when using the API. For example, using the API to rapidly create content, poll aggressively instead of using webhooks, make multiple concurrent requests, or repeatedly request data that is computationally expensive may result in abuse rate limiting.

Enter the repository name and description, and click the Initialize this repository with a README checkbox. You can add a.gitignore and license later on. If you did not select the option to Initialize this repository with a README, create an initial commit by adding a README file.

  • Is it possible to rename existing organization name? . Please confirm.
  • @LearnHadoop It is possible through the GitHub API ( And go-gitHub has an Edit function (…). So yes. You can change the name. Not its ID though.
  • Thanks .. i Could n't find the right field to rename organization . Any idea.
  • @LearnHadoop The field to use to rename an organization is... "name".
  • I tried with below payload. { "description": "GitHub, the company.", "name" :"Test-Org-100" } . No luck . Actually it is change in "Organization display name" in GIThub..Not Repo name..