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

Create a deploy key

Creates a deploy key that grants access to a repository. Provide the public key in key and optionally set title and read_only to name the key and control its access. A 201 response returns the created deploy key.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

2 parameters · 3 body fields
ownerstringrequired
The account owner of the repository. The name is not case sensitive.
repostringrequired
The repository name without the `.git` extension. The name is not case sensitive.

Deploy key details. key is required.

titlestringoptional
A name for the key.
keystringrequired
The contents of the key.
read_onlybooleanoptional
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](https://docs.github.com/articles/repository-permission-levels-for-an-organization/)" and "[Permission levels for a user account repository](https://docs.github.com/articles/permission-levels-for-a-user-account-repository/)."

2 status codes
201Returns the created deploy key object, including its ID, key, title, verification status, and access mode.
idintegerrequired
keystringrequired
urlstringrequired
titlestringrequired
verifiedbooleanrequired
created_atstringrequired
read_onlybooleanrequired
added_bystringoptional
last_usedstringoptional
enabledbooleanoptional
422Returned when validation fails or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 422 is returned when validation fails or the endpoint is considered spammed. key is required and must contain the key contents. The owner path parameter and repo path parameter must identify the repository where you want to create the deploy key.