# SSH Keys

## Get Ssh Keys

> Get all SSH keys for a project

```json
{"openapi":"3.1.0","info":{"title":"Mithril","version":"1.0.0"},"servers":[{"url":"https://api.mithril.ai"}],"security":[{"MithrilAPIKey":[]}],"components":{"securitySchemes":{"MithrilAPIKey":{"type":"http","scheme":"bearer","bearerFormat":"fkey_<key>"}},"schemas":{"NewSshKeyModel":{"properties":{"fid":{"type":"string","title":"Fid"},"name":{"type":"string","title":"Name"},"project":{"type":"string","title":"Project"},"public_key":{"type":"string","title":"Public Key"},"created_at":{"type":"string","format":"datetime","title":"Created At"},"required":{"type":"boolean","title":"Required"}},"type":"object","required":["fid","name","project","public_key","created_at","required"],"title":"NewSshKeyModel"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"oneOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v2/ssh-keys":{"get":{"tags":["SSH Keys"],"summary":"Get Ssh Keys","description":"Get all SSH keys for a project","operationId":"get_ssh_keys_v2_ssh_keys_get","parameters":[{"name":"project","in":"query","required":true,"schema":{"type":"string","title":"Project"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/NewSshKeyModel"},"title":"Response Get Ssh Keys V2 Ssh Keys Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Create Ssh Key

> Create a new SSH key. If public\_key is not provided, this endpoint will generate\
> a new RSA key pair and return both the private and public keys.

```json
{"openapi":"3.1.0","info":{"title":"Mithril","version":"1.0.0"},"servers":[{"url":"https://api.mithril.ai"}],"security":[{"MithrilAPIKey":[]}],"components":{"securitySchemes":{"MithrilAPIKey":{"type":"http","scheme":"bearer","bearerFormat":"fkey_<key>"}},"schemas":{"CreateSshKeyRequest":{"properties":{"project":{"type":"string","title":"Project"},"name":{"type":"string","title":"Name"},"public_key":{"type":"string","nullable":true},"required":{"type":"boolean","title":"Required","default":false}},"type":"object","required":["project","name"],"title":"CreateSshKeyRequest"},"CreatedSshKeyModel":{"properties":{"fid":{"type":"string","title":"Fid"},"name":{"type":"string","title":"Name"},"project":{"type":"string","title":"Project"},"public_key":{"type":"string","title":"Public Key"},"created_at":{"type":"string","format":"datetime","title":"Created At"},"required":{"type":"boolean","title":"Required"},"private_key":{"type":"string","nullable":true}},"type":"object","required":["fid","name","project","public_key","created_at","required"],"title":"CreatedSshKeyModel"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"oneOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v2/ssh-keys":{"post":{"tags":["SSH Keys"],"summary":"Create Ssh Key","description":"Create a new SSH key. If public_key is not provided, this endpoint will generate\na new RSA key pair and return both the private and public keys.","operationId":"create_ssh_key_v2_ssh_keys_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSshKeyRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatedSshKeyModel"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Delete Ssh Key

> Delete an SSH key. Note that SSH keys used in active bids/reservations cannot\
> be deleted.

```json
{"openapi":"3.1.0","info":{"title":"Mithril","version":"1.0.0"},"servers":[{"url":"https://api.mithril.ai"}],"security":[{"MithrilAPIKey":[]}],"components":{"securitySchemes":{"MithrilAPIKey":{"type":"http","scheme":"bearer","bearerFormat":"fkey_<key>"}},"schemas":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"oneOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v2/ssh-keys/{ssh_key_fid}":{"delete":{"tags":["SSH Keys"],"summary":"Delete Ssh Key","description":"Delete an SSH key. Note that SSH keys used in active bids/reservations cannot\nbe deleted.","operationId":"delete_ssh_key_v2_ssh_keys__ssh_key_fid__delete","parameters":[{"name":"ssh_key_fid","in":"path","required":true,"schema":{"type":"string","title":"Ssh Key Fid"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Update Ssh Key

> Update an SSH key to set it as required. Only admins can set a key as required.

```json
{"openapi":"3.1.0","info":{"title":"Mithril","version":"1.0.0"},"servers":[{"url":"https://api.mithril.ai"}],"security":[{"MithrilAPIKey":[]}],"components":{"securitySchemes":{"MithrilAPIKey":{"type":"http","scheme":"bearer","bearerFormat":"fkey_<key>"}},"schemas":{"UpdateSshKeyRequest":{"properties":{"required":{"type":"boolean","title":"Required"}},"type":"object","required":["required"],"title":"UpdateSshKeyRequest"},"NewSshKeyModel":{"properties":{"fid":{"type":"string","title":"Fid"},"name":{"type":"string","title":"Name"},"project":{"type":"string","title":"Project"},"public_key":{"type":"string","title":"Public Key"},"created_at":{"type":"string","format":"datetime","title":"Created At"},"required":{"type":"boolean","title":"Required"}},"type":"object","required":["fid","name","project","public_key","created_at","required"],"title":"NewSshKeyModel"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"oneOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v2/ssh-keys/{ssh_key_fid}":{"patch":{"tags":["SSH Keys"],"summary":"Update Ssh Key","description":"Update an SSH key to set it as required. Only admins can set a key as required.","operationId":"update_ssh_key_v2_ssh_keys__ssh_key_fid__patch","parameters":[{"name":"ssh_key_fid","in":"path","required":true,"schema":{"type":"string","title":"Ssh Key Fid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateSshKeyRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewSshKeyModel"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mithril.ai/compute-api/compute-api-reference/ssh-keys.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
