SOLFIND
Web Lens
Portal home

docs/content/graphql/guides/managing-enterprise-accounts.md at main · github/docs · GitHub

https://github.com/github/docs/blob/main/content/graphql/guides/managing-enterprise-accounts.md • 303 KB fetched
Open original page


docs/content/graphql/guides/managing-enterprise-accounts.md at main · github/docs · GitHub Skip to content Navigation Menu Sign in Appearance settings * Platform * AI CODE CREATION * GitHub Copilot Write better code with AI * GitHub Copilot app Direct agents from issue to merge * MCP Registry Integrate external tools * DEVELOPER WORKFLOWS * Actions Automate any workflow * Codespaces Instant dev environments * Issues Plan and track work * Code Review Manage code changes * Code Quality Enforce quality at merge * APPLICATION SECURITY * GitHub Advanced Security Find and fix vulnerabilities * Code security Secure your code as you build * Secret protection Stop leaks before they start * EXPLORE * Why GitHub * Documentation * Blog * Changelog * Marketplace View all features * Solutions * BY COMPANY SIZE * Enterprises * Small and medium teams * Startups * Nonprofits * BY USE CASE * App Modernization * DevSecOps * DevOps * CI/CD * View all use cases * BY INDUSTRY * Healthcare * Financial services * Manufacturing * Government * View all industries View all solutions * Resources * EXPLORE BY TOPIC * AI * Software Development * DevOps * Security * View all topics * EXPLORE BY TYPE * Customer stories * Events & webinars * Ebooks & reports * Business insights * GitHub Skills * SUPPORT & SERVICES * Documentation * Customer support * Community forum * Trust center * Partners View all resources * Open Source * COMMUNITY * GitHub Sponsors Fund open source developers * PROGRAMS * Security Lab * Maintainer Community * GitHub Stars * Archive Program * REPOSITORIES * Topics * Trending * Collections * Enterprise * ENTERPRISE SOLUTIONS * Enterprise platform AI-powered developer platform * AVAILABLE ADD-ONS * GitHub Advanced Security Enterprise-grade security features * Copilot for Business Enterprise-grade AI features * Premium Support Enterprise-grade 24/7 support * Pricing Search / Sign in Sign up Appearance settings You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert Uh oh! There was an error while loading. Please reload this page . github / docs Public * Notifications You must be signed in to change notification settings * Fork 68.7k * Star 20.8k * Code * Issues 27 * Pull requests 18 * Actions * Projects * Security and quality 0 * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security and quality * Insights Files Expand file tree main Breadcrumbs * docs * / content * / graphql * / guides / managing-enterprise-accounts.md Copy path Blame More file actions Blame More file actions Latest commit   History History History 207 lines (167 loc) · 9.34 KB main Breadcrumbs * docs * / content * / graphql * / guides / managing-enterprise-accounts.md Copy path Top File metadata and controls * Preview * Code * Blame 207 lines (167 loc) · 9.34 KB Raw Copy raw file Download raw file Outline Edit and raw actions title Managing enterprise accounts intro You can manage your enterprise account and the organizations it owns with the GraphQL API. redirect_from /v4/guides/managing-enterprise-accounts versions ghec ghes * * shortTitle Manage enterprise accounts category Get started and make API calls About managing enterprise accounts with GraphQL To help you monitor and make changes in your organizations and maintain compliance, you can use the Enterprise Accounts API and the Audit Log API, which are only available as GraphQL APIs. The enterprise account endpoints work for both GitHub Enterprise Cloud and for GitHub Enterprise Server. GraphQL allows you to request and return just the data you specify. For example, you can create a GraphQL query, or request for information, to see all the new organization members added to your organization. Or you can make a mutation, or change, to invite an administrator to your enterprise account. With the Audit Log API, you can monitor when someone: * Accesses your organization or repository settings. * Changes permissions. * Adds or removes users in an organization, repository, or team. * Promotes users to admin. * Changes permissions of a GitHub App. The Audit Log API enables you to keep copies of your audit log data. For queries made with the Audit Log API, the GraphQL response can include data for up to 90 to 120 days. For a list of the fields available with the Audit Log API, see the AUTOTITLE . With the Enterprise Accounts API, you can: * List and review all of the organizations and repositories that belong to your enterprise account. * Change Enterprise account settings. * Configure policies for settings on your enterprise account and its organizations. * Invite administrators to your enterprise account. * Create new organizations in your enterprise account. For a list of the fields available with the Enterprise Accounts API, see AUTOTITLE . Getting started using GraphQL for enterprise accounts See AUTOTITLE to get started using GraphQL to manage your enterprise accounts. For some example queries, see An example query using the Enterprise Accounts API . 1. Authenticate with your {% data variables.product.pat_generic %} * To authenticate with GraphQL, you need to generate a {% data variables.product.pat_generic %} from developer settings. For more information, see AUTOTITLE . * Grant admin and full control permissions to your {% data variables.product.pat_generic %} for areas of your enterprise you'd like to access. For full permission to private repositories, organizations, teams, user data, and access to enterprise billing and profile data, we recommend you select these scopes for your {% data variables.product.pat_generic %}: * repo * admin:org * user * admin:enterprise The enterprise account specific scopes are: * admin:enterprise : Gives full control of enterprises (includes manage_runners:enterprise , manage_billing:enterprise and read:enterprise ) * manage_billing:enterprise : Read and write enterprise billing data.{% ifversion ghes %} * manage_runners:enterprise : Access to manage GitHub Actions enterprise runners and runner-groups.{% endif %} * read:enterprise : Read enterprise profile data. * Copy your {% data variables.product.pat_generic %} and keep it in a secure place until you add it to your GraphQL client. 2. Choose a GraphQL client We recommend you use GraphiQL or another standalone GraphQL client that lets you configure the base URL. You may also consider using these GraphQL clients: * Insomnia * GraphiQL * Postman The next steps will use Insomnia. 3. Setting up Insomnia to use the GitHub GraphQL API with enterprise accounts * Add the base url and POST method to your GraphQL client. When using GraphQL to request information (queries), change information (mutations), or transfer data using the GitHub API, the default HTTP method is POST and the base url follows this syntax: * For your enterprise instance: https://<HOST>/api/graphql * For GitHub Enterprise Cloud: https://api.github.com/graphql * For GitHub Enterprise Cloud with Data Residency: https://api.SUBDOMAIN.ghe.com/graphql * Select the "Auth" menu and click Bearer Token . If you've previously selected a different authentication method, the menu will be labeled with that method, such as "Basic Auth", instead. * In the "TOKEN" field, enter your {% data variables.product.pat_generic %} from an earlier step. * Click Headers . * Under the Headers tab, click Add . * In the "header" field, enter Content-Type . * In the "value" field, enter application/json . Now you are ready to start making queries. An example query using the Enterprise Accounts API This GraphQL query requests the total number of public repositories in each of your appliance's organizations using the Enterprise Accounts API. To customize this query, replace <enterprise-account-name> with the handle for your enterprise account. For example, if your enterprise account is located at https://github.com/enterprises/octo-enterprise , replace <enterprise-account-name> with octo-enterprise . query publicRepositoriesByOrganization ( $slug : String ! ) { enterprise ( slug : $slug ) { ... enterpriseFragment } } fragment enterpriseFragment on Enterprise { ... on Enterprise { name organizations ( first : 100 ){ nodes { name ... on Organization { name repositories ( privacy : PUBLIC ){ totalCount } } } } } } # Passing our Enterprise Account as a variable variables { " slug ": "< enterprise - account - name >" } The next GraphQL query example shows how challenging it is to retrieve the number of public repositories in each organization without using the Enterprise Account API. Notice that the GraphQL Enterprise Accounts API has made this task simpler for enterprises since you only need to customize a single variable. To customize this query, replace <name-of-organization-one> and <name-of-organization-two> , etc. with the organization names on your instance. # Each organization is queried separately { organizationOneAlias : organization ( login : " nameOfOrganizationOne " ) { # How to use a fragment ... repositories } organizationTwoAlias : organization ( login : " nameOfOrganizationTwo " ) { ... repositories } # organizationThreeAlias ... and so on up-to lets say 100 } ## How to define a fragment fragment repositories on Organization { name repositories ( privacy : PUBLIC ){ totalCount } } Query each organization separately query publicRepositoriesByOrganization { organizationOneAlias : organization ( login : " <name-of-organization-one> " ) { # How to use a fragment ... repositories } organizationTwoAlias : organization ( login : " <name-of-organization-two> " ) { ... repositories } # organizationThreeAlias ... and so on up-to lets say 100 } # How to define a fragment fragment repositories on Organization { name repositories ( privacy : PUBLIC ){ totalCount } } This GraphQL query requests the last 5 log entries for an enterprise organization. To customize this query, replace <org-name> and <user-name> . { organization ( login : " <org-name> " ) { auditLog ( last : 5 , query : " actor:<user-name> " ) { edges { node { ... on AuditEntry { # Get Audit Log Entry by 'Action' action actorLogin createdAt # User 'Action' was performed on user { name email } } } } } } } For more information about getting started with GraphQL, see AUTOTITLE and AUTOTITLE . GraphQL fields and types for the Enterprise Accounts API For more details about the new queries, mutations, and schema defined types available for use with the Enterprise Accounts API, see the sidebar with detailed GraphQL definitions from any GraphQL reference page . You can access the reference docs from within the GraphQL clients. For more information, see AUTOTITLE . For other information, such as authentication and rate limit details, check out the guides . Footer (c) 2026 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Community * Docs * Contact * Manage cookies * Do not share my personal information You can’t perform that action at this time.

Links found on this page

  1. Skip to content [direct]
  2. Sign in [direct]
  3. GitHub Copilot Write better code with AI [direct]
  4. GitHub Copilot app Direct agents from issue to merge [direct]
  5. MCP Registry Integrate external tools [direct]
  6. Actions Automate any workflow [direct]
  7. Codespaces Instant dev environments [direct]
  8. Issues Plan and track work [direct]
  9. Code Review Manage code changes [direct]
  10. Code Quality Enforce quality at merge [direct]
  11. GitHub Advanced Security Find and fix vulnerabilities [direct]
  12. Code security Secure your code as you build [direct]
  13. Secret protection Stop leaks before they start [direct]
  14. Why GitHub [direct]
  15. Documentation [direct]
  16. Blog [direct]
  17. Changelog [direct]
  18. Marketplace [direct]
  19. View all features [direct]
  20. Enterprises [direct]
  21. Small and medium teams [direct]
  22. Startups [direct]
  23. Nonprofits [direct]
  24. App Modernization [direct]
  25. DevSecOps [direct]
  26. DevOps [direct]
  27. CI/CD [direct]
  28. View all use cases [direct]
  29. Healthcare [direct]
  30. Financial services [direct]
  31. Manufacturing [direct]
  32. Government [direct]
  33. View all industries [direct]
  34. View all solutions [direct]
  35. AI [direct]
  36. Software Development [direct]
  37. DevOps [direct]
  38. Security [direct]
  39. View all topics [direct]
  40. Customer stories [direct]
  41. Events & webinars [direct]
  42. Ebooks & reports [direct]
  43. Business insights [direct]
  44. GitHub Skills [direct]
  45. Customer support [direct]
  46. Community forum [direct]
  47. Trust center [direct]
  48. Partners [direct]
  49. View all resources [direct]
  50. GitHub Sponsors Fund open source developers [direct]
  51. Security Lab [direct]
  52. Maintainer Community [direct]
  53. GitHub Stars [direct]
  54. Archive Program [direct]
  55. Topics [direct]
  56. Trending [direct]
  57. Collections [direct]
  58. Copilot for Business Enterprise-grade AI features [direct]
  59. Premium Support Enterprise-grade 24/7 support [direct]
  60. Pricing [direct]
  61. Sign up [direct]
  62. github [direct]
  63. docs [direct]
  64. Notifications [direct]
  65. Issues 27 [direct]
  66. Pull requests 18 [direct]
  67. Actions [direct]
  68. Projects [direct]
  69. Security and quality 0 [direct]
  70. Insights [direct]
  71. docs [direct]
  72. content [direct]
  73. graphql [direct]
  74. guides [direct]
  75. History [direct]
  76. Raw [direct]
  77. AUTOTITLE [direct]
  78. AUTOTITLE [direct]
  79. AUTOTITLE [direct]
  80. AUTOTITLE [direct]