Pontos de extremidade da API REST para chaves de implantação
Use a API REST para criar e gerenciar chaves de implantação.
Sobre as chaves de implantação
É possível iniciar projetos por meio de um repositório no GitHub.com ao servidor usando uma chave de implantação, que é uma chave SSH que concede acesso a um só repositório. O GitHub anexa a parte pública da chave diretamente ao repositório em vez de a uma conta pessoal, e a parte privada da chave permanece no seu servidor. Para saber mais, confira Realização de implantações.
As chaves de deploy podem ser configuradas usando os seguintes endpoints de API, ou através da interface da Web GitHub. Para saber como configurar chaves de implantação na interface da Web, confira Gerenciar chaves de implantação.
Há alguns casos em que uma chave de implantação será excluída por outra atividade:
- Se a chave de implantação for criada com uma personal access token, excluir o personal access token também excluirá a chave de implantação. A regeneração personal access token não excluirá a chave de implantação.
- Se a chave de implantação for criada com um OAuth app token, a revogação do token também excluirá a chave de implantação.
Por outro lado, essas atividades não excluirão uma chave de implantação:
- Se a chave de implantação for criada com um GitHub App token de acesso do usuário, a revogação do token não excluirá a chave de implantação.
- Se a chave de implantação for criada com um GitHub App token de acesso de instalação, desinstalar ou excluir o aplicativo não excluirá a chave de implantação.
- Se a chave de implantação for criada com um personal access token, regenerar o personal access token não excluirá a chave de implantação.
List deploy keys
fine_grained_access
works_with_fine_grained_tokens:
permission_set:
- "Administration" repository permissions (read)
Parâmetros para "List deploy keys"
| Nome, Tipo, Descrição |
|---|
accept string Setting to |
| Nome, Tipo, Descrição |
|---|
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo string ObrigatórioThe name of the repository without the |
| Nome, Tipo, Descrição |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
http_status_code
| status_code | Descrição |
|---|---|
200 | OK |
code_samples
request_example
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/repos/OWNER/REPO/keysResponse
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,
"added_by": "octocat",
"last_used": "2022-01-10T15:53:42Z",
"enabled": true
}
]Create a deploy key
You can create a read-only deploy key.
fine_grained_access
works_with_fine_grained_tokens:
permission_set:
- "Administration" repository permissions (write)
Parâmetros para "Create a deploy key"
| Nome, Tipo, Descrição |
|---|
accept string Setting to |
| Nome, Tipo, Descrição |
|---|
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo string ObrigatórioThe name of the repository without the |
| Nome, Tipo, Descrição |
|---|
title string A name for the key. |
key string ObrigatórioThe contents of the key. |
read_only boolean If 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." |
http_status_code
| status_code | Descrição |
|---|---|
201 | Created |
422 | Validation failed, or the endpoint has been spammed. |
code_samples
request_example
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/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,
"added_by": "octocat",
"last_used": "2022-01-10T15:53:42Z",
"enabled": true
}Get a deploy key
fine_grained_access
works_with_fine_grained_tokens:
permission_set:
- "Administration" repository permissions (read)
Parâmetros para "Get a deploy key"
| Nome, Tipo, Descrição |
|---|
accept string Setting to |
| Nome, Tipo, Descrição |
|---|
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo string ObrigatórioThe name of the repository without the |
key_id integer ObrigatórioThe unique identifier of the key. |
http_status_code
| status_code | Descrição |
|---|---|
200 | OK |
404 | Resource not found |
code_samples
request_example
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/repos/OWNER/REPO/keys/KEY_IDResponse
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,
"added_by": "octocat",
"last_used": "2022-01-10T15:53:42Z",
"enabled": true
}Delete a deploy key
Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.
fine_grained_access
works_with_fine_grained_tokens:
permission_set:
- "Administration" repository permissions (write)
Parâmetros para "Delete a deploy key"
| Nome, Tipo, Descrição |
|---|
accept string Setting to |
| Nome, Tipo, Descrição |
|---|
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo string ObrigatórioThe name of the repository without the |
key_id integer ObrigatórioThe unique identifier of the key. |
http_status_code
| status_code | Descrição |
|---|---|
204 | No Content |
code_samples
request_example
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/repos/OWNER/REPO/keys/KEY_IDResponse
Status: 204