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

# Create instance

> Create an instance.



## OpenAPI

````yaml /openapi/compute-openapi.yaml post /api/v2/instances
openapi: 3.0.3
info:
  title: Compute Service API
  description: >-
    The Compute Service API provides services that allows provisioning and life
    cycle

    management of Compute clusters.
  version: 1.13.0
servers:
  - url: https://compute.nks.europe-west4.nscale.com
    description: Production
security: []
paths:
  /api/v2/instances:
    description: Compute instance services.
    post:
      tags:
        - Instances
      summary: Create instance
      description: Create an instance.
      requestBody:
        $ref: '#/components/requestBodies/instanceCreateRequest'
      responses:
        '201':
          $ref: '#/components/responses/instanceResponse'
        '400':
          $ref: '#/components/responses/badRequestResponse'
        '401':
          $ref: '#/components/responses/unauthorizedResponse'
        '403':
          $ref: '#/components/responses/forbiddenResponse'
        '500':
          $ref: '#/components/responses/internalServerErrorResponse'
      security:
        - oauth2Authentication: []
components:
  requestBodies:
    instanceCreateRequest:
      description: A compute instance creation request.
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/instanceCreate'
          example:
            metadata:
              name: my-host
            spec:
              organizationId: d4600d6e-e965-4b44-a808-84fb2fa36702
              projectId: cae219d7-10e5-4601-8c2c-ee7e066b93ce
              networkId: b059b3e6-9ae5-42b7-94b4-f42fb7a6baee
              flavorId: c7568e2d-f9ab-453d-9a3a-51375f78426b
              imageId: a10e30e8-006a-48e6-a3c7-3c9416891f31
              networking:
                securityGroups:
                  - dd5954af-1d71-4abf-bb16-5729c7163886
  responses:
    instanceResponse:
      description: A compute instance.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/instanceRead'
          example:
            metadata:
              id: c7568e2d-f9ab-453d-9a3a-51375f78426b
              name: my-host
              organizationId: d4600d6e-e965-4b44-a808-84fb2fa36702
              projectId: cae219d7-10e5-4601-8c2c-ee7e066b93ce
              creationTime: '2023-07-31T10:45:45Z'
              provisioningStatus: provisioned
              healthStatus: healthy
            spec:
              flavorId: c7568e2d-f9ab-453d-9a3a-51375f78426b
              imageId: a10e30e8-006a-48e6-a3c7-3c9416891f31
              networking:
                publicIP: true
                securityGroups:
                  - dd5954af-1d71-4abf-bb16-5729c7163886
            status:
              regionId: bb518c64-6856-4d67-a799-314ba668649f
              networkId: b059b3e6-9ae5-42b7-94b4-f42fb7a6baee
              privateIP: 192.168.0.3
              publicIP: 183.45.68.162
              powerState: Running
    badRequestResponse:
      description: |-
        Request body failed schema validation, or the request does not contain
        all the required fields.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error'
          example:
            error: invalid_request
            error_description: request body invalid
    unauthorizedResponse:
      description: Authentication failed or the access token has expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error'
          example:
            error: access_denied
            error_description: authentication failed
    forbiddenResponse:
      description: >-
        Request was denied by authorization, this may be caused by the
        authorization

        token not having the required scope for an API, or the user doesn't have
        the

        necessary privileges on the provider platform.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error'
          example:
            error: forbidden
            error_description: user credentials do not have the required privileges
    internalServerErrorResponse:
      description: >-
        An unexpected or unhandled error occurred. This may be a transient error
        and

        may succeed on a retry.  If this isn't the case, please report it as an
        issue.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error'
          example:
            error: server_error
            error_description: failed to token claim
  schemas:
    instanceCreate:
      description: A compute instance creation request.
      type: object
      required:
        - metadata
        - spec
      properties:
        metadata:
          $ref: '#/components/schemas/resourceMetadata'
        spec:
          $ref: '#/components/schemas/instanceCreateSpec'
    instanceRead:
      description: A compute instance.
      type: object
      required:
        - metadata
        - spec
        - status
      properties:
        metadata:
          $ref: '#/components/schemas/projectScopedResourceReadMetadata'
        spec:
          $ref: '#/components/schemas/instanceSpec'
        status:
          $ref: '#/components/schemas/instanceStatus'
    error:
      description: Generic error message, compatible with oauth2.
      type: object
      required:
        - error
        - error_description
      properties:
        error:
          description: >-
            A terse error string expanding on the HTTP error code. Errors are
            based on the OAuth 2.02 specification, but are expanded with
            proprietary status codes for APIs other than those specified by
            OAuth 2.02.
          type: string
          enum:
            - invalid_request
            - server_error
            - access_denied
            - not_found
            - conflict
            - method_not_allowed
            - unsupported_media_type
            - request_entity_too_large
            - unprocessable_content
            - forbidden
        error_description:
          description: Verbose message describing the error.
          type: string
    resourceMetadata:
      description: Metadata required for all API resource reads and writes.
      required:
        - name
      properties:
        name:
          $ref: '#/components/schemas/kubernetesLabelValue'
        description:
          description: >-
            The resource description, this optionally augments the name with
            more context.
          type: string
        tags:
          $ref: '#/components/schemas/tagList'
    instanceCreateSpec:
      description: A compute instance.
      type: object
      allOf:
        - $ref: '#/components/schemas/instanceSpec'
        - type: object
          required:
            - organizationId
            - projectId
            - networkId
          properties:
            organizationId:
              description: The organization to provision the resource in.
              type: string
            projectId:
              description: The project to provision the resource in.
              type: string
            networkId:
              description: The network ID to attach the compute instance to.
              type: string
    projectScopedResourceReadMetadata:
      description: Metadata required by project scoped resource reads.
      allOf:
        - $ref: '#/components/schemas/organizationScopedResourceReadMetadata'
        - type: object
          required:
            - projectId
          properties:
            projectId:
              description: The project identifier the resource belongs to.
              type: string
    instanceSpec:
      description: A compute instance.
      type: object
      required:
        - flavorId
        - imageId
      properties:
        flavorId:
          description: The flavor CPU/RAM of a compute instance.
          type: string
        imageId:
          description: The image of a compute instance.
          type: string
        networking:
          $ref: '#/components/schemas/instanceNetworking'
        userData:
          description: >-
            Contains base64-encoded configuration information or scripts to use
            upon launch.

            The format of the data is governed by the cloud-init standard, and
            may be a script,

            a MIME multipart archive, etc.
          type: string
          format: byte
    instanceStatus:
      description: Read only status information about a compute instance.
      type: object
      required:
        - regionId
        - networkId
      properties:
        regionId:
          description: The region a security group belongs to.
          type: string
        networkId:
          description: The network a security group belongs to.
          type: string
        powerState:
          $ref: '#/components/schemas/instanceLifecyclePhase'
        privateIP:
          description: The private IP address of the server.
          type: string
        publicIP:
          description: The public IP address of the server.
          type: string
    kubernetesLabelValue:
      description: >-
        A valid Kubernetes label value, typically used for resource names that
        can be

        indexed in the database.
      type: string
      pattern: ^[0-9A-Za-z](?:[0-9A-Za-z-_.]{0,61}[0-9A-Za-z])?$
    tagList:
      description: A list of tags.
      type: array
      items:
        $ref: '#/components/schemas/tag'
    organizationScopedResourceReadMetadata:
      description: Metadata required by organization scoped resource reads.
      allOf:
        - $ref: '#/components/schemas/resourceReadMetadata'
        - type: object
          required:
            - organizationId
          properties:
            organizationId:
              description: The organization identifier the resource belongs to.
              type: string
    instanceNetworking:
      description: A compute instance's network  configuration.
      type: object
      properties:
        securityGroups:
          $ref: '#/components/schemas/securityGroupIDList'
        publicIP:
          description: Whether or not to provision a public IP.
          type: boolean
        allowedSourceAddresses:
          $ref: '#/components/schemas/allowedSourceAddresses'
    instanceLifecyclePhase:
      description: The lifecycle phase of an instance.
      type: string
      enum:
        - Pending
        - Running
        - Stopping
        - Stopped
    tag:
      description: >-
        A tag mapping arbitrary names to values.  These have no special meaning

        for any component are are intended for use by end users to add
        additional

        context to a resource, for example to categorize it.
      type: object
      required:
        - name
        - value
      properties:
        name:
          description: A unique tag name.
          type: string
        value:
          description: The value of the tag.
          type: string
    resourceReadMetadata:
      description: Metadata required by all resource reads.
      allOf:
        - $ref: '#/components/schemas/staticResourceMetadata'
        - type: object
          required:
            - provisioningStatus
            - healthStatus
          properties:
            deletionTime:
              description: The time the resource was deleted.
              type: string
              format: date-time
            provisioningStatus:
              $ref: '#/components/schemas/resourceProvisioningStatus'
            healthStatus:
              $ref: '#/components/schemas/resourceHealthStatus'
    securityGroupIDList:
      description: A list of security group IDs.
      type: array
      items:
        description: A security group ID.
        type: string
    allowedSourceAddresses:
      description: >-
        A list of network prefixes that are allowed to egress from the server.

        By default, only packets from the server's network interface's IP
        address

        are allowed to enter the network.  Use of this option allows the server

        to act as a router without SNAT rules.
      type: array
      items:
        description: An allowed source address prefix.
        type: string
    staticResourceMetadata:
      description: |
        This metadata is for resources that just exist, and don't require
        any provisioning and health status, but benefit from a standardized
        metadata format.
      type: object
      allOf:
        - $ref: '#/components/schemas/resourceMetadata'
        - type: object
          required:
            - id
            - creationTime
          properties:
            id:
              description: The unique resource ID.
              type: string
            creationTime:
              description: The time the resource was created.
              type: string
              format: date-time
            createdBy:
              description: The user who created the resource.
              type: string
            modifiedTime:
              description: The time a resource was updated.
              type: string
              format: date-time
            modifiedBy:
              description: The user who updated the resource.
              type: string
    resourceProvisioningStatus:
      description: The provisioning state of a resource.
      type: string
      enum:
        - unknown
        - provisioning
        - provisioned
        - deprovisioning
        - error
    resourceHealthStatus:
      description: The health state of a resource.
      type: string
      enum:
        - unknown
        - healthy
        - degraded
        - error
  securitySchemes:
    oauth2Authentication:
      description: Operation requires OAuth 2.0 bearer token authentication.
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://identity.nks.europe-west4.nscale.com/oauth2/v2/authorization
          tokenUrl: https://identity.nks.europe-west4.nscale.com/oauth2/v2/token
          scopes: {}

````