{"meta":{"title":"REST-API-Endpunkte für Git-SSH-Schlüssel","intro":"Verwende die REST-API, um die Git-SSH-Schlüssel authentifizierter Benutzer*innen zu verwalten.","product":"REST-API","breadcrumbs":[{"href":"/de/rest","title":"REST-API"},{"href":"/de/rest/users","title":"Benutzer"},{"href":"/de/rest/users/keys","title":"Git-SSH-Schlüssel"}],"documentType":"article"},"body":"# REST-API-Endpunkte für Git-SSH-Schlüssel\n\nVerwende die REST-API, um die Git-SSH-Schlüssel authentifizierter Benutzer\\*innen zu verwalten.\n\n## Informationen zum Verwalten von Git-SSH-Schlüsseln\n\nWenn eine Anforderungs-URL keinen `{username}`-Parameter enthält, gilt die Antwort für den*die angemeldete*n Benutzer\\*in (und Sie müssen [Authentifizierungsinformationen](/de/rest/authentication/authenticating-to-the-rest-api) mit Ihrer Anforderung übergeben). Zusätzliche private Informationen, z. B. ob ein Benutzer die zweistufige Authentifizierung aktiviert hat, werden bei der Authentifizierung über OAuth mit dem `user` Zugriffsbereich eingeschlossen.\n\n> \\[!NOTE]\n> 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.\n\n## List public SSH keys for the authenticated user\n\n```\nGET /user/keys\n```\n\nLists the public SSH keys for the authenticated user's GitHub account.\nOAuth app tokens and personal access tokens (classic) need the read:public\\_key scope to use this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n* **`page`** (integer)\n  The page number of the results to fetch. For more information, see \"Using pagination in the REST API.\"\n  Default: `1`\n\n### HTTP response status codes\n\n* **200** - OK\n\n* **304** - Not modified\n\n* **401** - Requires authentication\n\n* **403** - Forbidden\n\n* **404** - Resource not found\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/user/keys\n```\n\n**Response schema (Status: 200):**\n\nArray of `Key`:\n\n* `key`: required, string\n* `id`: required, integer, format: int64\n* `url`: required, string\n* `title`: required, string\n* `created_at`: required, string, format: date-time\n* `verified`: required, boolean\n* `read_only`: required, boolean\n* `last_used`: string or null, format: date-time\n\n## Create a public SSH key for the authenticated user\n\n```\nPOST /user/keys\n```\n\nAdds a public SSH key to the authenticated user's GitHub account.\nOAuth app tokens and personal access tokens (classic) need the write:public\\_key scope to use this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Body parameters\n\n* **`title`** (string)\n  A descriptive name for the new key.\n\n* **`key`** (string) (required)\n  The public SSH key to add to your GitHub account.\n\n### HTTP response status codes\n\n* **201** - Created\n\n* **304** - Not modified\n\n* **401** - Requires authentication\n\n* **403** - Forbidden\n\n* **404** - Resource not found\n\n* **422** - Validation failed, or the endpoint has been spammed.\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  https://api.github.com/user/keys \\\n  -d '{\n  \"title\": \"ssh-rsa AAAAB3NzaC1yc2EAAA\",\n  \"key\": \"2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234\"\n}'\n```\n\n**Response schema (Status: 201):**\n\n* `key`: required, string\n* `id`: required, integer, format: int64\n* `url`: required, string\n* `title`: required, string\n* `created_at`: required, string, format: date-time\n* `verified`: required, boolean\n* `read_only`: required, boolean\n* `last_used`: string or null, format: date-time\n\n## Get a public SSH key for the authenticated user\n\n```\nGET /user/keys/{key_id}\n```\n\nView extended details for a single public SSH key.\nOAuth app tokens and personal access tokens (classic) need the read:public\\_key scope to use this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`key_id`** (integer) (required)\n  The unique identifier of the key.\n\n### HTTP response status codes\n\n* **200** - OK\n\n* **304** - Not modified\n\n* **401** - Requires authentication\n\n* **403** - Forbidden\n\n* **404** - Resource not found\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/user/keys/KEY_ID\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Create a public SSH key for the authenticated user](#create-a-public-ssh-key-for-the-authenticated-user).\n\n## Delete a public SSH key for the authenticated user\n\n```\nDELETE /user/keys/{key_id}\n```\n\nRemoves a public SSH key from the authenticated user's GitHub account.\nOAuth app tokens and personal access tokens (classic) need the admin:public\\_key scope to use this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`key_id`** (integer) (required)\n  The unique identifier of the key.\n\n### HTTP response status codes\n\n* **204** - No Content\n\n* **304** - Not modified\n\n* **401** - Requires authentication\n\n* **403** - Forbidden\n\n* **404** - Resource not found\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  https://api.github.com/user/keys/KEY_ID\n```\n\n**Response schema (Status: 204):**\n\n## List public keys for a user\n\n```\nGET /users/{username}/keys\n```\n\nLists the verified public SSH keys for a user. This is accessible by anyone.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n* **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n* **`page`** (integer)\n  The page number of the results to fetch. For more information, see \"Using pagination in the REST API.\"\n  Default: `1`\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/users/USERNAME/keys\n```\n\n**Response schema (Status: 200):**\n\nArray of `Key Simple`:\n\n* `id`: required, integer\n* `key`: required, string\n* `created_at`: string, format: date-time\n* `last_used`: string or null, format: date-time"}