Creating Github Organization using graphql

101 views Asked by At

I tried below code to create organization using my github account getting error

mutation { createOrganization(input: { login: "besttestzzzz", admin: true }) { organization { id login } } }

{ "input": { "admin": [ "testgithubaccount" ],

"clientMutationId": "",
"login": "testgithubaccount"

} }

I got errors view the below image.

view the below image

2

There are 2 answers

0
Ritik On

GitHub's GraphQL API does not provide direct endpoints to create organizations. Organization creation is typically done through the GitHub web interface or using the REST API.

Here's how you can use rest API:

curl -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -d '{
  "login": "new-org",
  "profile_name": "New Organization",
  "admin": "your-username"
}' https://api.github.com/user/repos
0
Timmmy001 On

Sure, you can!

gh api graphql -f query='
    mutation NeueOrg{
        createEnterpriseOrganization(
            input: { adminLogins: ["MyGH_Account"], billingEmail:"[email protected]", 
                enterpriseId: "MREFOkVudGVydHJpc2UxMzM5", login: "NeueOrg", profileName: "Neue Org"
            }
        )
        {enterprise {
            id
        }
    }
}'