# Search Packages with Custom Header Mapping

This operation returns package records based on the requested custom header mapping. The request body contains package field names as keys and custom header labels as values. These header labels can be used to display the returned package data with user-defined column names.

Endpoint: POST /api/v1/packages/search
Version: 1.0.0
Security: bearerAuth

## Security:

  - `bearerAuth` (unknown)
    http bearer

## Query parameters:

  - `startDate` (string)
    Filter package updated on or after this date.

  - `endDate` (string)
    Filter package updated on or before this date.

  - `page` (integer)
    The page number of the results to retrieve. Pagination starts from 1.

  - `size` (integer)
    The number of assets to retrieve per page.

  - `status` (string)
    Filter assets by status.

  - `sort` (string)
    Specify the sorting order of the results.

  - `inboundSiteId` (string)
    This is the identifier of the Inbound Site to be searched.

## Request body:

  - `application/json` (unknown)
    Defines custom header mappings for package search results.
Each key represents a package response field, and each value represents the custom header label to be used for that field.
The request body is a key-value mapping used to define custom headers for the package search response.
- **Key (Field Name):**
Represents the actual package field from the system.
This can include nested fields using dot notation (for example, `subId`, `packageId`, `currentLocation.name`, `givenTo.name`, `currentRoute.routeName`).
- **Value (Header Label):**
Represents the custom header name for the corresponding field in the response output.

This mapping allows users to control how package data fields are labeled when returned in response.
**Example:**
- `"packageId": "Package Identifier"` → Returns the packageId field as "Package Identifier"
- `"currentLocation.name": "Site Name"` → Returns current location name as "Site Name"
- `deliveryClerk: "Delivered By"` → Returns delivery clerk name as "Delivered By"

**Note:**
- An empty object can be passed.
- If no mappings are provided, the API returns all package fields using their default field names.

## Response 200:

  - `200` (unknown)
    Package details have been retrived successfully.

## Response 200 fields (application/json):

  - `packages` (array)
    Returns package records with fields labeled based on the provided custom header mappings.
Each package object contains dynamic key-value pairs where:
- **Key:** Custom header label defined in the request
- **Value:** Corresponding package field value

If no mappings are provided in the request, the response returns package fields using their default field names.

  - `totalCount` (integer)
    Total number of package records returned.
    Example: 20

## Response 400:

  - `400` (unknown)
    Invalid request.

## Response 400 fields (application/json):

  - `errors` (array)
    List of errors.

  - `errors.errorCode` (string)
    This error can be validation_error or internal_error or not_found or already_exists
    Example: validation_error

  - `errors.errorDescription` (string)
    The HTTP 400 Bad Request response status code indicates that the server cannot process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
    Example: Asset not found.

  - `errors.additionalCode` (string)
    A unique identifier for the error
    Example: 020005

  - `errors.additionalInfo` (string)
    additional information of the error.
    Example: additional information

  - `errors.additionalParameters` (string)
    The field(s) that might be incorrect in the request.
    Example: additional parameters

  - `errors.correlationID` (string)
    Example: correlationId

## Response 401:

  - `401` (unknown)
    The request could not be authorized.

## Response 401 fields (application/json):

  - `message` (string, required)
    This is HTTP 401 Unauthorized response status code, that indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource.

## Response 500:

  - `500` (unknown)
    The request could not be completed due to an internal error.

