Administración de GitHub Enterprise

You can use these GitHub Enterprise Cloud endpoints to administer your enterprise account.

URL de las Terminales

Las terminales de la API de REST—excepto aquellas API de Consola de Administración—llevan un prefijo con la siguiente URL:

http(s)://hostname/api/v3/

Las terminales de la API de Consola de Administración solo llevan un prefijo con un nombre de host:

http(s)://hostname/

Autenticación

Las terminales de la API para tu instalación de GitHub Enterprise acceptan los mismos métodos de autenticación que los de la API de GitHub.com. Puedes autenticarte con Tokens de OAuth (que se pueden crear utilizando la API de Autorizaciones) o con autenticación básica. Los tokens de OAuth deben tener el alcance de OAuth de site_admin cuando se utilicen con las terminales específicas de la empresa.

Solo puede accederse a las terminales de la API para la administración empresarial si se trata de administradores de sitio de GitHub Enterprise, excepto por la API de Consola de Administración, la cual requiere la contraseña de la Consola de Administración.

Información de la versión

La versión actual de una instancia de GitHub Enterprise se devuelve en el encabezado de respuesta de todas las API: X-GitHub-Enterprise-Version: github-ae@latest.0 También puedes leer la versión actual si llamas a la terminal de meta.

Estadísticas de los Administradores

La API de estadísticas de los administradores proporciona diversas métricas sobre tu instalación. Solo se encuentra disponible para los administradores de sitio autenticados. Los usuarios normales recibirán una respuesta 404 si intentan acceder a ella.

get /enterprise/stats/all

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/stats/all
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/all')

Response

Status: 200 OK
{
  "repos": {
    "total_repos": 212,
    "root_repos": 194,
    "fork_repos": 18,
    "org_repos": 51,
    "total_pushes": 3082,
    "total_wikis": 15
  },
  "hooks": {
    "total_hooks": 27,
    "active_hooks": 23,
    "inactive_hooks": 4
  },
  "pages": {
    "total_pages": 36
  },
  "orgs": {
    "total_orgs": 33,
    "disabled_orgs": 0,
    "total_teams": 60,
    "total_team_members": 314
  },
  "users": {
    "total_users": 254,
    "admin_users": 45,
    "suspended_users": 21
  },
  "pulls": {
    "total_pulls": 86,
    "merged_pulls": 60,
    "mergeable_pulls": 21,
    "unmergeable_pulls": 3
  },
  "issues": {
    "total_issues": 179,
    "open_issues": 83,
    "closed_issues": 96
  },
  "milestones": {
    "total_milestones": 7,
    "open_milestones": 6,
    "closed_milestones": 1
  },
  "gists": {
    "total_gists": 178,
    "private_gists": 151,
    "public_gists": 25
  },
  "comments": {
    "total_commit_comments": 6,
    "total_gist_comments": 28,
    "total_issue_comments": 366,
    "total_pull_request_comments": 30
  }
}

get /enterprise/stats/comments

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/stats/comments
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/comments')

Response

Status: 200 OK

get /enterprise/stats/gists

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/stats/gists
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/gists')

Response

Status: 200 OK

get /enterprise/stats/hooks

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/stats/hooks
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/hooks')

Response

Status: 200 OK

get /enterprise/stats/issues

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/stats/issues
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/issues')

Response

Status: 200 OK

get /enterprise/stats/milestones

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/stats/milestones
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/milestones')

Response

Status: 200 OK

get /enterprise/stats/orgs

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/stats/orgs
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/orgs')

Response

Status: 200 OK

get /enterprise/stats/pages

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/stats/pages
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/pages')

Response

Status: 200 OK

get /enterprise/stats/pulls

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/stats/pulls
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/pulls')

Response

Status: 200 OK

get /enterprise/stats/repos

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/stats/repos
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/repos')

Response

Status: 200 OK

get /enterprise/stats/users

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/stats/users
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/users')

Response

Status: 200 OK

Webhooks globales

Los webhooks globales se instalan en una instancia de GitHub Enterprise. Puedes utilizar los webhooks globales para controlar, responder o aplicar reglas automáticamente para la administración de usuarios, organizaciones, equipos y repositorios en tu instancia. Los webhooks globales se pueden suscribir a los tipos de evento para organizaciones, usuarios, repositorios, equipos, miembros, membrecías, bifuraciones, y pings.

Esta API solo se encuentra disponible para los administradores de sitio autenticados. Los usuarios normales recibirán una respuesta 404 si intentan acceder a ella. Para aprender cómo configurar los webhooks globales, consulta la sección Acerca de los webhooks globales.

get /admin/hooks

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

accept string header

This API is under preview and subject to change.

Default: application/vnd.github.superpro-preview+json
per_page integer query

Results per page (max 100)

Default: 30
page integer query

Page number of the results to fetch.

Default: 1

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  https://{hostname}/api/v3/admin/hooks
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/hooks', {
  mediaType: {
    previews: [
      'superpro'
    ]
  }
})

Response

Status: 200 OK
[
  {
    "type": "Global",
    "id": 1,
    "name": "web",
    "active": true,
    "events": [
      "organization",
      "user"
    ],
    "config": {
      "url": "https://example.com",
      "content_type": "json",
      "insecure_ssl": "0",
      "secret": "********"
    },
    "updated_at": "2017-12-07T00:14:59Z",
    "created_at": "2017-12-07T00:14:59Z",
    "url": "https://api.github.com/admin/hooks/1",
    "ping_url": "https://api.github.com/admin/hooks/1/pings"
  }
]

Aviso de previsualización

The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.superpro-preview+json
☝️El encabezado es requerido.

post /admin/hooks

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

accept string header

This API is under preview and subject to change.

Default: application/vnd.github.superpro-preview+json
name string body

Required. Must be passed as "web".

config object body

Required. Key/value pairs to provide settings for this webhook.

Properties of the config object
url (string)

Required. The URL to which the payloads will be delivered.

content_type (string)

The media type used to serialize the payloads. Supported values include json and form. The default is form.

secret (string)

If provided, the secret will be used as the key to generate the HMAC hex digest value in the X-Hub-Signature header.

insecure_ssl (string)

Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Supported values include 0 (verification is performed) and 1 (verification is not performed). The default is 0. We strongly recommend not setting this to 1 as you are subject to man-in-the-middle and other attacks.

events array of strings body

The events that trigger this webhook. A global webhook can be triggered by user and organization events. Default: user and organization.

active boolean body

Determines if notifications are sent when the webhook is triggered. Set to true to send notifications.

Default: true

Ejemplos de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  https://{hostname}/api/v3/admin/hooks \
  -d '{"name":"name","config":{"url":"url","content_type":"content_type","secret":"secret","insecure_ssl":"insecure_ssl"}}'
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/hooks', {
  name: 'name',
  config: {
    url: 'url',
    content_type: 'content_type',
    secret: 'secret',
    insecure_ssl: 'insecure_ssl'
  },
  mediaType: {
    previews: [
      'superpro'
    ]
  }
})

Response

Status: 201 Created
{
  "type": "Global",
  "id": 1,
  "name": "web",
  "active": true,
  "events": [
    "organization",
    "user"
  ],
  "config": {
    "url": "https://example.com",
    "content_type": "json",
    "insecure_ssl": "0",
    "secret": "********"
  },
  "updated_at": "2017-12-07T00:14:59Z",
  "created_at": "2017-12-07T00:14:59Z",
  "url": "https://api.github.com/admin/hooks/1",
  "ping_url": "https://api.github.com/admin/hooks/1/pings"
}

Aviso de previsualización

The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.superpro-preview+json
☝️El encabezado es requerido.

get /admin/hooks/{hook_id}

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

accept string header

This API is under preview and subject to change.

Default: application/vnd.github.superpro-preview+json
hook_id integer path

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  https://{hostname}/api/v3/admin/hooks/42
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/hooks/{hook_id}', {
  hook_id: 42,
  mediaType: {
    previews: [
      'superpro'
    ]
  }
})

Response

Status: 200 OK
{
  "type": "Global",
  "id": 1,
  "name": "web",
  "active": true,
  "events": [
    "organization",
    "user"
  ],
  "config": {
    "url": "https://example.com",
    "content_type": "json",
    "insecure_ssl": "0",
    "secret": "********"
  },
  "updated_at": "2017-12-07T00:14:59Z",
  "created_at": "2017-12-07T00:14:59Z",
  "url": "https://api.github.com/admin/hooks/1",
  "ping_url": "https://api.github.com/admin/hooks/1/pings"
}

Aviso de previsualización

The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.superpro-preview+json
☝️El encabezado es requerido.

Update a global webhook

Parameters that are not provided will be overwritten with the default value or removed if no default exists.

patch /admin/hooks/{hook_id}

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

accept string header

This API is under preview and subject to change.

Default: application/vnd.github.superpro-preview+json
hook_id integer path
config object body

Key/value pairs to provide settings for this webhook.

Properties of the config object
url (string)

Required. The URL to which the payloads will be delivered.

content_type (string)

The media type used to serialize the payloads. Supported values include json and form. The default is form.

secret (string)

If provided, the secret will be used as the key to generate the HMAC hex digest value in the X-Hub-Signature header.

insecure_ssl (string)

Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Supported values include 0 (verification is performed) and 1 (verification is not performed). The default is 0. We strongly recommend not setting this to 1 as you are subject to man-in-the-middle and other attacks.

events array of strings body

The events that trigger this webhook. A global webhook can be triggered by user and organization events. Default: user and organization.

active boolean body

Determines if notifications are sent when the webhook is triggered. Set to true to send notifications.

Default: true

Ejemplos de código

Shell
curl \
  -X PATCH \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  https://{hostname}/api/v3/admin/hooks/42 \
  -d '{"config":{"url":"url","content_type":"content_type","secret":"secret","insecure_ssl":"insecure_ssl"}}'
JavaScript (@octokit/core.js)
await octokit.request('PATCH /admin/hooks/{hook_id}', {
  hook_id: 42,
  config: {
    url: 'url',
    content_type: 'content_type',
    secret: 'secret',
    insecure_ssl: 'insecure_ssl'
  },
  mediaType: {
    previews: [
      'superpro'
    ]
  }
})

Response

Status: 200 OK
{
  "type": "Global",
  "id": 1,
  "name": "web",
  "active": true,
  "events": [
    "organization"
  ],
  "config": {
    "url": "https://example.com",
    "content_type": "form",
    "insecure_ssl": "0"
  },
  "updated_at": "2017-12-07T00:14:59Z",
  "created_at": "2017-12-07T00:14:59Z",
  "url": "https://api.github.com/admin/hooks/1",
  "ping_url": "https://api.github.com/admin/hooks/1/pings"
}

Aviso de previsualización

The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.superpro-preview+json
☝️El encabezado es requerido.

delete /admin/hooks/{hook_id}

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

accept string header

This API is under preview and subject to change.

Default: application/vnd.github.superpro-preview+json
hook_id integer path

Ejemplos de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  https://{hostname}/api/v3/admin/hooks/42
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/hooks/{hook_id}', {
  hook_id: 42,
  mediaType: {
    previews: [
      'superpro'
    ]
  }
})

Response

Status: 204 No Content

Aviso de previsualización

The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.superpro-preview+json
☝️El encabezado es requerido.

Ping a global webhook

This will trigger a ping event to be sent to the webhook.

post /admin/hooks/{hook_id}/pings

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

accept string header

This API is under preview and subject to change.

Default: application/vnd.github.superpro-preview+json
hook_id integer path

Ejemplos de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  https://{hostname}/api/v3/admin/hooks/42/pings
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/hooks/{hook_id}/pings', {
  hook_id: 42,
  mediaType: {
    previews: [
      'superpro'
    ]
  }
})

Response

Status: 204 No Content

Aviso de previsualización

The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.superpro-preview+json
☝️El encabezado es requerido.

LDAP

Puedes utilizar la API de LDAP para actualizar las relaciones de cuenta entre un usuario de Servidor de GitHub Enterprise o un equipo y su entrada enlazada de LDAP o poner en cola una sincronización nueva.

Con las terminales de mapeo de LDAP, puedes actualizar el Nombre Distintivo (DN, por sus siglas en inglés) al cual mapea un usuario o equipo. Nota que las terminales de LDAP generalmente solo son efectivas si tu aplicativo de Servidor de GitHub Enterprise habilitó la sincronización con LDAP. La terminal de mapeo de LDAP para actualización para un usuario puede utilizarse cuando se habilita LDAP, aún si la sincronización con LDAP está inhabilitada.

Licencia

La API de licencias proporciona información sobre tu licencia empresarial. Solo se encuentra disponible para los administradores de sitio autenticados. Los usuarios normales recibirán una respuesta 404 si intentan acceder a ella.

get /enterprise/settings/license

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/enterprise/settings/license
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/settings/license')

Response

Status: 200 OK
{
  "seats": 1400,
  "seats_used": 1316,
  "seats_available": 84,
  "kind": "standard",
  "days_until_expiration": 365,
  "expire_at": "2016/02/06 12:41:52 -0600"
}

Consola de administración

La API de la Consola de Administración te ayuda a administrar tu Servidor de GitHub Enterprise instalación.

Debes configurar el número de puerto explícitamente cuando haces llamadas de la API hacia la Consola de Administración. Si se habilita el TLS en tu instancia empresarial, el número de puerto es 8443; de lo contrario, el número de puerto será 8080.

Si no quieres proporcionar un número de puerto, necesitarás configurar tu herramienta para seguir automáticamente las redirecciones.

También necesitas agregar el marcador -k cuando utilices curl, ya que Servidor de GitHub Enterprise utiliza un certificado auto-firmado antes de que agregues tu propio certificado TLS.

Autenticación

Necesitas pasar tu Contraseña de la Consola de Administración como un token de autenticación para cada terminal de la API de ésta, con excepción de /setup/api/start.

Utiliza el parámetro de api_key para enviar este token con cada solicitud. Por ejemplo:

$ curl -L 'https://hostname:admin_port/setup/api?api_key=your-amazing-password'

También puedes utilizar la autenticación HTTP estándar para enviar este token. Por ejemplo:

$ curl -L 'https://api_key:your-amazing-password@hostname:admin_port/setup/api'

Organizaciones

La API de Administración de la organización te permite crear organizaciones en un aplicativo de Servidor de GitHub Enterprise. Solo se encuentra disponible para los administradores de sitio autenticados. Los usuarios normales recibirán una respuesta 404 si intentan acceder a ella.

post /admin/organizations

Parámetros

Name Type In Description
accept string header

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

login string body

Required. The organization's username.

admin string body

Required. The login of the user who will manage this organization.

profile_name string body

The organization's display name.

Ejemplos de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/admin/organizations \
  -d '{"login":"login","admin":"admin"}'
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/organizations', {
  login: 'login',
  admin: 'admin'
})

Response

Status: 201 Created
{
  "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"
}

patch /admin/organizations/{org}

Parámetros

Name Type In Description
accept string header

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

org string path
login string body

Required. The organization's new name.

Ejemplos de código

Shell
curl \
  -X PATCH \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/admin/organizations/ORG \
  -d '{"login":"login"}'
JavaScript (@octokit/core.js)
await octokit.request('PATCH /admin/organizations/{org}', {
  org: 'org',
  login: 'login'
})

Response

Status: 202 Accepted
{
  "message": "Job queued to rename organization. It may take a few minutes to complete.",
  "url": "https://<hostname>/api/v3/organizations/1"
}

Ganchos de Pre-recepción de la Organización

La API de Ganchos de Pre-recepción de la Organización te permite ver y modificar la aplicación de dichos ganchos que están disponibles para una organización.

Atributos de objeto

NombreTipoDescripción
name (nombre)secuenciaEl nombre del gancho.
enforcementsecuenciaEl estado de imposición del gancho en este repositorio.
allow_downstream_configurationbooleanSi los repositorios pueden ignorar la imposición o no.
configuration_urlsecuenciaURL para la terminal en donde se configuró la imposición.

Los valores posibles para enforcement son enabled, disabled y testing. El valor disabled indica que el gancho de pre-recepción no se ejecutará. El valor enabled indica que se ejecutará y rechazará cualquier carga que resulte en un estado diferente a zero. El valor testing indica que el script va a ejecutarse pero no va a causar que se rechace ninguna carga.

configuration_url podría ser un enlace a esta terminal o ser la configuración global de este gancho. Solo los administradores de sistema pueden acceder a la configuración global.

Ambientes de pre-recepción

La API de Ambientes de Pre-recepción te permite crear, listar, actualizar y borrar ambientes para los ganchos de pre-recepción. Solo se encuentra disponible para los administradores de sitio autenticados. Los usuarios normales recibirán una respuesta 404 si intentan acceder a ella.

Atributos de objeto

Ambiente de pre-recepción

NombreTipoDescripción
name (nombre)secuenciaEl nombre del ambiente como se muestra en la IU.
image_urlsecuenciaLa URL del tarball que se descargará y extraerá.
default_environmentbooleanSi este es el ambiente predeterminado que viene con Servidor de GitHub Enterprise o no.
descargarobjetoEl estado de descarga de este ambiente.
hooks_countnúmeroLa cantidad de ganchos de pre-recepción que utilizan este ambiente.

Descarga del Ambiente de Pre-recepción

NombreTipoDescripción
statesecuenciaEl estado de la mayoría de las descargas recientes.
downloaded_atsecuenciaLa hora en la cual iniciaron la mayoría de las descrgas recientes.
messagesecuenciaCuando algo falla, este tendrá cualquier mensaje de error que se haya producido.

Los valores posibles para state son not_started, in_progress, success, failed.

get /admin/pre-receive-environments

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

per_page integer query

Results per page (max 100)

Default: 30
page integer query

Page number of the results to fetch.

Default: 1
direction string query

One of asc (ascending) or desc (descending).

Default: desc
sort string query Default: created

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.eye-scream-preview+json" \
  https://{hostname}/api/v3/admin/pre-receive-environments
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/pre-receive-environments', {
  mediaType: {
    previews: [
      'eye-scream'
    ]
  }
})

Response

Status: 200 OK
[
  {
    "id": 1,
    "name": "Default",
    "image_url": "githubenterprise://internal",
    "url": "https://github.example.com/api/v3/admin/pre-receive-environments/1",
    "html_url": "https://github.example.com/admin/pre-receive-environments/1",
    "default_environment": true,
    "created_at": "2016-05-20T11:35:45-05:00",
    "hooks_count": 14,
    "download": {
      "url": "https://github.example.com/api/v3/admin/pre-receive-environments/1/downloads/latest",
      "state": "not_started",
      "downloaded_at": "2016-05-26T07:42:53-05:00",
      "message": null
    }
  },
  {
    "id": 2,
    "name": "DevTools Hook Env",
    "image_url": "https://my_file_server/path/to/devtools_env.tar.gz",
    "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2",
    "html_url": "https://github.example.com/admin/pre-receive-environments/2",
    "default_environment": false,
    "created_at": "2016-05-20T11:35:45-05:00",
    "hooks_count": 1,
    "download": {
      "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest",
      "state": "success",
      "downloaded_at": "2016-05-26T07:42:53-05:00",
      "message": null
    }
  }
]

Aviso de previsualización

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview
☝️El encabezado es requerido.

post /admin/pre-receive-environments

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

name string body

Required. The new pre-receive environment's name.

image_url string body

Required. URL from which to download a tarball of this environment.

Ejemplos de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.eye-scream-preview+json" \
  https://{hostname}/api/v3/admin/pre-receive-environments \
  -d '{"name":"name","image_url":"image_url"}'
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/pre-receive-environments', {
  name: 'name',
  image_url: 'image_url',
  mediaType: {
    previews: [
      'eye-scream'
    ]
  }
})

Response

Status: 201 Created
{
  "id": 2,
  "name": "DevTools Hook Env",
  "image_url": "https://my_file_server/path/to/devtools_env.tar.gz",
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2",
  "html_url": "https://github.example.com/admin/pre-receive-environments/2",
  "default_environment": false,
  "created_at": "2016-05-20T11:35:45-05:00",
  "hooks_count": 1,
  "download": {
    "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest",
    "state": "not_started",
    "downloaded_at": null,
    "message": null
  }
}

Aviso de previsualización

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview
☝️El encabezado es requerido.

get /admin/pre-receive-environments/{pre_receive_environment_id}

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

pre_receive_environment_id integer path

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.eye-scream-preview+json" \
  https://{hostname}/api/v3/admin/pre-receive-environments/42
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/pre-receive-environments/{pre_receive_environment_id}', {
  pre_receive_environment_id: 42,
  mediaType: {
    previews: [
      'eye-scream'
    ]
  }
})

Response

Status: 200 OK
{
  "id": 2,
  "name": "DevTools Hook Env",
  "image_url": "https://my_file_server/path/to/devtools_env.tar.gz",
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2",
  "html_url": "https://github.example.com/admin/pre-receive-environments/2",
  "default_environment": false,
  "created_at": "2016-05-20T11:35:45-05:00",
  "hooks_count": 1,
  "download": {
    "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest",
    "state": "not_started",
    "downloaded_at": null,
    "message": null
  }
}

Aviso de previsualización

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview
☝️El encabezado es requerido.

Update a pre-receive environment

You cannot modify the default environment. If you attempt to modify the default environment, you will receive a 422 Unprocessable Entity response.

patch /admin/pre-receive-environments/{pre_receive_environment_id}

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

pre_receive_environment_id integer path
name string body

This pre-receive environment's new name.

image_url string body

URL from which to download a tarball of this environment.

Ejemplos de código

Shell
curl \
  -X PATCH \
  -H "Accept: application/vnd.github.eye-scream-preview+json" \
  https://{hostname}/api/v3/admin/pre-receive-environments/42 \
  -d '{"name":"name"}'
JavaScript (@octokit/core.js)
await octokit.request('PATCH /admin/pre-receive-environments/{pre_receive_environment_id}', {
  pre_receive_environment_id: 42,
  name: 'name',
  mediaType: {
    previews: [
      'eye-scream'
    ]
  }
})

Response

Status: 200 OK
{
  "id": 2,
  "name": "DevTools Hook Env",
  "image_url": "https://my_file_server/path/to/devtools_env.tar.gz",
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2",
  "html_url": "https://github.example.com/admin/pre-receive-environments/2",
  "default_environment": false,
  "created_at": "2016-05-20T11:35:45-05:00",
  "hooks_count": 1,
  "download": {
    "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest",
    "state": "success",
    "downloaded_at": "2016-05-26T07:42:53-05:00",
    "message": null
  }
}

Client Errors

Status: 422 Unprocessable Entity
{
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PreReceiveEnvironment",
      "code": "custom",
      "message": "Cannot modify or delete the default environment"
    }
  ]
}

Aviso de previsualización

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview
☝️El encabezado es requerido.

Delete a pre-receive environment

If you attempt to delete an environment that cannot be deleted, you will receive a 422 Unprocessable Entity response.

The possible error messages are:

  • Cannot modify or delete the default environment
  • Cannot delete environment that has hooks
  • Cannot delete environment when download is in progress
delete /admin/pre-receive-environments/{pre_receive_environment_id}

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

pre_receive_environment_id integer path

Ejemplos de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.eye-scream-preview+json" \
  https://{hostname}/api/v3/admin/pre-receive-environments/42
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/pre-receive-environments/{pre_receive_environment_id}', {
  pre_receive_environment_id: 42,
  mediaType: {
    previews: [
      'eye-scream'
    ]
  }
})

Response

Status: 204 No Content

Client Errors

Status: 422 Unprocessable Entity
{
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PreReceiveEnvironment",
      "code": "custom",
      "message": "Cannot modify or delete the default environment"
    }
  ]
}

Aviso de previsualización

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview
☝️El encabezado es requerido.

Start a pre-receive environment download

Triggers a new download of the environment tarball from the environment's image_url. When the download is finished, the newly downloaded tarball will overwrite the existing environment.

If a download cannot be triggered, you will receive a 422 Unprocessable Entity response.

The possible error messages are:

  • Cannot modify or delete the default environment
  • Can not start a new download when a download is in progress
post /admin/pre-receive-environments/{pre_receive_environment_id}/downloads

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

pre_receive_environment_id integer path

Ejemplos de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.eye-scream-preview+json" \
  https://{hostname}/api/v3/admin/pre-receive-environments/42/downloads
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/pre-receive-environments/{pre_receive_environment_id}/downloads', {
  pre_receive_environment_id: 42,
  mediaType: {
    previews: [
      'eye-scream'
    ]
  }
})

Response

Status: 202 Accepted
{
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/3/downloads/latest",
  "state": "not_started",
  "downloaded_at": null,
  "message": null
}

Client Errors

Status: 422 Unprocessable Entity
{
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PreReceiveEnvironment",
      "code": "custom",
      "message": "Can not start a new download when a download is in progress"
    }
  ]
}

Aviso de previsualización

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview
☝️El encabezado es requerido.

Get the download status for a pre-receive environment

In addition to seeing the download status at the "Get a pre-receive environment" endpoint, there is also this separate endpoint for just the download status.

get /admin/pre-receive-environments/{pre_receive_environment_id}/downloads/latest

Parámetros

Name Type In Description
accept string header

This API is under preview and subject to change.Ver aviso de previsualización

pre_receive_environment_id integer path

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.eye-scream-preview+json" \
  https://{hostname}/api/v3/admin/pre-receive-environments/42/downloads/latest
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/pre-receive-environments/{pre_receive_environment_id}/downloads/latest', {
  pre_receive_environment_id: 42,
  mediaType: {
    previews: [
      'eye-scream'
    ]
  }
})

Response

Status: 200 OK
{
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/3/downloads/latest",
  "state": "success",
  "downloaded_at": "2016-05-26T07:42:53-05:00",
  "message": null
}

Aviso de previsualización

APIs for managing pre-receive hooks are currently available for developers to preview. During the preview period, the APIs may change without advance notice.

To access the API you must provide a custom media type in the Accept header:

application/vnd.github.eye-scream-preview
☝️El encabezado es requerido.

Ganchos de pre-recepción

La API de Ganchos Pre-recepción te permite crear, listar, actualizar y borrar los ganchos de pre-recepción. Solo se encuentra disponible para los administradores de sitio autenticados. Los usuarios normales recibirán una respuesta 404 si intentan acceder a ella.

Atributos de objeto

Ganchos de pre-recepción

NombreTipoDescripción
name (nombre)secuenciaEl nombre del gancho.
scriptsecuenciaEl script que ejecuta el gancho.
script_repositoryobjetoEl repositorio de GitHub en donde se mantiene el script.
entornoobjetoEl ambiente de pre-recepción en donde se ejecuta el script.
enforcementsecuenciaEl estado de las imposiciones para este gancho.
allow_downstream_configurationbooleanSi las imposiciones pueden o no ignorarse a nivel de organización o de repositorio.

Los valores posibles para enforcement son enabled, disabled y testing. El valor disabled indica que el gancho de pre-recepción no se ejecutará. El valor enabled indica que se ejecutará y rechazará cualquier carga que resulte en un estado diferente a zero. El valor testing indica que el script va a ejecutarse pero no va a causar que se rechace ninguna carga.

Ganchos de pre-recepción del repositorio

La API de Ganchos de Pre-recepción para Repositorios te permite ver y modificar la imposición de los ganchos de pre-recepción que están disponibles para un repositorio.

Atributos de objeto

NombreTipoDescripción
name (nombre)secuenciaEl nombre del gancho.
enforcementsecuenciaEl estado de imposición del gancho en este repositorio.
configuration_urlsecuenciaURL para la terminal en donde se configuró la imposición.

Los valores posibles para enforcement son enabled, disabled y testing. El valor disabled indica que el gancho de pre-recepción no se ejecutará. El valor enabled indica que se ejecutará y rechazará cualquier carga que resulte en un estado diferente a zero. El valor testing indica que el script va a ejecutarse pero no va a causar que se rechace ninguna carga.

configuration_url podría ser un enlace a este repositorio, al propietario de su organización o a su configuración global. La autorización para acceder a esta terminal en configuration_url se determina a nivel de administrador de sitio o de propietario.

Buscar en los índices

La API de Búsqueda en los índices te permite poner en cola varias tareas de búsqueda en los índices. Solo se encuentra disponible para los administradores de sitio autenticados. Los usuarios normales recibirán una respuesta 404 si intentan acceder a ella.

Usuarios

La API de Administración de usuarios te permite promover, degradar, suspender y dejar de suspender a los usuarios en un aplicativo de Servidor de GitHub Enterprise. Solo se encuentra disponible para los administradores de sitio autenticados. Los usuarios normales recibirán una respuesta 403 si intentan acceder a ella.

get /admin/keys

Parámetros

Name Type In Description
accept string header

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

per_page integer query

Results per page (max 100)

Default: 30
page integer query

Page number of the results to fetch.

Default: 1
direction string query

One of asc (ascending) or desc (descending).

Default: desc
sort string query Default: created
since string query

Only show public keys accessed after the given time.

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/admin/keys
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/keys')

Response

Status: 200 OK
[
  {
    "key": "2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234",
    "id": 2,
    "url": "https://api.github.com/user/keys/2",
    "title": "ssh-rsa AAAAB3NzaC1yc2EAAA",
    "created_at": "2020-06-11T21:31:57Z",
    "verified": false,
    "read_only": false,
    "last_used": "2020-06-11T22:31:57Z",
    "user_id": 1,
    "repository_id": 2
  },
  {
    "key": "9Og8iYjAyymI9LvABpJerYrMxURPc8r+dB7TJyvv1234",
    "id": 3,
    "url": "https://api.github.com/user/keys/2",
    "title": "ssh-rsa AAAAB3NzaC1yc2EAAA",
    "created_at": "2020-06-11T21:31:57Z",
    "verified": false,
    "read_only": false,
    "last_used": "2020-06-11T22:31:57Z",
    "user_id": 1,
    "repository_id": 2
  }
]

delete /admin/keys/{key_ids}

Parámetros

Name Type In Description
accept string header

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

key_ids string path

Ejemplos de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/admin/keys/KEY_IDS
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/keys/{key_ids}', {
  key_ids: 'key_ids'
})

Response

Status: 204 No Content

List personal access tokens

Lists personal access tokens for all users, including admin users.

get /admin/tokens

Parámetros

Name Type In Description
accept string header

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

per_page integer query

Results per page (max 100)

Default: 30
page integer query

Page number of the results to fetch.

Default: 1

Ejemplos de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/admin/tokens
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/tokens')

Response

Status: 200 OK
[
  {
    "id": 1,
    "url": "https://api.github.com/authorizations/1",
    "scopes": [
      "public_repo"
    ],
    "token": "ghu_16C7e42F292c6912E7710c838347Ae178B4a",
    "token_last_eight": "Ae178B4a",
    "hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8",
    "app": {
      "url": "http://my-github-app.com",
      "name": "my github app",
      "client_id": "abcde12345fghij67890"
    },
    "note": "optional note",
    "note_url": "http://optional/note/url",
    "updated_at": "2011-09-06T20:39:23Z",
    "created_at": "2011-09-06T17:26:27Z",
    "expires_at": "2011-09-08T17:26:27Z",
    "fingerprint": "jklmnop12345678"
  }
]

Delete a personal access token

Deletes a personal access token. Returns a 403 - Forbidden status when a personal access token is in use. For example, if you access this endpoint with the same personal access token that you are trying to delete, you will receive this error.

delete /admin/tokens/{token_id}

Parámetros

Name Type In Description
accept string header

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

token_id integer path

Ejemplos de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/admin/tokens/42
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/tokens/{token_id}', {
  token_id: 42
})

Response

Status: 204 No Content

Delete a user

Deleting a user will delete all their repositories, gists, applications, and personal settings. Suspending a user is often a better option.

You can delete any user account except your own.

delete /admin/users/{username}

Parámetros

Name Type In Description
accept string header

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

username string path

Ejemplos de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/admin/users/USERNAME
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/users/{username}', {
  username: 'username'
})

Response

Status: 204 No Content

post /admin/users/{username}/authorizations

Parámetros

Name Type In Description
accept string header

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

username string path
scopes array of strings body

A list of scopes.

Ejemplos de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/admin/users/USERNAME/authorizations \
  -d '{"scopes":["scopes"]}'
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/users/{username}/authorizations', {
  username: 'username',
  scopes: [
    'scopes'
  ]
})

Response

Status: 201 Created
{
  "id": 1,
  "url": "https://api.github.com/authorizations/1",
  "scopes": [
    "public_repo"
  ],
  "token": "ghu_16C7e42F292c6912E7710c838347Ae178B4a",
  "token_last_eight": "Ae178B4a",
  "hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8",
  "app": {
    "url": "http://my-github-app.com",
    "name": "my github app",
    "client_id": "abcde12345fghij67890"
  },
  "note": "optional note",
  "note_url": "http://optional/note/url",
  "updated_at": "2011-09-06T20:39:23Z",
  "created_at": "2011-09-06T17:26:27Z",
  "expires_at": "2011-10-06T17:26:27Z",
  "fingerprint": ""
}

delete /admin/users/{username}/authorizations

Parámetros

Name Type In Description
accept string header

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

username string path

Ejemplos de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/admin/users/USERNAME/authorizations
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/users/{username}/authorizations', {
  username: 'username'
})

Response

Status: 204 No Content

Suspend a user

If your GitHub instance uses LDAP Sync with Active Directory LDAP servers, Active Directory LDAP-authenticated users cannot be suspended through this API. If you attempt to suspend an Active Directory LDAP-authenticated user through this API, it will return a 403 response.

You can suspend any user account except your own.

Note that, if you choose not to pass any parameters, you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

put /users/{username}/suspended

Parámetros

Name Type In Description
accept string header

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

username string path
reason string body

The reason the user is being suspended. This message will be logged in the audit log. If you don't provide a reason, it will default to "Suspended via API by SITE_ADMINISTRATOR", where SITE_ADMINISTRATOR is the person who performed the action.

Ejemplos de código

Shell
curl \
  -X PUT \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/users/USERNAME/suspended \
  -d '{"reason":"reason"}'
JavaScript (@octokit/core.js)
await octokit.request('PUT /users/{username}/suspended', {
  username: 'username',
  reason: 'reason'
})

Response

Status: 204 No Content

Unsuspend a user

If your GitHub instance uses LDAP Sync with Active Directory LDAP servers, this API is disabled and will return a 403 response. Active Directory LDAP-authenticated users cannot be unsuspended using the API.

delete /users/{username}/suspended

Parámetros

Name Type In Description
accept string header

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

username string path
reason string body

The reason the user is being unsuspended. This message will be logged in the audit log. If you don't provide a reason, it will default to "Unsuspended via API by SITE_ADMINISTRATOR", where SITE_ADMINISTRATOR is the person who performed the action.

Ejemplos de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://{hostname}/api/v3/users/USERNAME/suspended \
  -d '{"reason":"reason"}'
JavaScript (@octokit/core.js)
await octokit.request('DELETE /users/{username}/suspended', {
  username: 'username',
  reason: 'reason'
})

Response

Status: 204 No Content

Did this doc help you?Privacy policy

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

O, learn how to contribute.