Canix Purchase Orders API

The Purchase Orders API from Canix — 4 operation(s) for purchase orders.

OpenAPI Specification

canix-purchase-orders-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Canix Purchase Orders API
  x-logo:
    url: https://assets.website-files.com/5ee52a0f4be6ffc2aaeb52cd/5ee52a0f4be6ff20e7eb534f_canix-logo.svg
    backgroundColor: '#FFFFFF'
    altText: Canix logo
  description: '# Introduction

    This API documentation describes the endpoints used by third-party developers to get Canix data for their account.

    # Authentication

    Canix API uses API Keys for authentication. You can generate an API key on our [API page](https://app.canix.com/company/api), and on your API requests use the `X-API-KEY` header with the API key value you generated.

    We strongly recommend using a secrets manager. Plain text files like dotenv lead to accidental costly leaks. Use [Doppler](https://doppler.com/) or similar options for a developer friendly experience. AWS and Google Cloud have native solutions as well.'
  contact:
    name: Canix Support
    url: https://help.canix.com/
    email: help@canix.com
  version: 1.3.10
servers:
- url: https://api.canix.com/api/v1
  variables: {}
security:
- ApiKeyAuth: []
tags:
- name: Purchase Orders
paths:
  /purchase_orders:
    get:
      tags:
      - Purchase Orders
      summary: GetPurchaseOrders
      description: Return Purchase Orders
      operationId: GetPurchaseOrders
      parameters:
      - $ref: '#/components/parameters/limitParam'
      - $ref: '#/components/parameters/offsetParam'
      - $ref: '#/components/parameters/orderByParam'
      - $ref: '#/components/parameters/whereParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PurchaseOrder'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401NotAuthenticated'
        '403':
          $ref: '#/components/responses/403AccessDenied'
        '404':
          $ref: '#/components/responses/404NotFound'
        '500':
          $ref: '#/components/responses/500ServerError'
    post:
      tags:
      - Purchase Orders
      summary: PostPurchaseOrder
      description: __CALLING THIS ENDPOINT WILL MODIFY YOUR DATA IRREVERSIBLY. ONLY CALL THIS ON SANDBOX DATA DURING DEVELOPMENT/CODING/TESTING.__
      operationId: PostPurchaseOrder
      requestBody:
        required: true
        description: Create a new Purchase Order
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePurchaseOrderRequestBody'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PurchaseOrder'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401NotAuthenticated'
        '403':
          $ref: '#/components/responses/403AccessDenied'
        '404':
          $ref: '#/components/responses/404NotFound'
        '500':
          $ref: '#/components/responses/500ServerError'
  /purchase_orders/{purchase_order_id}:
    get:
      tags:
      - Purchase Orders
      summary: GetPurchaseOrder
      description: Get Purchase Order by ID
      operationId: GetPurchaseOrderById
      parameters:
      - name: purchase_order_id
        in: path
        description: ID of Purchase Order to return
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PurchaseOrder'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401NotAuthenticated'
        '403':
          $ref: '#/components/responses/403AccessDenied'
        '404':
          $ref: '#/components/responses/404NotFound'
        '500':
          $ref: '#/components/responses/500ServerError'
  /purchase_orders/{purchase_order_id}/contents:
    get:
      tags:
      - Purchase Orders
      summary: GetPurchaseOrderContents
      description: Get Purchase Order Contents by Purchase Order ID
      operationId: GetPurchaseOrderContentsById
      parameters:
      - name: purchase_order_id
        in: path
        description: Purchase Order ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PurchaseOrderItem'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401NotAuthenticated'
        '403':
          $ref: '#/components/responses/403AccessDenied'
        '404':
          $ref: '#/components/responses/404NotFound'
        '500':
          $ref: '#/components/responses/500ServerError'
  /purchase_orders/{purchase_order_id}/payments:
    get:
      tags:
      - Purchase Orders
      summary: GetPurchaseOrderPayments
      description: Get Purchase Order Payments by Purchase Order ID
      operationId: GetpurchaseOrderPayments
      parameters:
      - name: purchase_order_id
        in: path
        description: Purchase Order ID
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PurchaseOrderPayment'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401NotAuthenticated'
        '403':
          $ref: '#/components/responses/403AccessDenied'
        '404':
          $ref: '#/components/responses/404NotFound'
        '500':
          $ref: '#/components/responses/500ServerError'
components:
  schemas:
    NonCannabisProductStandardCosting:
      title: NonCannabisProductStandardCosting
      required:
      - id
      - standard_cost_amount
      - standard_cost_currency
      - start_date
      properties:
        id:
          type: integer
          example: 123
        standard_cost_amount:
          type: number
          example: 12.1111
        standard_cost_currency:
          type: string
          example: USD
        start_date:
          type: string
          example: '2023-04-19'
        end_date:
          type: string
          example: '2023-05-19'
    Address:
      title: Address
      type: object
      properties:
        street:
          type: string
          example: 123 Cumberland St
        street2:
          type: string
          example: West
        city:
          type: string
          example: Somerset
        county:
          type: string
          example: KY
        state:
          type: string
          example: CO
        country:
          type: string
          example: USA
        postal_code:
          type: string
          example: 42504
    Location:
      title: Location
      required:
      - id
      - name
      properties:
        id:
          type: integer
          example: 123
        name:
          type: string
          example: Pro System
        sqft:
          type: number
          example: 14.4
        num_lights:
          type: integer
          example: 42
        parent_location:
          $ref: '#/components/schemas/ParentLocation'
        updated_at:
          type: string
          example: 2018-11-06 08:00:00+00:00
        is_active:
          type: boolean
          example: true
    PurchaseOrderItemRequestBody:
      title: Purchase Order Item Request Body
      required:
      - weight
      - weight_unit_id
      - price
      type: object
      properties:
        item_id:
          type: integer
          example: 7036
          description: Item ID (fk). Mutually exclusive with non_cannabis_product_id - exactly one of the two is required per line item.
        non_cannabis_product_id:
          type: integer
          example: 145
          description: Non-Cannabis Product ID (fk). Mutually exclusive with item_id - exactly one of the two is required per line item.
        weight:
          type: number
          example: 200
        weight_unit_id:
          type: integer
          example: 15
          description: Weight Unit ID (fk)
        price:
          type: number
          example: 10.25
          description: Total price for that item weight
        notes:
          type: string
          example: my notes for this order item
          description: Note to describe the order item
    ItemStandardCost:
      title: ItemStandardCost
      required:
      - id
      - standard_cost_amount
      - standard_cost_currency
      - start_date
      properties:
        id:
          type: integer
          example: 123
        standard_cost_amount:
          type: number
          example: 12.1111
        standard_cost_currency:
          type: string
          example: USD
        start_date:
          type: string
          example: '2023-04-19'
        end_date:
          type: string
          example: '2023-05-19'
    ItemType:
      title: ItemType
      required:
      - id
      - name
      - facility_id
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        quantity_type:
          type: string
        requires_strain:
          type: boolean
        requires_unit_volume:
          type: boolean
        requires_unit_weight:
          type: boolean
        requires_unit_thc_weight:
          type: boolean
        requires_unit_cbd_weight:
          type: boolean
        requires_unit_cbd_percent:
          type: boolean
        requires_unit_thc_percent:
          type: boolean
        requires_public_ingredients:
          type: boolean
        requires_administration_method:
          type: boolean
        requires_serving_size:
          type: boolean
        requires_supply_duration_days:
          type: boolean
        requires_number_of_doses:
          type: boolean
        updated_at:
          type: string
          example: 2018-11-06 08:00:00+00:00
    Vendor:
      title: Vendor
      required:
      - id
      - name
      properties:
        id:
          type: integer
          example: 123
        name:
          type: string
          example: Canna Cones
        is_active:
          type: boolean
        contact_name:
          type: string
          example: John Smith
        email:
          type: string
          example: john@cannacones.com
        phone:
          type: string
          example: 16501109234
        license_number:
          type: string
          example: X-000012
        license_expiration_date:
          type: string
          example: 2022-03-16 07:00:00+00:00
        address:
          type: string
          example: 63 Bluxome St.
        address2:
          type: string
          example: Suite A
        city:
          type: string
          example: San Francisco
        postal_code:
          type: string
          example: 94107
        state:
          type: string
          example: CA
        country:
          type: string
          example: US
        website_url:
          type: string
          example: cannacones.com
        notes:
          type: string
          example: Best vendor
        min_lead_time:
          type: object
          example:
            value: 2
            unit: week
        updated_at:
          type: string
          example: 2018-11-06 08:00:00+00:00
    CreatePurchaseOrderRequestBody:
      title: Purchase Order Request Body
      required:
      - facility_id
      - vendor_id
      - status
      - requested_delivery_date
      - payment_terms
      type: object
      properties:
        facility_id:
          type: integer
          example: 1
          description: Facility ID (fk)
        name:
          type: string
          example: PO 00001
          description: Optional name for the purchase order
        status:
          type: string
          enum:
          - CREATED
          - RELEASED
          - REQUESTED
          - PARTIALLY_RECEIVED
          - RECEIVED
          - PAID
          - ARCHIVED
          description: Status of the purchase order
        vendor_id:
          type: integer
          example: 123
          description: Vendor ID (fk)
        requested_delivery_date:
          type: string
          format: date
          example: '2021-06-07'
          description: Expected delivery date for the purchase order
        internal_notes:
          type: string
          example: Follow up
          description: Optional internal notes for the purchase order
        payment_terms:
          type: string
          pattern: ^(NET|COD|CONSIGNMENT|PREPAYMENT)
          example: NET15
          description: Payment terms - must start with one of 'NET', 'COD', 'CONSIGNMENT', 'PREPAYMENT'
        payment_date:
          type: string
          format: date
          example: '2021-06-22'
          description: Date when the Purchase Order was paid. Required if payment_terms is PREPAYMENT
        delivery_fee:
          type: number
          format: float
          minimum: 0
          example: 1.5
          description: Optional delivery fee amount
        local_tax_rate:
          type: number
          format: float
          minimum: 0
          maximum: 1
          example: 0.01
          description: Input 0.01 to represent 1% tax rate. Will enable excise_tax if greater than 0
        state_tax_rate:
          type: number
          format: float
          minimum: 0
          maximum: 1
          example: 0.01
          description: Input 0.01 to represent 1% tax rate. Will enable excise_tax if greater than 0
        other_tax_rate:
          type: number
          format: float
          minimum: 0
          maximum: 1
          example: 0.01
          description: Input 0.01 to represent 1% tax rate
        purchase_order_items_attributes:
          description: Contents of the order (i.e. line items)
          type: array
          items:
            $ref: '#/components/schemas/PurchaseOrderItemRequestBody'
    IdName:
      title: IdName
      type: object
      properties:
        id:
          type: number
        name:
          type: string
    PurchaseOrderPayment:
      title: Purchase Order Payment
      type: object
      required:
      - amount
      - date
      properties:
        amount:
          type: number
          format: float
          example: 100.0
        date:
          type: string
          format: date
          example: '2025-02-04'
    CrossStrain:
      title: Cross Strain
      required:
      - id
      - name
      properties:
        id:
          type: integer
        name:
          type: string
          example: Lemon Skunk
          description: Strain name
        notes:
          type: string
          example: Terpenes .63%
          description: Notes
        sku:
          type: string
          example: BIOJJ
          description: SKU
        testing_status:
          type: string
          example: InHouse
          description: 'Testing status: InHouse, ThirdParty, None, NA'
        indica_percent:
          type: number
          example: 45.0
          description: Indica Percentage
        sativa_percent:
          type: number
          example: 55.0
          description: Sativa Percentage
    Item:
      title: Item
      required:
      - id
      - name
      - facility_id
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        is_active:
          type: boolean
        item_type:
          type: string
        brand:
          $ref: '#/components/schemas/IdName'
        product_id:
          type: integer
          description: ID of the active Product this item belongs to, if any
        product_brand:
          $ref: '#/components/schemas/IdName'
        quantity_type:
          type: string
        sku:
          type: string
        current_standard_cost:
          $ref: '#/components/schemas/ItemStandardCost'
        accounting_inventory_type:
          type: string
        notes:
          type: string
        facility_id:
          type: integer
        strain:
          $ref: '#/components/schemas/Strain'
        type:
          $ref: '#/components/schemas/ItemType'
        sub_type:
          $ref: '#/components/schemas/ItemSubType'
        weight_unit:
          type: string
        unit_weight:
          type: number
        unit_weight_unit:
          type: string
        case_quantity:
          type: string
        case_quantity_unit:
          type: string
        unit_cbd_weight:
          type: number
        unit_cbd_weight_unit:
          type: string
        unit_thc_weight:
          type: number
        unit_thc_weight_unit:
          type: string
        unit_cbd_percent:
          type: number
        unit_thc_percent:
          type: number
        description:
          type: string
        serving_size:
          type: number
        number_of_doses:
          type: number
        public_ingredients:
          type: string
        supply_duration_days:
          type: number
        administration_method:
          type: string
        allergens:
          type: string
        transfer_source_license:
          type: string
          description: Facility license number of the originating facility. Non-editable.
        bills_of_materials:
          type: array
          items:
            type: object
            properties:
              url:
                type: string
              name:
                type: string
              package_weight:
                type: number
              unit:
                type: string
        sage_item:
          type: object
          properties:
            external_id:
              type: string
            name:
              type: string
        leaflink_item:
          type: object
          properties:
            external_id:
              type: string
            name:
              type: string
        dutchie_product:
          type: object
          properties:
            external_id:
              type: string
            name:
              type: string
        phenotype:
          type: string
        total_for_sale:
          type: number
          description: Total quantity marked as available to sell
        ordered:
          type: number
          description: Total quantity ordered from in-progress sales orders
        backordered:
          type: number
          description: Total quantity backordered from in-progress sales orders
        unordered:
          type: number
          description: Quantity available to sell minus ordered quantity (minimum 0)
        updated_at:
          type: string
          example: 2018-11-06 08:00:00+00:00
      example:
        id: 7036
        name: Blue Dream - Trim
        sku: '22657'
        current_standard_costing:
          id:
            type: integer
            example: 123
          standard_cost_amount:
            type: number
            example: 12.1111
          standard_cost_currency:
            type: string
            example: USD
          start_date:
            type: string
            example: '2023-04-19'
          end_date:
            type: string
          example: '2023-05-19'
        is_active: true
        facility_id: 14
        type:
          id: 884
          name: Clone - Cutting
          quantity_type: CountBased
          product_category: Plants
        sub_type: null
        brand: null
        product_id: 512
        product_brand: null
        quantity_type: CountBased
        notes: ''
        accounting_inventory_type: raw_materials
        strain: null
        weight_unit: Each
        unit_weight: 10
        unit_weight_unit: Grams
        case_quantity: 100
        case_unit: Each
        description: Clone
        allergens: Can s 2
        transfer_source_license: '1234567890'
        bills_of_materials:
        - url: https://www.app.canix.com/inventory/non-cannabis/bill-of-materials/123
          name: Bill of Materials
          package_weight: 10
          unit: g
        sage_item:
          external_id: '1234567890'
          name: Sage Item
        leaflink_item: null
        dutchie_product: null
        phenotype: Indica
        total_for_sale: 100
        ordered: 25
        backordered: 10
        unordered: 75
        updated_at: '2021-03-16T23:49:03.175Z'
    PurchaseOrder:
      title: Purchase Order
      required:
      - id
      - facility_id
      - name
      - status
      - requested_delivery_date
      - other_tax_rate
      - local_tax_rate
      - state_tax_rate
      type: object
      properties:
        id:
          type: integer
          example: 350
        facility_id:
          type: integer
          example: 1
          description: Facility ID (fk)
        name:
          type: string
          example: PO 00001
        status:
          type: string
          description: 'status, can be one of: ''CREATED'', ''RELEASED'', ''REQUESTED'', ''PARTIALLY_RECEIVED'', ''RECEIVED'', ''PAID'', ''ARCHIVED'''
        vendor:
          $ref: '#/components/schemas/Vendor'
        requested_delivery_date:
          type: string
          example: '2021-06-07T07:00:00.000Z'
        internal_notes:
          type: string
          example: Follow up
        payment_terms:
          type: string
          example: NET15
          description: Has to start with one of 'NET', 'COD', 'CONSIGNMENT', 'PREPAYMENT'
        payment_date:
          type: string
          example: '2021-06-22'
          description: Date when the Purchase Order was paid. (Required if payment_terms is PREPAYMENT)
        delivery_fee:
          type: number
          example: 1.5
        local_tax_rate:
          type: number
          example: 0.01
          description: Input 0.01 to represent 1% tax rate
        state_tax_rate:
          type: number
          example: 0.01
          description: Input 0.01 to represent 1% tax rate
        other_tax_rate:
          type: number
          example: 0.01
          description: Input 0.01 to represent 1% tax rate
        subtotal:
          type: number
          description: Subtotal of all items
        total_price:
          type: number
          description: Total price (with taxes)
        total_paid:
          type: number
        payments:
          description: Payments for this order
          type: array
          items:
            $ref: '#/components/schemas/PurchaseOrderPayment'
        contents:
          description: Contents of the order (i.e. line items)
          type: array
          items:
            $ref: '#/components/schemas/PurchaseOrderItem'
        created_at:
          type: string
          description: Timestamp that the record was created in Canix
        updated_at:
          type: string
          example: 2018-11-06 08:00:00+00:00
    NonCannabisProduct:
      title: Non Cannabis Product
      required:
      - id
      - name
      properties:
        id:
          type: integer
          example: 123
        name:
          type: string
          example: Pro System
        is_active:
          type: boolean
        facilities:
          $ref: '#/components/schemas/Facility'
          description: All facilities that the product is available in
        category:
          $ref: '#/components/schemas/NonCannabisProductCategory'
        location:
          $ref: '#/components/schemas/Location'
        sku:
          type: string
          example: 0.5EC
        notes:
          type: string
          description: Optional notes for the product
          example: This product requires special handling
        available_quantity:
          type: number
          example: 196
        weight_unit:
          type: string
          example: Each
        par:
          type: number
          example: 100
        updated_at:
          type: string
          example: 2018-11-06 08:00:00+00:00
        current_standard_costing:
          $ref: '#/components/schemas/NonCannabisProductStandardCosting'
        submits_to_metrc:
          type: boolean
          description: This field is only applicable to products that are submitted to METRC
        additive_type:
          type: string
          example: fertilizer
          description: This field is only applicable to products that are submitted to METRC
        product_trade_name:
          type: string
          description: This field is only applicable to products that are submitted to METRC
        epa_registration_name:
          type: string
          description: This field is only applicable to products that are submitted to METRC
        product_supplier:
          type: string
          description: This field is only applicable to products that are submitted to METRC
        application_device:
          type: string
          description: This field is only applicable to products that are submitted to METRC
        active_ingredients:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              percentage:
                type: number
    Strain:
      title: Strain
      required:
      - id
      - name
      properties:
        id:
          type: integer
        name:
          type: string
          example: Lemon Skunk
          description: Strain name
        notes:
          type: string
          example: Terpenes .63%
          description: Notes
        sku:
          type: string
          example: BIOJJ
          description: SKU
        testing_status:
          type: string
          example: InHouse
          description: 'Testing status: InHouse, ThirdParty, None, NA'
        indica_percent:
          type: number
          example: 45.0
          description: Indica Percentage
        sativa_percent:
          type: number
          example: 55.0
          description: Sativa Percentage
        cross_strains:
          type: array
          description: Cross strains
          items:
            $ref: '#/components/schemas/CrossStrain'
    ItemSubType:
      title: ItemSubType
      required:
      - id
      - name
      - weight_unit
      - item_category
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        weight_unit:
          type: string
        category:
          $ref: '#/components/schemas/ItemType'
        updated_at:
          type: string
          example: 2018-11-06 08:00:00+00:00
    NonCannabisProductCategory:
      title: Non Cannabis Product Category
      required:
      - id
      - name
      properties:
        id:
          type: integer
          example: 123
        name:
          type: string
          example: Preroll Materials
        updated_at:
          type: string
          example: 2018-11-06 08:00:00+00:00
    ParentLocation:
      title: Parent Location
      required:
      - id
      - name
      properties:
        id:
          type: integer
          example: 123
        name:
          type: string
          example: Pro System
        sqft:
          type: number
          example: 14.4
        num_lights:
          type: integer
          example: 42
        updated_at:
          type: string
          example: 2018-11-06 08:00:00+00:00
        is_active:
          type: boolean
          example: true
    PurchaseOrderItem:
      title: Purchase Order Item
      required:
      - id
      - purchase_order_id
      type: object
      properties:
        id:
          type: integer
          example: 13
        weight:
          type: number
          example: 200
        weight_unit:
          type: string
          example: Grams
        total_price:
          type: number
          example: 10.25
          description: Total price for that item weight
        item:
          $ref: '#/components/schemas/Item'
          description: Purchased cannabis item (if `non_cannabis_product` is unset)
        non_cannabis_product:
          $ref: '#/components/schemas/NonCannabisProduct'
          description: Purchased non-cannabis item (if `item` is unset)
    Facility:
      title: Facility
      required:
      - id
      properties:
        id:
          type: integer
          example: 123
        name:
          type: string
          example: Test Facility
        license_number:
          type: string
          example: 4a-x123
        is_active:
          type: boolean
          example: true
        address:
          $ref: '#/components/schemas/Address'
  parameters:
    offsetParam:
      name: offset
      in: query
      description: Offset for the returned records (optional)
      schema:
        type: integer
        default: 0
        example: 20
    whereParam:
      name: where
      in: query
      description: 'Filter results using SQL-like WHERE clause syntax (optional).


        **Supported operators**: =, >, <, >=, <=, BETWEEN, IN, LIKE, AND, OR


        **Supported patterns**:

        - Equality: `status=''Active''`

        - Comparison: `updated_at >= ''2024-01-01''`

        - Range: `id BETWEEN 1 AND 10000`

        - List: `status IN (''Active'', ''Pending'')`

        - Pattern: `sku LIKE ''ABC%''`

        - Compound: `facility_id=123 AND is_active=true`

        '
      schema:
        type: string
        example: status='Active' AND updated_at >= '2024-01-01'
    orderByParam:
      name: order_by
      in: query
      description: Order-by clause, in SQL format (optional)
      schema:
        type: string
        example: id desc
    limitParam:
      name: limit
      in: query
      description: Max number of records to return (optional). Cannot exceed 2000
      required: false
      style: form
      schema:
        type: integer
        default: 2000
        example: 100
  responses:
    403AccessDenied:
      description: Access denied
    404NotFound:
      description: The specified resource was not found
    400BadRequest:
      description: Bad request
    401NotAuthenticated:
      description: Not authenticated
    500ServerError:
      description: Server error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY