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

# Create Order

> Create a new order. Provide either a customerId or a customer object to auto-create.



## OpenAPI

````yaml POST /orders
openapi: 3.1.0
info:
  title: bitbybit Open API
  description: >-
    The bitbybit Open API provides programmatic access to your bitbybit data
    including customers, orders, and products.
  version: 1.0.0
  contact:
    name: bitbybit Support
    url: https://bitbybit.studio
servers:
  - url: https://api.bitbybit.studio/customer/api/open/v1
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /orders:
    post:
      tags:
        - Orders
      summary: Create an order
      description: >-
        Create a new order. Provide either a customerId or a customer object to
        auto-create.
      operationId: createOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - lineItems
                - shippingAddress
              properties:
                customerId:
                  type: string
                  description: ID of an existing customer
                customer:
                  type: object
                  description: Create or find a customer by phone/email
                  properties:
                    firstName:
                      type: string
                    lastName:
                      type: string
                    phone:
                      type: string
                    email:
                      type: string
                      format: email
                  required:
                    - firstName
                    - lastName
                lineItems:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                      - productVariantId
                      - quantity
                    properties:
                      productVariantId:
                        type: string
                      quantity:
                        type: integer
                        minimum: 1
                shippingAddress:
                  $ref: '#/components/schemas/ShippingAddressInput'
                notes:
                  type: string
                tags:
                  type: array
                  items:
                    type: string
      responses:
        '201':
          description: Order created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Order'
        '400':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    ShippingAddressInput:
      type: object
      required:
        - firstName
        - lastName
        - phone
        - address1
        - city
        - province
        - zip
      properties:
        firstName:
          type: string
        lastName:
          type: string
        phone:
          type: string
        address1:
          type: string
        address2:
          type: string
        city:
          type: string
        province:
          type: string
        country:
          type: string
        zip:
          type: string
    Order:
      type: object
      properties:
        id:
          type: string
        orderId:
          type: string
          nullable: true
        orderNumber:
          type: string
          nullable: true
        status:
          type: string
          enum:
            - active
            - archived
            - cancelled
            - refunded
        fulfillmentStatus:
          type: string
          enum:
            - unfulfilled
            - fulfilled
        financialStatus:
          type: string
          enum:
            - pending
            - paid
            - refunded
        total:
          type: number
        currency:
          type: string
          nullable: true
        notes:
          type: string
          nullable: true
        customer:
          type: object
          properties:
            id:
              type: string
            firstName:
              type: string
              nullable: true
            lastName:
              type: string
              nullable: true
            email:
              type: string
              nullable: true
            phoneNumber:
              type: string
              nullable: true
        lineItems:
          type: array
          items:
            $ref: '#/components/schemas/LineItem'
        shippingAddress:
          $ref: '#/components/schemas/Address'
        tags:
          type: array
          items:
            type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    LineItem:
      type: object
      properties:
        id:
          type: string
        quantity:
          type: integer
        price:
          type: number
        title:
          type: string
        productVariant:
          $ref: '#/components/schemas/ProductVariant'
    Address:
      type: object
      properties:
        id:
          type: string
        firstName:
          type: string
          nullable: true
        lastName:
          type: string
          nullable: true
        phone:
          type: string
          nullable: true
        address1:
          type: string
          nullable: true
        address2:
          type: string
          nullable: true
        city:
          type: string
          nullable: true
        province:
          type: string
          nullable: true
        country:
          type: string
          nullable: true
        zip:
          type: string
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
    ProductVariant:
      type: object
      properties:
        id:
          type: string
        key:
          type: string
        price:
          type: number
        compareAtPrice:
          type: number
          nullable: true
        inventorySku:
          type: string
          nullable: true
        media:
          type: string
          nullable: true
  responses:
    ValidationError:
      description: Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: VALIDATION_ERROR
              message: Invalid request body
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication. Create one in Settings > Developer.

````