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

# Get Loads List

> Retrieve a paginated list of loads (orders) with related stops, trips, tags, documents, and ETA details.

## API Url

```json theme={null}
https://{company_name}.datatruck.io/api/v1/openapi/orders/
```

Here, please put your company name in the url. Ex: if it is CompanyX company, then url should be

```json theme={null}
https://companyx.datatruck.io/api/v1/openapi/orders/
```

## Sample request

```json theme={null}
curl --request GET \
--url https://{company_name}.datatruck.io/api/v1/openapi/orders/ \
--header "Authorization: Token cc92174571ac12f386e5657b187d39bb210f3270a837730125ed4029a44fsdfasd" \
--header "Content-Type: application/json"
```

## Sample response

```json theme={null}
{
    "count": 150,
    "next": "https://companyx.datatruck.io/api/v1/openapi/orders/?page=2",
    "previous": null,
    "results": [
        {
            "id": 2489,
            "load_id": "T-111QT34XS",
            "shipment_id": "DT-002489",
            "status": "dispatched",
            "load_pay": "148.17",
            "total_miles": "574.31",
            "created_datetime": "2023-10-11T13:42:54.456045Z",
            "created_by__full_name": "Super Admin",
            "total_other_pay": "122.00",
            "total_pay": "270.17",
            "per_mile_revenue": "0.26",
            "tags": [{"name": "AUTOBOT"}],
            "dispatcher__full_name": "Alice Johnson",
            "customer__company_name": "ABC Logistics",
            "mc_number__company_name": "Updated Test Mc Number",
            "office__office_name": null,
            "pickup_appointment_time": "2023-10-08T20:00:00Z",
            "delivery_appointment_time": "2023-10-11T23:14:00Z",
            "pickup_time": "2023-10-08T20:00:00Z",
            "delivery_time": "2023-10-11T23:14:00Z",
            "stops": [
                {
                    "id": 101,
                    "order": 2489,
                    "stop_type": "pickup",
                    "location": {
                        "id": 1348,
                        "company": "DWA9",
                        "address1": "3711 142nd Ave E, Sumner, WA 98390, USA",
                        "city": "Sumner",
                        "state": "Washington",
                        "zip_code": "98390",
                        "latitude": 47.203,
                        "longitude": -122.229,
                        "is_active": true
                    },
                    "reference_id": "REF-001",
                    "proof_of_delivery": null
                }
            ],
            "is_flagged": false,
            "flagging_reason": null,
            "documents": [
                {
                    "file_type": "rate_confirmation",
                    "file_link": "https://storage.example.com/docs/rc-2489.pdf",
                    "uploaded_by": "Super Admin",
                    "uploaded_at": "2023-10-11T13:50:00Z"
                }
            ],
            "trip": {
                "id": 1913,
                "status": "assigned",
                "trip_id": "TR-002489-01",
                "mile": "574.31",
                "empty_mile": "0.00",
                "total_load_pay": "148.17",
                "carrier__name": null,
                "driver__full_name": "John Smith",
                "team_driver__full_name": null,
                "truck__unit_number": "2105",
                "pickup": {
                    "id": 1348,
                    "company": "DWA9",
                    "address1": "3711 142nd Ave E",
                    "city": "Sumner",
                    "state": "Washington",
                    "zip_code": "98390",
                    "latitude": 47.203,
                    "longitude": -122.229,
                    "is_active": true
                },
                "delivery": null,
                "settlement": null
            },
            "batch_orders": null,
            "eta_detail": {"on_time": true, "eta_datetime": null}
        }
    ]
}
```

## Filtering

Pass a JSON-encoded array to the `filter` query parameter. Each object in the array has three keys:

| Key        | Description                                                 |
| ---------- | ----------------------------------------------------------- |
| `column`   | ORM field path (e.g. `status`, `load_pay`, `delivery_time`) |
| `value`    | The filter value                                            |
| `contains` | Operator (see table below)                                  |

### Supported operators

| Operator           | Description                          | Example value                                 |
| ------------------ | ------------------------------------ | --------------------------------------------- |
| `is`               | Exact match                          | `"booked"`                                    |
| `is_not`           | Exclude exact match                  | `"cancelled"`                                 |
| `is_in`            | Match any in list                    | `["booked","dispatched"]`                     |
| `is_not_in`        | Exclude all in list                  | `["cancelled"]`                               |
| `contains`         | Case-insensitive substring           | `"logistics"`                                 |
| `before`           | Less than or equal                   | `"2024-07-10T23:59:59Z"`                      |
| `after`            | Greater than or equal                | `"2024-06-26T00:00:00Z"`                      |
| `greater_than`     | Greater than or equal (numeric)      | `"1000"`                                      |
| `less_than`        | Less than or equal (numeric)         | `"5000"`                                      |
| `between`          | Numeric range (comma-separated)      | `"1000,5000"`                                 |
| `between_datetime` | Datetime range (comma-separated ISO) | `"2024-06-26T00:00:00Z,2024-07-10T23:59:59Z"` |
| `isnull`           | Is null check                        | `"true"` or `"false"`                         |
| `today`            | Matches today's date                 | *(any value)*                                 |
| `exclude`          | Exclude exact match                  | `"booked"`                                    |
| `exclude_in`       | Exclude all in list                  | `["booked","dispatched"]`                     |

### Examples

**Filter by status:**

```
?filter=[{"column":"status","value":"booked","contains":"is"}]
```

**Filter by delivery datetime range:**

```
?filter=[{"column":"delivery_time","value":"2024-06-26T00:00:00.000Z,2024-07-10T23:59:59.000Z","contains":"between_datetime"}]
```

**Filter after a date:**

```
?filter=[{"column":"delivery_time","value":"2024-06-26T00:00:00.000Z","contains":"after"}]
```

**Combine multiple filters:**

```
?filter=[{"column":"status","value":"booked","contains":"is"},{"column":"load_pay","value":"1000,5000","contains":"between"}]
```

## Ordering

Use the `ordering` query parameter with an ORM field path. Prefix with `-` for descending order.

```
?ordering=-created_datetime
?ordering=load_pay
```


## OpenAPI

````yaml GET /orders/
openapi: 3.0.1
info:
  title: OpenAPI Datatruck
  description: >-
    To be able to use Datatruck OpenAPI you should create tokens from your
    dashboard. Go to your dashboard and create token with appropriate scopes and
    expiration. Expiration and scopes are optional as well as description for
    your token, but remember name is required.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://{company}.datatruck.io/api/v1/openapi/
security: []
paths:
  /orders/:
    get:
      summary: List Orders
      description: >-
        Retrieve a paginated list of loads (orders) with related stops, trips,
        tags, documents, and ETA details.
      operationId: listOrders
      parameters:
        - name: page
          in: query
          required: false
          schema:
            type: integer
            example: 1
          description: Page number for paginated results.
        - name: page_size
          in: query
          required: false
          schema:
            type: integer
            example: 10
            maximum: 25
          description: Number of results per page (max 25, default 10).
        - name: ordering
          in: query
          required: false
          schema:
            type: string
            example: '-created_datetime'
          description: >-
            ORM field path to order by. Prefix with `-` for descending order
            (e.g. `-created_datetime`, `load_pay`, `status`).
        - name: filter
          in: query
          required: false
          schema:
            type: string
            example: '[{"column":"status","value":"booked","contains":"is"}]'
          description: >-
            JSON-encoded array of filter objects. Each object has `column` (ORM
            field path), `value`, and `contains` (operator). Supported
            operators: `is`, `is_not`, `is_in`, `is_not_in`, `contains`,
            `before`, `after`, `greater_than`, `less_than`, `between`,
            `between_datetime`, `isnull`, `today`, `exclude`, `exclude_in`.
            Example:
            `[{"column":"status","value":"booked","contains":"is"},{"column":"load_pay","value":"1000,5000","contains":"between"}]`
      responses:
        '200':
          description: Paginated list of orders.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderListResponse'
        '400':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    OrderListResponse:
      type: object
      properties:
        count:
          type: integer
          description: Total number of orders.
          example: 150
        next:
          type: string
          nullable: true
          description: URL to the next page of results.
        previous:
          type: string
          nullable: true
          description: URL to the previous page of results.
        results:
          type: array
          items:
            $ref: '#/components/schemas/Order'
          description: List of orders.
      required:
        - count
        - next
        - previous
        - results
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
    Order:
      type: object
      required:
        - id
        - status
        - created_datetime
        - tags
        - equipment_type
        - equipment_type_child
        - estimated_mile
        - estimated_time
        - eta_detail
        - trip
        - batch_orders
        - assigned_driver_n_truck
        - assigned_carrier
        - is_flagged
        - documents
        - stops
      properties:
        id:
          type: integer
          example: 12345
          description: Unique order ID
        load_id:
          type: string
          nullable: true
          example: LD-987654
          description: Load identifier
        shipment_id:
          type: string
          nullable: true
          example: SHIP-123456
          description: Shipment identifier
        status:
          type: string
          example: In Progress
          description: Current status of the load
        load_pay:
          type: string
          format: decimal
          nullable: true
          example: '5000.00'
          description: Total payment amount for the load
        total_miles:
          type: string
          format: decimal
          nullable: true
          example: '1500.75'
          description: Total miles covered for the load
        created_datetime:
          type: string
          format: date-time
          example: '2025-02-06T12:00:00Z'
          description: Order creation timestamp
        created_by__full_name:
          type: string
          nullable: true
          example: John Doe
          description: Full name of the order creator
        total_other_pay:
          type: string
          format: decimal
          nullable: true
          example: '200.00'
          description: Additional payments related to the order
        total_pay:
          type: string
          format: decimal
          nullable: true
          example: '5200.00'
          description: Total payout for the order
        per_mile_revenue:
          type: string
          format: decimal
          nullable: true
          example: '3.25'
          description: Revenue per mile (optional)
        tags:
          type: array
          description: List of tags associated with the order
          items:
            $ref: '#/components/schemas/Tag'
        dispatcher__full_name:
          type: string
          nullable: true
          example: Alice Johnson
          description: Full name of the dispatcher
        customer__company_name:
          type: string
          nullable: true
          example: ABC Logistics
          description: Customer's company name
        mc_number__company_name:
          type: string
          nullable: true
          example: XYZ Carriers
          description: Motor carrier company name
        office__office_name:
          type: string
          nullable: true
          example: Dallas Office
          description: Office handling the order
        pickup_appointment_time:
          type: string
          format: date-time
          nullable: true
          example: '2025-02-06T08:30:00Z'
          description: Scheduled pickup appointment time
        delivery_appointment_time:
          type: string
          format: date-time
          nullable: true
          example: '2025-02-07T15:00:00Z'
          description: Scheduled delivery appointment time
        pickup_time:
          type: string
          format: date-time
          nullable: true
          example: '2025-02-06T09:00:00Z'
          description: Actual pickup time
        delivery_time:
          type: string
          format: date-time
          nullable: true
          example: '2025-02-07T16:30:00Z'
          description: Actual delivery time
        stops:
          type: array
          description: Stops along the order route
          items:
            $ref: '#/components/schemas/OrderStopLocation'
        equipment_type:
          type: string
          example: Refrigerated
          description: Equipment type used for transportation
        equipment_type_child:
          type: array
          description: List of child equipment types
          items:
            type: string
            example: Chilled Storage
        transportation_mode:
          type: string
          nullable: true
          example: Truckload
          description: Mode of transportation
        driver_requirements:
          type: array
          items:
            type: string
          description: Driver-specific requirements
        additional_equipments:
          type: array
          items:
            type: string
          description: Additional equipment required
        freight_requirements:
          type: array
          items:
            type: string
          description: Freight-specific requirements
        freight_requirements_min_temperature:
          type: string
          format: decimal
          nullable: true
          example: '2.0'
          description: Minimum temperature requirement
        freight_requirements_max_temperature:
          type: string
          format: decimal
          nullable: true
          example: '8.0'
          description: Maximum temperature requirement
        estimated_mile:
          type: string
          format: decimal
          example: '1200.50'
          description: Estimated miles for the trip
        estimated_time:
          type: integer
          example: 10
          description: Estimated travel time in hours
        eta_detail:
          $ref: '#/components/schemas/ETADetail'
        trip:
          $ref: '#/components/schemas/TripOrder'
        batch_orders:
          $ref: '#/components/schemas/OrderFullBatchOrder'
        assigned_driver_n_truck:
          type: object
          properties:
            driver_full_name:
              type: string
              nullable: true
            truck_unit_number:
              type: string
              nullable: true
        assigned_carrier:
          type: string
          nullable: true
        is_flagged:
          type: boolean
          example: false
          description: Whether the order has been flagged for attention.
        flagging_reason:
          type: string
          nullable: true
          example: null
          description: Reason the order was flagged, if applicable.
        documents:
          type: array
          description: >-
            Documents attached to the order (rate confirmation, bill of lading,
            proof of delivery, commercial invoice).
          items:
            $ref: '#/components/schemas/OrderDocument'
    Tag:
      type: object
      properties:
        name:
          type: string
          example: Urgent
          description: Tag name associated with the order
    OrderStopLocation:
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for the stop.
        order:
          type: integer
          description: ID of the parent order.
        stop_type:
          type: string
          example: pickup
          description: 'Type of stop: pickup or delivery.'
        location:
          $ref: '#/components/schemas/StopLocation'
          nullable: true
        reference_id:
          type: string
          nullable: true
          example: REF-001
        proof_of_delivery:
          type: string
          nullable: true
        ready_time_start_date:
          type: string
          format: date-time
          nullable: true
        ready_time_end_date:
          type: string
          format: date-time
          nullable: true
        note:
          type: string
          nullable: true
    ETADetail:
      type: object
      properties:
        on_time:
          type: boolean
        eta_datetime:
          type: string
          format: date-time
          nullable: true
    TripOrder:
      type: object
      nullable: true
      properties:
        id:
          type: integer
        status:
          type: string
          example: assigned
        trip_id:
          type: string
          nullable: true
          example: TR-002489-01
        mile:
          type: string
          format: decimal
          nullable: true
          example: '574.31'
        empty_mile:
          type: string
          format: decimal
          nullable: true
          example: '0.00'
        total_load_pay:
          type: string
          format: decimal
          nullable: true
          example: '148.17'
        carrier__name:
          type: string
          nullable: true
        driver__full_name:
          type: string
          nullable: true
        team_driver__full_name:
          type: string
          nullable: true
        truck__unit_number:
          type: string
          nullable: true
        pickup:
          $ref: '#/components/schemas/StopLocation'
          nullable: true
        delivery:
          $ref: '#/components/schemas/StopLocation'
          nullable: true
        settlement:
          type: object
          nullable: true
          properties:
            settlement__status:
              type: string
              nullable: true
            settlement__settlement_number:
              type: string
              nullable: true
            settlement__is_sent:
              type: boolean
              nullable: true
    OrderFullBatchOrder:
      type: object
      nullable: true
      properties:
        invoice_number:
          type: string
          nullable: true
        is_sent:
          type: boolean
          nullable: true
        batch:
          type: object
          nullable: true
          properties:
            batch_number:
              type: string
              nullable: true
            status:
              type: string
              nullable: true
    OrderDocument:
      type: object
      properties:
        file_type:
          type: string
          example: rate_confirmation
          description: >-
            Type of document: rate_confirmation, bill_of_lading,
            proof_of_delivery, commercial_invoice.
        file_link:
          type: string
          format: uri
          example: https://storage.example.com/docs/rc-12345.pdf
          description: URL to the document file.
        uploaded_by:
          type: string
          nullable: true
          example: John Doe
          description: Full name of the user who uploaded the document.
        uploaded_at:
          type: string
          format: date-time
          example: '2025-02-06T12:00:00Z'
          description: Timestamp when the document was uploaded.
      required:
        - file_type
        - file_link
        - uploaded_at
    StopLocation:
      type: object
      properties:
        id:
          type: integer
        company:
          type: string
          nullable: true
        address1:
          type: string
          nullable: true
        address2:
          type: string
          nullable: true
        city:
          type: string
          nullable: true
        state:
          type: string
          nullable: true
        zip_code:
          type: string
          nullable: true
        contact_name:
          type: string
          nullable: true
        place_name:
          type: string
          nullable: true
        latitude:
          type: number
          format: float
          nullable: true
          example: 33.749
        longitude:
          type: number
          format: float
          nullable: true
          example: -84.388
        is_active:
          type: boolean

````