# Account # Keys ## Create `client.gpuDroplets.account.keys.create(KeyCreateParamsbody, RequestOptionsoptions?): KeyCreateResponse` **post** `/v2/account/keys` To add a new SSH public key to your DigitalOcean account, send a POST request to `/v2/account/keys`. Set the `name` attribute to the name you wish to use and the `public_key` attribute to the full public key you are adding. ### Parameters - `body: KeyCreateParams` - `name: string` A human-readable display name for this key, used to easily identify the SSH keys when they are displayed. - `public_key: string` The entire public key string that was uploaded. Embedded into the root user's `authorized_keys` file if you include this key during Droplet creation. ### Returns - `KeyCreateResponse` - `ssh_key?: SSHKeys` - `name: string` A human-readable display name for this key, used to easily identify the SSH keys when they are displayed. - `public_key: string` The entire public key string that was uploaded. Embedded into the root user's `authorized_keys` file if you include this key during Droplet creation. - `id?: number` A unique identification number for this key. Can be used to embed a specific SSH key into a Droplet. - `fingerprint?: string` A unique identifier that differentiates this key from other keys using a format that SSH recognizes. The fingerprint is created when the key is added to your account. ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const key = await client.gpuDroplets.account.keys.create({ name: 'My SSH Public Key', public_key: 'ssh-rsa AEXAMPLEaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example', }); console.log(key.ssh_key); ``` ## Retrieve `client.gpuDroplets.account.keys.retrieve(number | stringsshKeyIdentifier, RequestOptionsoptions?): KeyRetrieveResponse` **get** `/v2/account/keys/{ssh_key_identifier}` To get information about a key, send a GET request to `/v2/account/keys/$KEY_ID` or `/v2/account/keys/$KEY_FINGERPRINT`. The response will be a JSON object with the key `ssh_key` and value an ssh_key object which contains the standard ssh_key attributes. ### Parameters - `sshKeyIdentifier: number | string` A unique identification number for this key. Can be used to embed a specific SSH key into a Droplet. - `number` - `string` ### Returns - `KeyRetrieveResponse` - `ssh_key?: SSHKeys` - `name: string` A human-readable display name for this key, used to easily identify the SSH keys when they are displayed. - `public_key: string` The entire public key string that was uploaded. Embedded into the root user's `authorized_keys` file if you include this key during Droplet creation. - `id?: number` A unique identification number for this key. Can be used to embed a specific SSH key into a Droplet. - `fingerprint?: string` A unique identifier that differentiates this key from other keys using a format that SSH recognizes. The fingerprint is created when the key is added to your account. ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const key = await client.gpuDroplets.account.keys.retrieve(512189); console.log(key.ssh_key); ``` ## Update `client.gpuDroplets.account.keys.update(number | stringsshKeyIdentifier, KeyUpdateParamsbody, RequestOptionsoptions?): KeyUpdateResponse` **put** `/v2/account/keys/{ssh_key_identifier}` To update the name of an SSH key, send a PUT request to either `/v2/account/keys/$SSH_KEY_ID` or `/v2/account/keys/$SSH_KEY_FINGERPRINT`. Set the `name` attribute to the new name you want to use. ### Parameters - `sshKeyIdentifier: number | string` A unique identification number for this key. Can be used to embed a specific SSH key into a Droplet. - `number` - `string` - `body: KeyUpdateParams` - `name?: string` A human-readable display name for this key, used to easily identify the SSH keys when they are displayed. ### Returns - `KeyUpdateResponse` - `ssh_key?: SSHKeys` - `name: string` A human-readable display name for this key, used to easily identify the SSH keys when they are displayed. - `public_key: string` The entire public key string that was uploaded. Embedded into the root user's `authorized_keys` file if you include this key during Droplet creation. - `id?: number` A unique identification number for this key. Can be used to embed a specific SSH key into a Droplet. - `fingerprint?: string` A unique identifier that differentiates this key from other keys using a format that SSH recognizes. The fingerprint is created when the key is added to your account. ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const key = await client.gpuDroplets.account.keys.update(512189); console.log(key.ssh_key); ``` ## List `client.gpuDroplets.account.keys.list(KeyListParamsquery?, RequestOptionsoptions?): KeyListResponse` **get** `/v2/account/keys` To list all of the keys in your account, send a GET request to `/v2/account/keys`. The response will be a JSON object with a key set to `ssh_keys`. The value of this will be an array of ssh_key objects, each of which contains the standard ssh_key attributes. ### Parameters - `query: KeyListParams` - `page?: number` Which 'page' of paginated results to return. - `per_page?: number` Number of items returned per page ### Returns - `KeyListResponse` - `meta: MetaProperties` Information about the response itself. - `total?: number` Number of objects returned by the request. - `links?: PageLinks` - `pages?: ForwardLinks | BackwardLinks | unknown` - `ForwardLinks` - `last?: string` URI of the last page of the results. - `next?: string` URI of the next page of the results. - `BackwardLinks` - `first?: string` URI of the first page of the results. - `prev?: string` URI of the previous page of the results. - `unknown` - `ssh_keys?: Array` - `name: string` A human-readable display name for this key, used to easily identify the SSH keys when they are displayed. - `public_key: string` The entire public key string that was uploaded. Embedded into the root user's `authorized_keys` file if you include this key during Droplet creation. - `id?: number` A unique identification number for this key. Can be used to embed a specific SSH key into a Droplet. - `fingerprint?: string` A unique identifier that differentiates this key from other keys using a format that SSH recognizes. The fingerprint is created when the key is added to your account. ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const keys = await client.gpuDroplets.account.keys.list(); console.log(keys.meta); ``` ## Delete `client.gpuDroplets.account.keys.delete(number | stringsshKeyIdentifier, RequestOptionsoptions?): void` **delete** `/v2/account/keys/{ssh_key_identifier}` To destroy a public SSH key that you have in your account, send a DELETE request to `/v2/account/keys/$KEY_ID` or `/v2/account/keys/$KEY_FINGERPRINT`. A 204 status will be returned, indicating that the action was successful and that the response body is empty. ### Parameters - `sshKeyIdentifier: number | string` A unique identification number for this key. Can be used to embed a specific SSH key into a Droplet. - `number` - `string` ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); await client.gpuDroplets.account.keys.delete(512189); ``` ## Domain Types ### SSH Keys - `SSHKeys` - `name: string` A human-readable display name for this key, used to easily identify the SSH keys when they are displayed. - `public_key: string` The entire public key string that was uploaded. Embedded into the root user's `authorized_keys` file if you include this key during Droplet creation. - `id?: number` A unique identification number for this key. Can be used to embed a specific SSH key into a Droplet. - `fingerprint?: string` A unique identifier that differentiates this key from other keys using a format that SSH recognizes. The fingerprint is created when the key is added to your account.