openapi: 3.0.0
info:
  title: Massed Compute Inventory API
  description: >
    **API documentation for our Inventory API. Power your marketplace or
    application with our comptue resourcces.**


    *If you are a marketplace looking to leverage our GPU inventory please
    contact us at techadmin@massedcompute.com*

    # Authentication

    Authentication of every endpoint provided requres a API token. We leverage
    Bearer token authentication on our endpoints.


    | Header | Value |

    | --- | --- |

    | Authorization | Bearer {{api_token}} |


    If you would like to use the API, please contact us at
    techadmin@massedcompute.com to request a token.
  version: 1.0.0
servers:
  - url: https://api.massedcompute.com
paths:
  /api/vm_marketplace/instance-types:
    get:
      summary: Retrieve list of all compute products.
      description: An instance type is a configuration of CPU, memory, and storage.
      tags:
        - Instances
      responses:
        '200':
          description: A list of available instance types
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AvailableInstanceTypesV1'
  /api/vm_marketplace/instances:
    get:
      summary: Retrieve list of all running instances.
      description: An instance is a virtual machine that is currently running.
      tags:
        - Instances
      responses:
        '200':
          description: A list of all running instances
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RetrieveAllRunningInstancesV1'
  /api/vm_marketplace/instances/{uuid}:
    get:
      summary: Retrieve single running instances.
      description: An instance is a virtual machine.
      tags:
        - Instances
      responses:
        '200':
          description: A list of all running instances
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RetrieveInstanceByUuidV1'
  /api/vm_marketplace/instance-operations/launch:
    post:
      summary: Deploy new instances.
      tags:
        - Instances
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - instance_type_name
                - region_name
                - ssh_key_names
                - quantity
              properties:
                instance_type_name:
                  type: string
                  description: The name of the instance you want to deploy
                region_name:
                  type: string
                  description: Set value equal to 'any'
                ssh_key_names:
                  type: array
                  items:
                    type: string
                  description: >-
                    The SSH key you want to use to connect to the instance. Can
                    be a blank array.
                file_system_names:
                  type: array
                  items:
                    type: string
                  description: >-
                    The file system you want to use to connect to the instance.
                    Can be a blank array.
                quantity:
                  type: integer
                  description: The number of instances you want to deploy.
                name:
                  type: string
                  description: The name of the instance you want to deploy.
                os_image_name:
                  type: string
                  description: The name of the OS image you want to deploy.
                env_vars:
                  type: object
                  description: >
                    Optional environment variables to pass to the VM. Keys are
                    variable

                    names, values are strings. Written to `~/<vm_username>/.env`
                    on the

                    VM at every boot. Stored encrypted at rest server-side; sent
                    over

                    TLS in transit; plaintext on the VM.


                    Validation:
                      - Keys must match `^[A-Za-z_][A-Za-z0-9_]{0,63}$`.
                      - Reserved keys (rejected): PATH, HOME, USER, SHELL, PWD, OLDPWD,
                        IFS, PS1, PS2, TERM, LANG, LC_ALL.
                      - Reserved prefixes (rejected): LD_, MC_.
                      - Max 64 entries, max 4 KiB per value, max 16 KiB total.
                      - Values must not contain NUL bytes.

                    Manual edits to the file on the VM do not survive reboot —
                    the

                    API is the source of truth. To change values, launch a new
                    VM.
                  additionalProperties:
                    type: string
                  example:
                    HF_TOKEN: hf_...
                    OPENAI_API_KEY: sk-...
                    MY_APP_FLAG: '1'
      responses:
        '200':
          description: Success deploying instance
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LaunchInstanceV1'
  /api/vm_marketplace/instance-operations/terminate:
    post:
      summary: Terminate an instances.
      description: >-
        Termination completely removes the instance from the system and destroys
        all data. You will no longer be billed
      tags:
        - Instances
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                instance_ids:
                  type: array
                  items:
                    type: string
                  description: The ID or IDs of instances to restart
              required:
                - instance_ids
        example:
          instance_ids:
            - string1
            - string2
      responses:
        '202':
          description: Success restarting instance
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TerminateInstanceV1'
  /api/vm_marketplace/instance-operations/restart:
    post:
      summary: Restart an instance.
      description: >-
        Restarting an instance can only be done to `Stopped` instances. This
        takes the instance from a stopped to active state.
      tags:
        - Instances
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                instance_uuids:
                  type: array
                  items:
                    type: string
                  description: The ID or IDs of instances to restart
              required:
                - instance_uuids
        example:
          instance_uuids:
            - string1
            - string2
      responses:
        '202':
          description: Success restarting instance
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestartInstanceV1'
  /api/vm_marketplace/instance-operations/stop:
    post:
      summary: Stop an instance.
      description: >-
        Stopping an instance will halt it without destroying any data. You will
        still be billed.
      tags:
        - Instances
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                instance_uuids:
                  type: array
                  items:
                    type: string
                  description: The ID or IDs of instances to restart
              required:
                - instance_uuids
        example:
          instance_uuids:
            - string1
            - string2
      responses:
        '202':
          description: Success restarting instance
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StoppedInstanceV1'
  /api/vm_marketplace/ssh-keys:
    get:
      summary: Retrieve list of all SSH keys.
      description: An SSH key is a secure way to connect to an instance.
      tags:
        - SSH Keys
      responses:
        '200':
          description: A list of all SSH keys
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RetrieveSshKeysV1'
    post:
      summary: Create a new SSH key.
      description: An SSH key is a secure way to connect to an instance.
      tags:
        - SSH Keys
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - public_key
              properties:
                name:
                  type: string
                  description: The name of the SSH key
                public_key:
                  type: string
                  description: The public key of the SSH key
      responses:
        '200':
          description: Success creating SSH key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddSshKeysV1'
  /api/vm_marketplace/ssh-keys/{uuid}:
    delete:
      summary: Delete an SSH key.
      description: An SSH key is a secure way to connect to an instance.
      tags:
        - SSH Keys
      responses:
        '200':
          description: Success deleting SSH key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeleteSshKeyV1'
components:
  schemas:
    AvailableInstanceTypesV1:
      type: object
      properties:
        data:
          type: object
          properties:
            gpu_type:
              type: object
              description: >-
                A unique compute product that can be deployed. Ex. gpu_1x_a6000,
                gpu_2x_a6000, etc.
              properties:
                instance_type:
                  type: object
                  properties:
                    name:
                      type: string
                      example: gpu_1x_a6000
                    description:
                      type: string
                      example: 1x RTX A6000
                    price_cents_per_hour:
                      type: integer
                      example: 66
                    specs:
                      type: object
                      properties:
                        vcpu_count:
                          type: integer
                          example: 6
                        memory_gib:
                          type: integer
                          example: 48
                        storage_gb:
                          type: integer
                          example: 256
                regions_with_capacity_available:
                  type: array
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                        example: us-central-1
                      description:
                        type: string
                        example: Wichita, KS
                capacity_available:
                  type: integer
                  example: 0
    RetrieveAllRunningInstancesV1:
      type: object
      properties:
        data:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                example: 8b52a46b-a892-4fde-925c-6d13226908f7
              name:
                type: string
                example: Instance Test
              ip:
                type: string
                example: 1.1.1.1
              status:
                type: string
                enum:
                  - terminated
                  - active
                  - stopped
                  - booting
                example: active
              ssh_key_names:
                type: array
                items:
                  type: string
                example: []
              file_system_names:
                type: array
                items:
                  type: string
                example: []
              region:
                type: object
                properties:
                  name:
                    type: string
                    example: us-central-1
                  description:
                    type: string
                    example: Wichita, KS
              instance_type:
                type: object
                properties:
                  name:
                    type: string
                    example: gpu_1x_l40
                  description:
                    type: string
                    example: 1x L40
                  price_cents_per_hour:
                    type: integer
                    example: 99
                  vcpu:
                    type: integer
                    example: 26
                  ram:
                    type: integer
                    example: 128
                  storage:
                    type: integer
                    example: 625
              jupyter_token:
                type: string
                example: 8b52a46b-a892-4fde-925c-6d13226908f7
              jupyter_url:
                type: string
                example: https://jupyter.8b52a46b-a892-4fde-925c-6d13226908f7.com
    RetrieveInstanceByUuidV1:
      type: object
      properties:
        data:
          type: object
          properties:
            id:
              type: string
              example: 8b52a46b-a892-4fde-925c-6d13226908f7
            name:
              type: string
              example: Instance Test
            ip:
              type: string
              example: 1.1.1.1
            status:
              type: string
              enum:
                - terminated
                - active
                - stopped
                - booting
              example: active
            ssh_key_names:
              type: array
              items:
                type: string
              example: []
            file_system_names:
              type: array
              items:
                type: string
              example: []
            region:
              type: object
              properties:
                name:
                  type: string
                  example: us-central-1
                description:
                  type: string
                  example: Wichita, KS
            instance_type:
              type: object
              properties:
                name:
                  type: string
                  example: gpu_1x_a6000
                description:
                  type: string
                  example: 1x RTX A6000
                price_cents_per_hour:
                  type: integer
                  example: 66
                specs:
                  type: object
                  properties:
                    vcpu_count:
                      type: integer
                      example: 6
                    memory_gib:
                      type: integer
                      example: 48
                    storage_gb:
                      type: integer
                      example: 256
            jupyter_token:
              type: string
              example: ''
            jupyter_url:
              type: string
              example: ''
    LaunchInstanceV1:
      type: object
      properties:
        data:
          type: object
          properties:
            uuid:
              type: string
              example: 8b52a46b-a892-4fde-925c-6d13226908f7
    TerminateInstanceV1:
      type: object
      properties:
        data:
          type: object
          properties:
            terminated_instances:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    example: 8b52a46b-a892-4fde-925c-6d13226908f7
                  name:
                    type: string
                    example: Instance Test
                  ip:
                    type: string
                    example: 1.1.1.1
                  status:
                    type: string
                    enum:
                      - terminated
                      - active
                      - stopping
                      - booting
                    example: terminated
                  ssh_key_names:
                    type: array
                    items:
                      type: string
                    example: []
                  file_system_names:
                    type: array
                    items:
                      type: string
                    example: []
                  region:
                    type: object
                    properties:
                      name:
                        type: string
                        example: us-central-1
                      description:
                        type: string
                        example: Wichita, KS
                  instance_type:
                    type: object
                    properties:
                      name:
                        type: string
                        example: gpu_1x_a6000
                      description:
                        type: string
                        example: 1x RTX A6000
                      price_cents_per_hour:
                        type: integer
                        example: 66
                      specs:
                        type: object
                        properties:
                          vcpu_count:
                            type: integer
                            example: 6
                          memory_gib:
                            type: integer
                            example: 48
                          storage_gb:
                            type: integer
                            example: 256
                  jupyter_token:
                    type: string
                    example: ''
                  jupyter_url:
                    type: string
                    example: ''
    RestartInstanceV1:
      type: object
      properties:
        data:
          type: object
          properties:
            restarted_instances:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    example: 8b52a46b-a892-4fde-925c-6d13226908f7
                  name:
                    type: string
                    example: Instance Test
                  ip:
                    type: string
                    example: 1.1.1.1
                  status:
                    type: string
                    enum:
                      - terminated
                      - active
                      - stopping
                      - booting
                    example: booting
                  ssh_key_names:
                    type: array
                    items:
                      type: string
                    example: []
                  file_system_names:
                    type: array
                    items:
                      type: string
                    example: []
                  region:
                    type: object
                    properties:
                      name:
                        type: string
                        example: us-central-1
                      description:
                        type: string
                        example: Wichita, KS
                  instance_type:
                    type: object
                    properties:
                      name:
                        type: string
                        example: gpu_1x_a6000
                      description:
                        type: string
                        example: 1x RTX A6000
                      price_cents_per_hour:
                        type: integer
                        example: 66
                      specs:
                        type: object
                        properties:
                          vcpu_count:
                            type: integer
                            example: 6
                          memory_gib:
                            type: integer
                            example: 48
                          storage_gb:
                            type: integer
                            example: 256
                  jupyter_token:
                    type: string
                    example: ''
                  jupyter_url:
                    type: string
                    example: ''
    StoppedInstanceV1:
      type: object
      properties:
        data:
          type: object
          properties:
            stopped_instances:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    example: 8b52a46b-a892-4fde-925c-6d13226908f7
                  name:
                    type: string
                    example: Instance Test
                  ip:
                    type: string
                    example: 1.1.1.1
                  status:
                    type: string
                    enum:
                      - terminated
                      - active
                      - stopping
                      - booting
                    example: stopping
                  ssh_key_names:
                    type: array
                    items:
                      type: string
                    example: []
                  file_system_names:
                    type: array
                    items:
                      type: string
                    example: []
                  region:
                    type: object
                    properties:
                      name:
                        type: string
                        example: us-central-1
                      description:
                        type: string
                        example: Wichita, KS
                  instance_type:
                    type: object
                    properties:
                      name:
                        type: string
                        example: gpu_1x_a6000
                      description:
                        type: string
                        example: 1x RTX A6000
                      price_cents_per_hour:
                        type: integer
                        example: 66
                      specs:
                        type: object
                        properties:
                          vcpu_count:
                            type: integer
                            example: 6
                          memory_gib:
                            type: integer
                            example: 48
                          storage_gb:
                            type: integer
                            example: 256
                  jupyter_token:
                    type: string
                    example: ''
                  jupyter_url:
                    type: string
                    example: ''
    RetrieveSshKeysV1:
      type: object
      properties:
        data:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                example: 8b52a46b-a892-4fde-925c-6d13226908f7
              name:
                type: string
                example: Instance Test
              public_key:
                type: string
                example: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDfZ
    AddSshKeysV1:
      type: object
      properties:
        data:
          type: object
          properties:
            id:
              type: string
              example: 8b52a46b-a892-4fde-925c-6d13226908f7
            name:
              type: string
              example: Add SSH Key Test
    DeleteSshKeyV1:
      type: object
      properties:
        data:
          type: object
