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

# Create Draft Order

> Create a new draft order

## Description

This endpoint allows you to create a draft order in FreshTrack via API integration. It provides an easy way for third-party software, such as ERPs (Enterprise Resource Planning systems), to create and submit shipping orders directly into the FreshTrack system.

<Note>
  1. Ensure all required fields are provided in the request body.
  2. The example provided showcases a common shipping route from Agadir, Morocco to Rotterdam, Netherlands.
</Note>


## OpenAPI

````yaml post /draft
openapi: 3.0.0
info:
  title: FreshTrack API
  description: API for managing shipping and logistics operations
  version: '1.0'
  contact: {}
servers:
  - url: https://api.freshtrack.ma/api/v1
security:
  - bearerAuth: []
paths:
  /draft:
    post:
      tags:
        - draft
      summary: Create Draft Order
      description: Create a new draft order in the FreshTrack system
      operationId: createDraftOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DraftOrderDTO'
      responses:
        '200':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Draft order created successfully
                  draftOrderId:
                    type: string
                    example: DO-2024-08203
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid request body
                  details:
                    type: array
                    items:
                      type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Authentication failed
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Internal server error occurred
      security:
        - ApiKeyAuth: []
components:
  schemas:
    DraftOrderDTO:
      type: object
      description: Represents a simplified draft order for maritime container shipping.
      required:
        - reference
        - quantity
        - pickupPlaceName
        - departurePortUnLoCode
        - arrivalPortUnLoCode
        - deliveryPlaceName
        - containerIsoCode
        - commodityHsCode
        - incoterm
      properties:
        reference:
          type: string
          example: AGD-RTM-2024-08136
          description: >-
            A unique reference number assigned by the shipper to identify this
            specific shipment.
        quantity:
          type: number
          example: 2
          description: The number of containers requested for this shipment.
        pickupPlaceName:
          type: string
          example: TAROUNDANT
          description: The name of the pickup location.
        pickupGenset:
          type: boolean
          example: false
          description: >-
            Indicates whether a generator set (genset) is required at the pickup
            location.
        departurePortUnLoCode:
          type: string
          example: MAAGA
          description: The UN/LOCODE for the departure port.
        arrivalPortUnLoCode:
          type: string
          example: NLRTM
          description: The UN/LOCODE for the arrival port.
        deliveryPlaceName:
          type: string
          example: BERLIN
          description: The name of the delivery location.
        deliveryGenset:
          type: boolean
          example: false
          description: >-
            Indicates whether a generator set (genset) is required at the
            delivery location.
        containerIsoCode:
          type: string
          example: 22R1
          description: The ISO code for the container type.
        commodityHsCode:
          type: string
          example: '0805220000'
          description: The Harmonized System (HS) code for the commodity.
        incoterm:
          type: string
          example: FOB
          description: The Incoterm rule used for this shipment.
        comment:
          type: string
          example: Contact hello@example.com (John Doe)
          description: Additional notes or instructions relevant to the shipment.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-auth-token

````