Skip to main content

Esta versión de GitHub Enterprise se discontinuó el 2022-10-12. No se realizarán lanzamientos de patch, ni siquiera para problemas de seguridad críticos. Para obtener rendimiento mejorado, seguridad mejorada y nuevas características, actualice a la versión más reciente de GitHub Enterprise. Para obtener ayuda con la actualización, póngase en contacto con el soporte técnico de GitHub Enterprise.

Las organizaciones

List organizations

Funciona con GitHub Apps

Lists all organizations, in the order that they were created on GitHub Enterprise Server.

Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of organizations.

Parámetros

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Query parameters
Name, Type, Description
sinceinteger

An organization ID. Only return organizations with an ID greater than this ID.

per_pageinteger

The number of results per page (max 100).

Default: 30

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

304

Not modified

Ejemplos de código

get/organizations
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/organizations

Response

Status: 200
[ { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" } ]

Get an organization

Funciona con GitHub Apps

To see many of the organization response values, you need to be an authenticated organization owner with the admin:org scope. When the value of two_factor_requirement_enabled is true, the organization requires all members, billing managers, and outside collaborators to enable two-factor authentication.

GitHub Apps with the Organization plan permission can use this endpoint to retrieve information about an organization's GitHub Enterprise Server plan. See "Authenticating with GitHub Apps" for details. For an example response, see 'Response with GitHub Enterprise Server plan information' below."

Parámetros

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

See preview notice
Path parameters
Name, Type, Description
orgstringRequired

The organization name. The name is not case sensitive.

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

404

Resource not found

Ejemplos de código

get/orgs/{org}
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/orgs/ORG

Default response

Status: 200
{ "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization", "name": "github", "company": "GitHub", "blog": "https://github.com/blog", "location": "San Francisco", "email": "octocat@github.com", "twitter_username": "github", "is_verified": true, "has_organization_projects": true, "has_repository_projects": true, "public_repos": 2, "public_gists": 1, "followers": 20, "following": 0, "html_url": "https://github.com/octocat", "created_at": "2008-01-14T04:33:35Z", "updated_at": "2014-03-03T18:58:10Z", "type": "Organization", "total_private_repos": 100, "owned_private_repos": 100, "private_gists": 81, "disk_usage": 10000, "collaborators": 8, "billing_email": "mona@github.com", "plan": { "name": "Medium", "space": 400, "private_repos": 20, "filled_seats": 4, "seats": 5 }, "default_repository_permission": "read", "members_can_create_repositories": true, "two_factor_requirement_enabled": true, "members_allowed_repository_creation_type": "all", "members_can_create_public_repositories": false, "members_can_create_private_repositories": false, "members_can_create_internal_repositories": false, "members_can_create_pages": true }

Aviso de previsualización

New repository creation permissions are available to preview. You can now use members_can_create_public_repositories, members_can_create_private_repositories, and members_can_create_internal_repositories. You can only allow members to create internal repositories if your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+. These parameters provide more granular permissions to configure the type of repositories organization members can create.

To access these new parameters during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.surtur-preview+json

Update an organization

Funciona con GitHub Apps

Parameter Deprecation Notice: GitHub Enterprise Server will replace and discontinue members_allowed_repository_creation_type in favor of more granular permissions. The new input parameters are members_can_create_public_repositories, members_can_create_private_repositories for all organizations and members_can_create_internal_repositories for organizations associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+. For more information, see the blog post.

Enables an authenticated organization owner with the admin:org scope to update the organization's profile and member privileges.

Parámetros

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

See preview notice
Path parameters
Name, Type, Description
orgstringRequired

The organization name. The name is not case sensitive.

Body parameters
Name, Type, Description
billing_emailstring

Billing email address. This address is not publicized.

companystring

The company name.

emailstring

The publicly visible email address.

twitter_usernamestring

The Twitter username of the company.

locationstring

The location.

namestring

The shorthand name of the company.

descriptionstring

The description of the company.

has_organization_projectsboolean

Whether an organization can use organization projects.

has_repository_projectsboolean

Whether repositories that belong to the organization can use repository projects.

default_repository_permissionstring

Default permission level members have for organization repositories.

Default: read

Can be one of: read, write, admin, none

members_can_create_repositoriesboolean

Whether of non-admin organization members can create repositories. Note: A parameter can override this parameter. See members_allowed_repository_creation_type in this table for details.

Default: true

members_can_create_internal_repositoriesboolean

Whether organization members can create internal repositories, which are visible to all enterprise members. You can only allow members to create internal repositories if your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+. For more information, see "Restricting repository creation in your organization" in the GitHub Help documentation.

members_can_create_private_repositoriesboolean

Whether organization members can create private repositories, which are visible to organization members with permission. For more information, see "Restricting repository creation in your organization" in the GitHub Help documentation.

members_can_create_public_repositoriesboolean

Whether organization members can create public repositories, which are visible to anyone. For more information, see "Restricting repository creation in your organization" in the GitHub Help documentation.

members_allowed_repository_creation_typestring

Specifies which types of repositories non-admin organization members can create. Note: This parameter is deprecated and will be removed in the future. Its return value ignores internal repositories. Using this parameter overrides values set in members_can_create_repositories. See the parameter deprecation notice in the operation description for details.

Can be one of: all, private, none

members_can_create_pagesboolean

Whether organization members can create GitHub Pages sites. Existing published sites will not be impacted.

Default: true

blogstring

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

409

Conflict

422

Validation failed

Ejemplos de código

patch/orgs/{org}
curl \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/orgs/ORG \ -d '{"billing_email":"mona@github.com","company":"GitHub","email":"mona@github.com","twitter_username":"github","location":"San Francisco","name":"github","description":"GitHub, the company.","default_repository_permission":"read","members_can_create_repositories":true,"members_allowed_repository_creation_type":"all"}'

Response

Status: 200
{ "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization", "name": "github", "company": "GitHub", "blog": "https://github.com/blog", "location": "San Francisco", "email": "octocat@github.com", "twitter_username": "github", "is_verified": true, "has_organization_projects": true, "has_repository_projects": true, "public_repos": 2, "public_gists": 1, "followers": 20, "following": 0, "html_url": "https://github.com/octocat", "created_at": "2008-01-14T04:33:35Z", "type": "Organization", "total_private_repos": 100, "owned_private_repos": 100, "private_gists": 81, "disk_usage": 10000, "collaborators": 8, "billing_email": "mona@github.com", "plan": { "name": "Medium", "space": 400, "private_repos": 20 }, "default_repository_permission": "read", "members_can_create_repositories": true, "two_factor_requirement_enabled": true, "members_allowed_repository_creation_type": "all", "members_can_create_public_repositories": false, "members_can_create_private_repositories": false, "members_can_create_internal_repositories": false, "members_can_create_pages": true, "members_can_create_public_pages": true, "members_can_create_private_pages": true, "updated_at": "2014-03-03T18:58:10Z" }

Aviso de previsualización

New repository creation permissions are available to preview. You can now use members_can_create_public_repositories, members_can_create_private_repositories, and members_can_create_internal_repositories. You can only allow members to create internal repositories if your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+. These parameters provide more granular permissions to configure the type of repositories organization members can create.

To access these new parameters during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.surtur-preview+json

List app installations for an organization

Funciona con GitHub Apps

Lists all GitHub Apps in an organization. The installation count includes all GitHub Apps installed on repositories in the organization. You must be an organization owner with admin:read scope to use this endpoint.

Parámetros

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
orgstringRequired

The organization name. The name is not case sensitive.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

Ejemplos de código

get/orgs/{org}/installations
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/orgs/ORG/installations

Response

Status: 200
{ "total_count": 1, "installations": [ { "id": 25381, "account": { "login": "octo-org", "id": 6811672, "node_id": "MDEyOk9yZ2FuaXphdGlvbjY4MTE2NzI=", "avatar_url": "https://avatars3.githubusercontent.com/u/6811672?v=4", "gravatar_id": "", "url": "https://api.github.com/users/octo-org", "html_url": "https://github.com/octo-org", "followers_url": "https://api.github.com/users/octo-org/followers", "following_url": "https://api.github.com/users/octo-org/following{/other_user}", "gists_url": "https://api.github.com/users/octo-org/gists{/gist_id}", "starred_url": "https://api.github.com/users/octo-org/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octo-org/subscriptions", "organizations_url": "https://api.github.com/users/octo-org/orgs", "repos_url": "https://api.github.com/users/octo-org/repos", "events_url": "https://api.github.com/users/octo-org/events{/privacy}", "received_events_url": "https://api.github.com/users/octo-org/received_events", "type": "Organization", "site_admin": false }, "repository_selection": "selected", "access_tokens_url": "https://api.github.com/app/installations/25381/access_tokens", "repositories_url": "https://api.github.com/installation/repositories", "html_url": "https://github.com/organizations/octo-org/settings/installations/25381", "app_id": 2218, "target_id": 6811672, "target_type": "Organization", "permissions": { "deployments": "write", "metadata": "read", "pull_requests": "read", "statuses": "read" }, "events": [ "deployment", "deployment_status" ], "created_at": "2017-05-16T08:47:09.000-07:00", "updated_at": "2017-06-06T11:23:23.000-07:00", "single_file_name": "config.yml", "has_multiple_single_files": true, "single_file_paths": [ "config.yml", ".github/issue_TEMPLATE.md" ], "app_slug": "github-actions", "suspended_at": null, "suspended_by": null } ] }

List organizations for the authenticated user

List organizations for the authenticated user.

OAuth scope requirements

This only lists organizations that your authorization allows you to operate on in some way (e.g., you can list teams with read:org scope, you can publicize your organization membership with user scope, etc.). Therefore, this API requires at least user or read:org scope. OAuth requests with insufficient scope receive a 403 Forbidden response.

Parámetros

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

Ejemplos de código

get/user/orgs
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/user/orgs

Response

Status: 200
[ { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" } ]

List organizations for a user

Funciona con GitHub Apps

List public organization memberships for the specified user.

This method only lists public memberships, regardless of authentication. If you need to fetch all of the organization memberships (public and private) for the authenticated user, use the List organizations for the authenticated user API instead.

Parámetros

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
usernamestringRequired

The handle for the GitHub user account.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

Ejemplos de código

get/users/{username}/orgs
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/users/USERNAME/orgs

Response

Status: 200
[ { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" } ]