# 배포 키에 대한 REST API 엔드포인트

REST API를 사용하여 배포 키 만들고 관리합니다.

## 배포 키 정보

배포 키를 사용하여 서버에 대한 GitHub Enterprise Server 인스턴스 리포지토리에서 프로젝트를 시작할 수 있습니다. 이것은 단일 리포지토리에 대한 액세스 권한을 부여하는 SSH 키입니다. GitHub는 키의 퍼블릭 부분을 개인 계정 대신 리포지토리에 직접 연결하고 키의 프라이빗 부분은 서버에 남아 있습니다. 자세한 내용은 [배포 작업](/ko/enterprise-server@3.19/rest/guides/delivering-deployments)을(를) 참조하세요.

배포 키는 다음 API 엔드포인트를 사용하거나 웹 인터페이스를 GitHub 사용하여 설정할 수 있습니다. 웹 인터페이스에서 배포 키를 설정하는 방법을 알아보려면 [배포 키 관리](/ko/enterprise-server@3.19/authentication/connecting-to-github-with-ssh/managing-deploy-keys)을(를) 참조하세요.

조직 또는 엔터프라이즈 소유자가 사용을 제한하는 정책을 설정한 경우 배포 키 만들 수 없습니다. 또한 조직 또는 엔터프라이즈 수준에서 이 정책을 사용하도록 설정하면 기존 배포 키 사용하지 않도록 설정할 수 있습니다. 자세한 내용은 [엔터프라이즈에서 리포지토리 관리 정책 적용](/ko/enterprise-server@3.19/admin/policies/enforcing-policies-for-your-enterprise/enforcing-repository-management-policies-in-your-enterprise#enforcing-a-policy-for-deploy-keys) 및 [조직의 배포 키 제한](/ko/enterprise-server@3.19/organizations/managing-organization-settings/restricting-deploy-keys-in-your-organization)을(를) 참조하세요.

배포 키가 다른 활동에 의해 삭제되는 경우 몇 가지는 다음과 같습니다.

* 배포 키를 사용하여 personal access token만든 경우 삭제하면 personal access token 배포 키도 삭제됩니다. 다시 생성하면 personal access token 배포 키가 삭제되지 않습니다.
* 토큰을 사용하여 배포 키를 만든 OAuth app 경우 토큰을 해지하면 배포 키도 삭제됩니다.

반대로 이러한 활동은 수행해도 배포 키가 삭제되지 않습니다.

* 사용자 액세스 토큰을 사용하여 GitHub App 배포 키를 만든 경우 토큰을 해지해도 배포 키가 삭제되지 않습니다.
* 설치 액세스 토큰을 사용하여 GitHub App 배포 키를 만든 경우 앱을 제거하거나 삭제해도 배포 키가 삭제되지 않습니다.
* 배포 키가 personal access token 상태에서 생성된 경우, personal access token을 다시 생성하더라도 배포 키가 삭제되지 않습니다.

> \[!NOTE]
> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2022-11-28`. Curl examples below omit these standard headers for brevity.

## List deploy keys

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

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`per_page`** (integer)
  The number of results per page (max 100). For more information, see "Using pagination in the REST API."
  Default: `30`

* **`page`** (integer)
  The page number of the results to fetch. For more information, see "Using pagination in the REST API."
  Default: `1`

### HTTP response status codes

* **200** - OK

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys
```

**Response schema (Status: 200):**

Array of `Deploy Key`:

* `id`: required, integer
* `key`: required, string
* `url`: required, string
* `title`: required, string
* `verified`: required, boolean
* `created_at`: required, string
* `read_only`: required, boolean
* `added_by`: string or null
* `last_used`: string or null, format: date-time
* `enabled`: boolean

## Create a deploy key

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

You can create a read-only deploy key.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

#### Body parameters

* **`title`** (string)
  A name for the key.

* **`key`** (string) (required)
  The contents of the key.

* **`read_only`** (boolean)
  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."

### HTTP response status codes

* **201** - Created

* **422** - Validation failed, or the endpoint has been spammed.

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X POST \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys \
  -d '{
  "title": "octocat@octomac",
  "key": "ssh-rsa AAA...",
  "read_only": true
}'
```

**Response schema (Status: 201):**

* `id`: required, integer
* `key`: required, string
* `url`: required, string
* `title`: required, string
* `verified`: required, boolean
* `created_at`: required, string
* `read_only`: required, boolean
* `added_by`: string or null
* `last_used`: string or null, format: date-time
* `enabled`: boolean

## Get a deploy key

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

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`key_id`** (integer) (required)
  The unique identifier of the key.

### HTTP response status codes

* **200** - OK

* **404** - Resource not found

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_ID
```

**Response schema (Status: 200):**

Same response schema as [Create a deploy key](#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

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`key_id`** (integer) (required)
  The unique identifier of the key.

### HTTP response status codes

* **204** - No Content

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X DELETE \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_ID
```

**Response schema (Status: 204):**