REST API endpoints for deploy keys

Use the REST API to create and manage deploy keys.

About deploy keys

You can launch projects from a repository on GitHub.com to your server by using a deploy key, which is an SSH key that grants access to a single repository. GitHub attaches the public part of the key directly to your repository instead of a personal account, and the private part of the key remains on your server. For more information, see Delivering deployments.

Deploy keys can either be set up using the following API endpoints, or by using the GitHub web interface. To learn how to set deploy keys up in the web interface, see Managing deploy keys.

There are a few cases when a deploy key will be deleted by other activity:

Conversely, these activities will not delete a deploy key:

Note

Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.

List deploy keys

GET /repos/{owner}/{repo}/keys

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/keys

Response schema (Status: 200):

Array of Deploy Key:

Create a deploy key

POST /repos/{owner}/{repo}/keys

You can create a read-only deploy key.

Parameters

Headers

Path and query parameters

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X POST \
  https://api.github.com/repos/OWNER/REPO/keys \
  -d '{
  "title": "octocat@octomac",
  "key": "ssh-rsa AAA...",
  "read_only": true
}'

Response schema (Status: 201):

Get a deploy key

GET /repos/{owner}/{repo}/keys/{key_id}

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/repos/OWNER/REPO/keys/KEY_ID

Response schema (Status: 200):

Same response schema as Create a deploy key.

Delete a deploy key

DELETE /repos/{owner}/{repo}/keys/{key_id}

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

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/repos/OWNER/REPO/keys/KEY_ID

Response schema (Status: 204):