> ## Documentation Index
> Fetch the complete documentation index at: https://cinch-api.crex.page/llms.txt
> Use this file to discover all available pages before exploring further.

# Create order with emissions

> Estimate emission given an order



## OpenAPI

````yaml post /api/customer-orders
openapi: 3.0.0
info:
  title: CREX API
  version: '1.0'
servers:
  - url: https://api.gocrex.com
    variables: {}
security:
  - ApiKeyAuth: []
tags: []
paths:
  /api/customer-orders:
    post:
      tags: []
      summary: Create order with emissions
      description: Estimate emission given an order
      operationId: GrootApi.OrdersController.create
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderParams'
        description: OrderParams
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderResponse'
          description: OrderResponse
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
          description: BadRequest
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: ErrorResponse
      callbacks: {}
components:
  schemas:
    OrderParams:
      description: Order Params
      properties:
        customer_id:
          description: >-
            Your customer ID. This is used to identify the customer in your
            system.
          type: string
          x-struct: null
          x-validate: null
        items:
          items:
            $ref: '#/components/schemas/OrderItemSchema'
          type: array
          x-struct: null
          x-validate: null
        order_date:
          description: The date of the Order (YYYY-MM-DD)
          format: date
          type: string
          x-struct: null
          x-validate: null
        order_id:
          description: Your order ID. This is used to identify the order in your system.
          type: string
          x-struct: null
          x-validate: null
        tenure_start_date:
          description: The start date of the order (YYYY-MM-DD)
          format: date
          type: string
          x-struct: null
          x-validate: null
      required:
        - customer_id
        - order_id
        - order_date
        - tenure_start_date
      title: OrderParams
      type: object
      x-struct: Elixir.GrootApi.ApiSpec.Schemas.OrderParams
      x-validate: null
    OrderResponse:
      properties:
        created_at:
          description: Order creation date
          format: date-time
          type: string
          x-struct: null
          x-validate: null
        customer_id:
          description: Customer ID
          type: string
          x-struct: null
          x-validate: null
        emission_unit:
          description: Unit of GHG emission
          example: kgCO2e
          type: string
          x-struct: null
          x-validate: null
        items:
          description: List of items in the order
          items:
            $ref: '#/components/schemas/ItemSchema'
          type: array
          x-struct: null
          x-validate: null
        order_date:
          description: Order date
          format: date
          type: string
          x-struct: null
          x-validate: null
        order_id:
          description: Order ID
          type: string
          x-struct: null
          x-validate: null
        status:
          description: Order status
          example: created
          type: string
          x-struct: null
          x-validate: null
        tenure_start_date:
          description: Order's tenure start date
          format: date
          type: string
          x-struct: null
          x-validate: null
        total_emission:
          description: Total GHG emission of the order
          type: number
          x-struct: null
          x-validate: null
      title: OrderResponse
      type: object
      x-struct: Elixir.GrootApi.ApiSpec.Schemas.OrderResponse
      x-validate: null
    BadRequest:
      description: Bad request
      example:
        error: Invalid parameter
      properties:
        error:
          description: Error message
          type: string
          x-struct: null
          x-validate: null
      title: BadRequest
      type: object
      x-struct: Elixir.GrootApi.ApiSpec.Schemas.BadRequest
      x-validate: null
    ErrorResponse:
      example:
        code: unauthorized
        detail: Invalid API key
      properties:
        code:
          type: string
          x-struct: null
          x-validate: null
        detail:
          type: string
          x-struct: null
          x-validate: null
      title: ErrorResponse
      type: object
      x-struct: Elixir.GrootApi.ApiSpec.Schemas.ErrorResponse
      x-validate: null
    OrderItemSchema:
      description: Properties common to all items
      properties:
        config:
          description: Configuration of the item based on type
          discriminator:
            mapping:
              packaging: '#/components/schemas/PackagingItemSchema'
              product: '#/components/schemas/ProductItemSchema'
              transportation: '#/components/schemas/TransportationItemSchema'
            propertyName: type
          oneOf:
            - $ref: '#/components/schemas/ProductItemSchema'
            - $ref: '#/components/schemas/TransportationItemSchema'
            - $ref: '#/components/schemas/PackagingItemSchema'
          x-struct: null
          x-validate: null
        type:
          description: Type of item
          enum:
            - product
            - transportation
            - packaging
          type: string
          x-struct: null
          x-validate: null
      required:
        - type
        - config
      title: OrderItemSchema
      type: object
      x-struct: Elixir.GrootApi.ApiSpec.Schemas.OrderParams.OrderItemSchema
      x-validate: null
    ItemSchema:
      properties:
        device_id:
          description: Device ID
          type: string
          x-struct: null
          x-validate: null
        emission_breakdown:
          properties:
            packaging:
              $ref: '#/components/schemas/EmissionBreakdownSchema'
            product_embodied_emission:
              $ref: '#/components/schemas/EmissionBreakdownSchema'
            product_use:
              $ref: '#/components/schemas/EmissionBreakdownSchema'
            transportation:
              $ref: '#/components/schemas/EmissionBreakdownSchema'
          type: object
          x-struct: null
          x-validate: null
        serial_number:
          description: Serial number of the product
          type: string
          x-struct: null
          x-validate: null
        total_emission:
          description: Total GHG emission of the item
          type: number
          x-struct: null
          x-validate: null
        type:
          description: Type of item
          enum:
            - product
            - packaging
            - transportation
          example: product
          type: string
          x-struct: null
          x-validate: null
      title: ItemSchema
      type: object
      x-struct: Elixir.GrootApi.ApiSpec.Schemas.OrderResponse.ItemSchema
      x-validate: null
    ProductItemSchema:
      description: Properties specific to product items
      properties:
        product_id:
          description: >-
            Your product ID. This is used to identify the product in your
            system.
          type: string
          x-struct: null
          x-validate: null
        serial_number:
          description: Serial number of the product
          type: string
          x-struct: null
          x-validate: null
        tenure_months:
          description: Tenure of the product in months
          type: integer
          x-struct: null
          x-validate: null
        weight_kg:
          description: Weight of the product in kilograms
          type: number
          x-struct: null
          x-validate: null
      required:
        - product_id
        - tenure_months
        - weight_kg
        - serial_number
      title: ProductItemSchema
      type: object
      x-struct: Elixir.GrootApi.ApiSpec.Schemas.OrderParams.ProductItemSchema
      x-validate: null
    TransportationItemSchema:
      description: Properties specific to transport items
      properties:
        distance_km:
          description: Distance in kilometers
          type: number
          x-struct: null
          x-validate: null
        transportation_id:
          description: Transportation ID
          type: string
          x-struct: null
          x-validate: null
        transportation_mode:
          description: Mode of transportation
          type: string
          x-struct: null
          x-validate: null
        weight_kg:
          description: Weight in kilograms
          type: number
          x-struct: null
          x-validate: null
      required:
        - transportation_mode
        - transportation_id
        - distance_km
        - weight_kg
      title: TransportationItemSchema
      type: object
      x-struct: Elixir.GrootApi.ApiSpec.Schemas.OrderParams.TransportationItemSchema
      x-validate: null
    PackagingItemSchema:
      description: Properties specific to packaging
      properties:
        packaging_id:
          description: Packaging ID
          type: string
          x-struct: null
          x-validate: null
        weight_kg:
          description: Weight in kilograms
          type: number
          x-struct: null
          x-validate: null
      required:
        - packaging_id
        - weight_kg
      title: PackagingItemSchema
      type: object
      x-struct: Elixir.GrootApi.ApiSpec.Schemas.OrderParams.PackagingItemSchema
      x-validate: null
    EmissionBreakdownSchema:
      properties:
        description:
          description: Description of the emission source
          type: string
          x-struct: null
          x-validate: null
        emission:
          description: GHG Emission value
          type: number
          x-struct: null
          x-validate: null
        emission_unit:
          description: Unit of GHG emission
          example: kgCO2e
          type: string
          x-struct: null
          x-validate: null
        ghg_category:
          description: GHG category
          type: string
          x-struct: null
          x-validate: null
        ghg_scope:
          description: GHG Scope category
          type: string
          x-struct: null
          x-validate: null
        type:
          description: Type of emission computation result (e.g., estimated, indicative)
          type: string
          x-struct: null
          x-validate: null
      title: EmissionBreakdownSchema
      type: object
      x-struct: Elixir.GrootApi.ApiSpec.Schemas.OrderResponse.EmissionBreakdownSchema
      x-validate: null
  securitySchemes:
    ApiKeyAuth:
      in: header
      name: X-API-Key
      type: apiKey

````