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

# Search jobs

> Run rich filtered searches across jobs using POST /dn/jobs/search. Supports date ranges, status filters, groups, vehicles, and item-level criteria.

The search endpoint lets you query jobs with many optional filters, including date ranges, statuses, groups, vehicles, and item-level criteria. Results are paginated and include `links` with `next` and `prev` URLs for easy navigation through large result sets.

For what `status`, `primary_job_status`, and `tracking_status` mean, see [Status fields](/concepts/jobs#status-fields).

## Pagination

Send `page`, `limit`, and `sort` as **query parameters**, for example `POST /dn/jobs/search?page=2&limit=50`. They aren't read from inside `data`. The response includes `links.next` and `links.prev` when there are more pages.

For listing jobs without filters, see [List jobs](/api-reference/jobs/list). For retrieving a single job by DO number, see [Retrieve job](/api-reference/jobs/retrieve).


## OpenAPI

````yaml POST /dn/jobs/search
openapi: 3.0.3
info:
  title: Detrack REST API v2
  version: '2.0'
  description: >-
    Detrack REST API v2. Checked against detrack-webapp origin/main (production)
    on 2026-09-29: dn_jobs.rb @ d246ad006, dn_depots.rb @ 2a5f387, dn_routes.rb
    @ 50a73a9, app_helper.rb @ d745ad2, dn_jobs_helper.rb @ d296e30,
    job_decorator.rb @ 3041da7, run_location_decorator.rb @ 0f0274d,
    vehicle_route_plan_decorator.rb and tsp_route_decorator.rb @ 7d1f3ef,
    data_export.rb @ ed4e135.
servers:
  - url: https://app.detrack.com/api/v2
security:
  - apiKey: []
tags:
  - name: Jobs
    description: Deliveries and collections.
  - name: Depots
    description: Saved warehouse and pickup locations.
  - name: Routes
    description: Optimized multi-stop plans across vehicles.
paths:
  /dn/jobs/search:
    post:
      tags:
        - Jobs
      summary: Search jobs
      description: >-
        Searches jobs using the filters in `data`. Pagination and sorting aren't
        part of `data`: send `page`, `limit`, and `sort` as query parameters.
        Filters on job and item fields only apply if they're enabled in your
        account's job search settings; other filters are ignored without an
        error. `data` is optional: without it, all jobs are returned, newest
        first.
      operationId: searchJobs
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/Limit'
        - name: sort
          in: query
          schema:
            type: string
          description: >-
            Comma-separated fields to sort by. Prefix a field with `-` for
            descending, for example `-created_at`. Allowed: `do_number`,
            `start_date`, `date`, `created_at`, `assign_to`, `status`,
            `job_sequence`, `job_time`, `customer`. Other fields are ignored.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - Delivery
                        - Collection
                    do_number:
                      type: string
                    do_numbers:
                      type: array
                      items:
                        type: string
                    dates:
                      type: object
                      properties:
                        from:
                          type: string
                          format: date
                        to:
                          type: string
                          format: date
                    start_dates:
                      type: object
                      properties:
                        from:
                          type: string
                          format: date
                        to:
                          type: string
                          format: date
                    statuses:
                      type: array
                      items:
                        type: string
                    reasons:
                      type: array
                      items:
                        type: string
                      example:
                        - No Recipient
                    groups:
                      type: array
                      items:
                        type: object
                        properties:
                          name:
                            type: string
                    vehicles:
                      type: array
                      items:
                        type: object
                        properties:
                          name:
                            type: string
                    customer:
                      type: string
                    department:
                      type: string
                    invoice_number:
                      type: string
                    address:
                      type: string
                    deliver_to_collect_from:
                      type: string
                    order_number:
                      type: string
                    tracking_number:
                      type: string
                    zone:
                      type: string
                    run_number:
                      type: string
                    account_number:
                      type: string
                    contractor_groups:
                      type: array
                      items:
                        type: object
                        properties:
                          name:
                            type: string
                    customer_eq:
                      type: string
                      description: Exact customer name.
                    sku:
                      type: string
                      description: Item SKU.
                    item_description:
                      type: string
                    item_batch_number:
                      type: string
                    item_purchase_order_number:
                      type: string
                    item_serial_numbers:
                      type: string
                    item_reasons:
                      type: array
                      items:
                        type: string
                    source:
                      type: string
                    job_type:
                      type: string
                    job_time:
                      type: string
                    time_window:
                      type: string
                    serial_number:
                      type: string
                    open_to_marketplace:
                      type: boolean
            example:
              data:
                type: Delivery
                dates:
                  from: '2026-09-01'
                  to: '2026-09-30'
                groups:
                  - name: Detrack
      responses:
        '200':
          description: Matching jobs.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Job'
                  links:
                    $ref: '#/components/schemas/Links'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        default:
          $ref: '#/components/responses/ServerError'
components:
  parameters:
    Page:
      name: page
      in: query
      schema:
        type: integer
        default: 1
      description: Page number.
    Limit:
      name: limit
      in: query
      schema:
        type: integer
        default: 25
      description: Records per page. The API doesn't cap it, but keep it to 100 or fewer.
  schemas:
    Job:
      type: object
      description: >-
        A delivery or collection job. Only the most-used fields are listed; the
        API returns more.
      properties:
        id:
          type: string
          example: 5b22055510c92b1a046ece04
        type:
          type: string
          enum:
            - Delivery
            - Collection
          example: Delivery
        do_number:
          type: string
          example: DO-10001
        date:
          type: string
          format: date
          example: '2026-09-15'
        status:
          type: string
          description: >-
            Lifecycle status. Use this in integration logic. See [Status
            fields](/concepts/jobs#status-fields).
          example: dispatched
        primary_job_status:
          type: string
          description: Same value as `status`.
          example: dispatched
        tracking_status:
          type: string
          description: >-
            Customer-facing label, which can be customised per account. Don't
            use it in integration logic.
          example: Info received
        attempt:
          type: integer
          example: 1
        detrack_number:
          type: string
          example: DET2000001
        tracking_number:
          type: string
          nullable: true
          example: T0
        order_number:
          type: string
          nullable: true
          example: ORN12345678
        address:
          type: string
          example: Singapore 470140
        postal_code:
          type: string
          nullable: true
          example: '470140'
        deliver_to_collect_from:
          type: string
          nullable: true
          example: James Li
        phone_number:
          type: string
          nullable: true
          example: '65432178'
        notify_email:
          type: string
          nullable: true
          example: test@example.com
        items_count:
          type: integer
          example: 2
        created_at:
          type: string
          format: date-time
          example: '2026-09-15T06:04:06.017Z'
        items:
          type: array
          items:
            $ref: '#/components/schemas/Item'
        milestones:
          type: array
          items:
            $ref: '#/components/schemas/Milestone'
    Links:
      type: object
      properties:
        first:
          type: string
          nullable: true
        last:
          type: string
          nullable: true
        next:
          type: string
          nullable: true
        prev:
          type: string
          nullable: true
    Item:
      type: object
      properties:
        id:
          type: string
          readOnly: true
          example: 5b22055510c92b1a046ece05
        sku:
          type: string
          example: '12345678'
        description:
          type: string
          nullable: true
          example: iPad
        quantity:
          type: number
          example: 10
        checked:
          type: boolean
          readOnly: true
          example: false
    Milestone:
      type: object
      properties:
        status:
          type: string
          example: info_recv
        assign_to:
          type: string
          nullable: true
          example: null
        reason:
          type: string
          nullable: true
          example: null
        pod_at:
          type: string
          format: date-time
          example: '2026-09-15T06:04:06.017Z'
        created_at:
          type: string
          format: date-time
          example: '2026-09-15T06:04:06.017Z'
        user_name:
          type: string
          example: Simon
    Error:
      type: object
      properties:
        code:
          type: string
          example: not_found
        message:
          type: string
          example: Could not find job with this DO number
  responses:
    BadRequest:
      description: The request body isn't valid JSON.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: invalid_json_format
    Unauthorized:
      description: >-
        The API key is missing or invalid. A missing `X-API-KEY` returns `{
        "error": "Missing Authorization header" }`; an invalid key returns `{
        "code": "invalid_key", "message": "Invalid key" }`.
      content:
        application/json:
          schema:
            oneOf:
              - type: object
                title: Missing key
                required:
                  - error
                properties:
                  error:
                    type: string
                    example: Missing Authorization header
              - type: object
                title: Invalid key
                required:
                  - code
                properties:
                  code:
                    type: string
                    example: invalid_key
                  message:
                    type: string
                    example: Invalid key
          example:
            code: invalid_key
            message: Invalid key
    Forbidden:
      description: Your API key's user doesn't have permission for this action.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: forbidden
          example:
            code: forbidden
    ServerError:
      description: >-
        Unexpected server error. Retry with exponential backoff, and contact
        Detrack support if it persists.
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-KEY
      description: Your Detrack API key, from **Integrations > API Key** in the dashboard.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.