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.

Claves de implementación

La API de Claves de implementación permite crear y administrar claves de implementación.

Acerca de la API de claves de implementación

Puedes lanzar proyectos hacia tu servidor desde un repositorio de your GitHub Enterprise Server instance utilizando una llave de despliegue, la cual es una llave SSH que otorga acceso a un repositorio único. GitHub Enterprise Server adjunta la parte pública de la llave directamente en tu repositorio en vez de hacerlo a una cuenta personal, mientras que la parte privada de la clave permanece en tu servidor. Para más información, vea "Entrega de implementaciones".

Las llaves de despliegue pueden ya sea configurarse utilizando las siguientes terminales de la API, o mediante GitHub. Para descubrir cómo configurar las claves de implementación en GitHub, vea "Administración de claves de implementación".

List deploy keys

Funciona con GitHub Apps

Parámetros

Headers
Name, Type, Description
acceptstring

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

Path parameters
Name, Type, Description
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. 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/repos/{owner}/{repo}/keys
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys

Response

Create a deploy key

Funciona con GitHub Apps

You can create a read-only deploy key.

Parámetros

Headers
Name, Type, Description
acceptstring

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

Path parameters
Name, Type, Description
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

Body parameters
Name, Type, Description
titlestring

A name for the key.

keystringRequired

The contents of the key.

read_onlyboolean

If true, the key will only be able to read repository contents. Otherwise, the key will be able to read and write.

Deploy keys with write access can perform the same actions as an organization member with admin access, or a collaborator on a personal repository. For more information, see "Repository permission levels for an organization" and "Permission levels for a user account repository."

Códigos de estado de respuesta HTTP

status codeDescripción
201

Created

422

Validation failed, or the endpoint has been spammed.

Ejemplos de código

post/repos/{owner}/{repo}/keys
curl \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys \ -d '{"title":"octocat@octomac","key":"ssh-rsa AAA...","read_only":true}'

Response

Status: 201
{ "id": 1, "key": "ssh-rsa AAA...", "url": "https://api.github.com/repos/octocat/Hello-World/keys/1", "title": "octocat@octomac", "verified": true, "created_at": "2014-12-10T15:53:42Z", "read_only": true }

Get a deploy key

Funciona con GitHub Apps

Parámetros

Headers
Name, Type, Description
acceptstring

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

Path parameters
Name, Type, Description
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

key_idintegerRequired

The unique identifier of the key.

Códigos de estado de respuesta HTTP

status codeDescripción
200

OK

404

Resource not found

Ejemplos de código

get/repos/{owner}/{repo}/keys/{key_id}
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_ID

Response

Status: 200
{ "id": 1, "key": "ssh-rsa AAA...", "url": "https://api.github.com/repos/octocat/Hello-World/keys/1", "title": "octocat@octomac", "verified": true, "created_at": "2014-12-10T15:53:42Z", "read_only": true }

Delete a deploy key

Funciona con GitHub Apps

Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.

Parámetros

Headers
Name, Type, Description
acceptstring

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

Path parameters
Name, Type, Description
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

key_idintegerRequired

The unique identifier of the key.

Códigos de estado de respuesta HTTP

status codeDescripción
204

No Content

Ejemplos de código

delete/repos/{owner}/{repo}/keys/{key_id}
curl \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_ID

Response

Status: 204