# Create a deploy key

From **GitHub v3 REST API**.

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

You can create a read-only deploy key.

## Parameters

### `owner`

- Location: path
- Required: true
- Type: `string`

### `repo`

- Location: path
- Required: true
- Type: `string`

## Request body

- Required: true
### `application/json`

- Type: `object`

```json
{
  "key": "ssh-rsa AAA...",
  "read_only": true,
  "title": "octocat@octomac"
}
```

```json
{"properties":{"key":{"description":"The contents of the key.","type":"string"},"read_only":{"description":"If `true`, the key will only be able to read repository contents. Otherwise, the key will be able to read and write.  \n  \nDeploy 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/).\"","type":"boolean"},"title":{"description":"A name for the key.","type":"string"}},"required":["key"],"type":"object"}
```

## Responses

### `201`

Response

#### Headers

##### `Location`

- Type: `string`

- Example: `https://api.github.com/repos/octocat/Hello-World/keys/1`

### `application/json`

- Type: `object`

An SSH key granting access to a single repository.

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

```json
{"description":"An SSH key granting access to a single repository.","properties":{"created_at":{"type":"string"},"id":{"type":"integer"},"key":{"type":"string"},"read_only":{"type":"boolean"},"title":{"type":"string"},"url":{"type":"string"},"verified":{"type":"boolean"}},"required":["id","key","url","title","verified","created_at","read_only"],"title":"Deploy Key","type":"object"}
```

### `422`

Validation failed

### `application/json`

- Type: `object`

Validation Error

```json
{"description":"Validation Error","properties":{"documentation_url":{"type":"string"},"errors":{"items":{"properties":{"code":{"type":"string"},"field":{"type":"string"},"index":{"type":"integer"},"message":{"type":"string"},"resource":{"type":"string"},"value":{"oneOf":[{"nullable":true,"type":"string"},{"nullable":true,"type":"integer"},{"items":{"type":"string"},"nullable":true,"type":"array"}]}},"required":["code"],"type":"object"},"type":"array"},"message":{"type":"string"}},"required":["message","documentation_url"],"title":"Validation Error","type":"object"}
```

## Request examples

### cURL

```shell
curl --request POST \
  --url {protocol}://{hostname}/api/v3/repos/{owner}/{repo}/keys \
  --header 'content-type: application/json' \
  --data '{
  "key": "ssh-rsa AAA...",
  "read_only": true,
  "title": "octocat@octomac"
}'
```
