Skip to main content
Die REST-API verfügt jetzt über eine Versionskontrolle. Weitere Informationen findest du unter Informationen zur API-Versionsverwaltung.

REST-API-Endpunkte für E-Mails

Verwende die REST-API, um die E-Mail-Adressen authentifizierter Benutzer*innen zu verwalten.

Informationen zur E-Mail-Verwaltung

Wenn eine Anforderungs-URL keinen {username}-Parameter enthält, gilt die Antwort für dendie angemeldeten Benutzerin (und Sie müssen Authentifizierungsinformationen mit Ihrer Anforderung übergeben). Zusätzliche private Informationen, z. B. ob eine Benutzer*in die Zwei-Faktor-Authentifizierung aktiviert hat, wird bei der Authentifizierung über OAuth mit dem user-Bereich eingeschlossen.

Set primary email visibility for the authenticated user

Sets the visibility for your primary email addresses.

Differenzierte Zugriffstoken für "Set primary email visibility for the authenticated user"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • emails:write

Parameter für „Set primary email visibility for the authenticated user“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Textparameter
Name, type, BESCHREIBUNG
visibility string Erforderlich

Denotes whether an email is publicly visible.

Kann eine der Folgenden sein: public, private

HTTP-Antwortstatuscodes für „Set primary email visibility for the authenticated user“

StatuscodeBESCHREIBUNG
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Codebeispiele für „Set primary email visibility for the authenticated user“

Beispiel für eine Anfrage

patch/user/email/visibility
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/email/visibility \ -d '{"visibility":"private"}'

Response

Status: 200
[ { "email": "octocat@github.com", "primary": true, "verified": true, "visibility": "private" } ]

List email addresses for the authenticated user

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.

Differenzierte Zugriffstoken für "List email addresses for the authenticated user"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • emails:read

Parameter für „List email addresses for the authenticated user“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Abfrageparameter
Name, type, BESCHREIBUNG
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Standard: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Standard: 1

HTTP-Antwortstatuscodes für „List email addresses for the authenticated user“

StatuscodeBESCHREIBUNG
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

Codebeispiele für „List email addresses for the authenticated user“

Beispiel für eine Anfrage

get/user/emails
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/emails

Response

Status: 200
[ { "email": "octocat@github.com", "verified": true, "primary": true, "visibility": "public" } ]

Add an email address for the authenticated user

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

Differenzierte Zugriffstoken für "Add an email address for the authenticated user"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • emails:write

Parameter für „Add an email address for the authenticated user“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Textparameter
Name, type, BESCHREIBUNG
emails array of strings Erforderlich

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-Antwortstatuscodes für „Add an email address for the authenticated user“

StatuscodeBESCHREIBUNG
201

Created

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Codebeispiele für „Add an email address for the authenticated user“

Beispiel für eine Anfrage

post/user/emails
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/emails \ -d '{"emails":["octocat@github.com","mona@github.com","octocat@octocat.org"]}'

Response

Status: 201
[ { "email": "octocat@octocat.org", "primary": false, "verified": false, "visibility": "public" }, { "email": "octocat@github.com", "primary": false, "verified": false, "visibility": null }, { "email": "mona@github.com", "primary": false, "verified": false, "visibility": null } ]

Delete an email address for the authenticated user

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

Differenzierte Zugriffstoken für "Delete an email address for the authenticated user"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • emails:write

Parameter für „Delete an email address for the authenticated user“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Textparameter
Name, type, BESCHREIBUNG
emails array of strings Erforderlich

Email addresses associated with the GitHub user account.

HTTP-Antwortstatuscodes für „Delete an email address for the authenticated user“

StatuscodeBESCHREIBUNG
204

No Content

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Codebeispiele für „Delete an email address for the authenticated user“

Beispiel für eine Anfrage

delete/user/emails
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/emails \ -d '{"emails":["octocat@github.com","mona@github.com"]}'

Response

Status: 204

List public email addresses for the authenticated user

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.

Differenzierte Zugriffstoken für "List public email addresses for the authenticated user"

Dieser Endpunkt funktioniert mit den folgenden Tokentypen.:

Das Token muss einen der folgenden Berechtigungssätze aufweisen.:

  • emails:read

Dieser Endpunkt kann ohne Authentifizierung oder die zuvor erwähnten Berechtigungen verwendet werden, wenn nur öffentliche Ressourcen angefordert werden.

Parameter für „List public email addresses for the authenticated user“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Abfrageparameter
Name, type, BESCHREIBUNG
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Standard: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Standard: 1

HTTP-Antwortstatuscodes für „List public email addresses for the authenticated user“

StatuscodeBESCHREIBUNG
200

OK

304

Not modified

401

Requires authentication

403

Forbidden

404

Resource not found

Codebeispiele für „List public email addresses for the authenticated user“

Beispiel für eine Anfrage

get/user/public_emails
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/public_emails

Response

Status: 200
[ { "email": "octocat@github.com", "verified": true, "primary": true, "visibility": "public" } ]