> ## Documentation Index
> Fetch the complete documentation index at: https://vms.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Add an SSH key to a sandbox

> Adds a public key to the sandbox. Then `ssh <name>@ssh.vms.dev` with this key opens a shell in the sandbox as `user`, and so does SSH to the IPv6 address of the sandbox. A running sandbox gets the key in a few seconds. A sandbox can have 20 keys. Needs the `sandboxes:ssh` scope.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/sandboxes/{id}/ssh-keys
openapi: 3.1.0
info:
  title: VMS API
  version: 1.0.0
  description: >-
    The public API of a VMS workspace. Each request needs an API key of the
    workspace in the Authorization header.
servers:
  - url: https://vms.dev/api
    description: The VMS API
security:
  - apiKey: []
paths:
  /v1/sandboxes/{id}/ssh-keys:
    post:
      tags:
        - Sandboxes
      summary: Add an SSH key to a sandbox
      description: >-
        Adds a public key to the sandbox. Then `ssh <name>@ssh.vms.dev` with
        this key opens a shell in the sandbox as `user`, and so does SSH to the
        IPv6 address of the sandbox. A running sandbox gets the key in a few
        seconds. A sandbox can have 20 keys. Needs the `sandboxes:ssh` scope.
      operationId: createSshKey
      parameters:
        - in: path
          name: id
          schema:
            type: string
            example: sbx_06d8k3m7q2v9x4b1n5c0e8f2ja
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSshKeyBody'
      responses:
        '201':
          description: The key is added.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SshKey'
        '400':
          description: The request is not valid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: The API key is missing, not correct, revoked, or expired.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: The API key does not have the scope of the endpoint.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: The workspace has no sandbox with this ID.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: The key is already on the sandbox, or the sandbox has 20 keys.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: The API key sent more than 1,200 requests in one minute.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CreateSshKeyBody:
      type: object
      properties:
        publicKey:
          type: string
          minLength: 1
          maxLength: 16384
          description: >-
            An OpenSSH public key: ssh-ed25519, ecdsa-sha2-nistp256,
            ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, or ssh-rsa with 2048 bits
            or more.
          example: >-
            ssh-ed25519
            AAAAC3NzaC1lZDI1NTE5AAAAINiCC4DtKiK4pnatEMwz9fpZks348+f9WnodyRCkr/al
            dev@example.com
        name:
          type: string
          minLength: 1
          maxLength: 100
      required:
        - publicKey
    SshKey:
      type: object
      properties:
        id:
          type: string
          example: ssk_06d8k3m7q2v9x4b1n5c0e8f2ja
        sandboxId:
          type: string
          example: sbx_06d8k3m7q2v9x4b1n5c0e8f2ja
        name:
          description: The name of the key. The default is the key comment.
          example: dev@example.com
          type:
            - string
            - 'null'
        publicKey:
          type: string
          description: The key type and the key, without the comment.
          example: >-
            ssh-ed25519
            AAAAC3NzaC1lZDI1NTE5AAAAINiCC4DtKiK4pnatEMwz9fpZks348+f9WnodyRCkr/al
        fingerprint:
          type: string
          description: The SHA-256 fingerprint, as ssh-keygen -l shows it.
          example: SHA256:DbPhl9dNAPM0TB3+SLh/OdwIJ9Rtl3hGJU6s/NJyjOg
        createdAt:
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
      required:
        - id
        - sandboxId
        - name
        - publicKey
        - fingerprint
        - createdAt
      additionalProperties: false
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: no_capacity
            message:
              type: string
            requestId:
              type:
                - string
                - 'null'
            retryAfterSeconds:
              type: integer
              minimum: 0
              maximum: 9007199254740991
            sandboxId:
              description: The sandbox that the error is about.
              type: string
          required:
            - code
            - message
            - requestId
          additionalProperties: false
      required:
        - error
      additionalProperties: false
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: An API key that starts with vms_. Make one in Settings > API keys.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.