# 電子メール用の REST API エンドポイント

REST API を使って、認証されたユーザーのメール アドレスを管理します。

## メール管理について

要求 URL に `{username}` パラメーターが含まれていない場合、応答はサインインしているユーザーに対して行われます (要求で[認証情報](/ja/enterprise-server@3.22/rest/authentication/authenticating-to-the-rest-api)を渡す必要があります)。 ユーザーが 2 要素認証を有効にしているかどうかなどの追加の個人情報は、基本認証またはOAuthの`user`スコープを使用した認証時に含まれます。

> \[!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 email addresses for the authenticated user

```
GET /user/emails
```

Lists all of your email addresses, and specifies which one is visible
to the public.
OAuth app tokens and personal access tokens (classic) need the user:email scope to use this endpoint.

### Parameters

#### Headers

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

#### Path and query parameters

* **`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

* **304** - Not modified

* **401** - Requires authentication

* **403** - Forbidden

* **404** - Resource not found

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/user/emails
```

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

Array of `Email`:

* `email`: required, string, format: email
* `primary`: required, boolean
* `verified`: required, boolean
* `visibility`: required, string or null

## Add an email address for the authenticated user

```
POST /user/emails
```

OAuth app tokens and personal access tokens (classic) need the user scope to use this endpoint.

### Parameters

#### Headers

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

#### Body parameters

* **`emails`** (array of strings) (required)
  Adds one or more email addresses to your GitHub account. Must contain at least one email address. Note: Alternatively, you can pass a single email address or an array of emails addresses directly, but we recommend that you pass an object using the emails key.

### HTTP response status codes

* **201** - Created

* **304** - Not modified

* **401** - Requires authentication

* **403** - Forbidden

* **404** - Resource not found

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

### Code examples

#### Example adding multiple email addresses

**Request:**

```curl
curl -L \
  -X POST \
  http(s)://HOSTNAME/api/v3/user/emails \
  -d '{
  "emails": [
    "octocat@github.com",
    "mona@github.com",
    "octocat@octocat.org"
  ]
}'
```

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

Same response schema as [List email addresses for the authenticated user](#list-email-addresses-for-the-authenticated-user).

## Delete an email address for the authenticated user

```
DELETE /user/emails
```

OAuth app tokens and personal access tokens (classic) need the user scope to use this endpoint.

### Parameters

#### Headers

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

#### Body parameters

* **`emails`** (array of strings) (required)
  Email addresses associated with the GitHub user account.

### HTTP response status codes

* **204** - No Content

* **304** - Not modified

* **401** - Requires authentication

* **403** - Forbidden

* **404** - Resource not found

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

### Code examples

#### Example deleting multiple email accounts

**Request:**

```curl
curl -L \
  -X DELETE \
  http(s)://HOSTNAME/api/v3/user/emails \
  -d '{
  "emails": [
    "octocat@github.com",
    "mona@github.com"
  ]
}'
```

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

## List public email addresses for the authenticated user

```
GET /user/public_emails
```

Lists your publicly visible email address, which you can set with the
Set primary email visibility for the authenticated user
endpoint.
OAuth app tokens and personal access tokens (classic) need the user:email scope to use this endpoint.

### Parameters

#### Headers

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

#### Path and query parameters

* **`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

* **304** - Not modified

* **401** - Requires authentication

* **403** - Forbidden

* **404** - Resource not found

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/user/public_emails
```

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

Same response schema as [List email addresses for the authenticated user](#list-email-addresses-for-the-authenticated-user).