1. Inferences
  2. Bill of Lading Inference

Inferences

Bill of Lading Inference

You can have the inference via the API or the vision-SDK while the vision-SDK will do the network request for you, the responses from this document will remain the same.

New Inference

POST
`/v0/ai/inferences/images/bills-of-lading`

To create a new inference for bill of lading, you'll need to pass the image as a base64 encoded data URL or public web URL. There's a soft cap of about 7.5MB per image for the base64 URL.

You're also able to specify what type of image the parser is looking at, so it can better extract data accurately along with other helpful information listed below:

image string (required)
Base64 encoded image.

barcode_values Array.<String>
Any existing values you've already extracted from the barcode.

location_id String
The ID of the location you want to attribute to this scan.

options Object
Option contains different other optional parameters you can provide along with the image. Those parameters are described below

Show Details

custom_attributes Array.<String>

This parameter allows you to provide custom attributes as an array of strings.
Each string can be a maximum of 127 characters, and the array can contain up to 25 elements.
Duplicate attributes (case-insensitive) will be removed, and the final array will retain the original casing of the first occurrence.
If omitted, the default value is an empty array.

match Object
All the options associated with matching logic.

These parameters are required only if matching is used.

Show Details
Parameter Type Description
search_in Object Includes the following fields: invoice_number, order_number, purchase_order_number, reference_number, customer_purchase_order_number, container_number, load_number. Each field is a boolean and at least one of these must be set to true must be set to true to include in the matching process.
search_type string Specifies the type of search to perform. Can be match_some or match_all. match_some will return all manifests that match any of the fields specified in search_in, while match_all will only return the manifests that return all of the specified fields.


For example,

js
        const data = {
  image: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASA...", //truncated
  location_id: null, //You an optionally pass the location ID to later filter scans by location
  options: {
    match: {
      search_in: {
        invoice_number: true,
        order_number: true,
        purchase_order_number: true,
        reference_number: true,
        customer_purchase_order_number: true,
        container_number: true,
        load_number: false,
      },
      search_type: "match_some",
    },
  },
};

const res = await fetch("https://api.packagex.io/v0/ai/inferences/images/bills-of-lading", {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

const scan = response.data;

      

List Bill of Lading Inferences

GET
`/v0/ai/inferences/images/bills-of-lading`

Retrieve a paginated list of Bill of Lading inferences for your organization. Results are returned in descending order by default, meaning the most recently created inference appears first.

Query Parameters

Parameter Type Description
page Number The page number for pagination. Defaults to 1.
limit Number The number of results per page. Defaults to 10.
order_by String The field to order results by. Supported value: created_at. Defaults to created_at.
direction String Sort direction. Can be asc or desc. Defaults to asc.
location_id String Filter inferences by a specific location ID.
statuses String Comma-separated list of statuses to filter by. Possible values include inferring, inferred, matched, completed, canceled, error, inference_error.
search String A search term to perform full-text search across inferences. Minimum 2 characters, maximum 255 characters.
search_strategy String The search matching strategy. Can be match_some or match_all.
metadata Object Filter by metadata key-value pairs.

Pagination

The response includes a pagination object. If has_more is true, there are additional inferences not yet returned. Use the page and limit query parameters to paginate through results. The total_count property returns the total number of inferences matching your query.

js
        const response = await fetch("https://api.packagex.io/v0/ai/inferences/images/bills-of-lading?page=1&limit=25", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const inferences = response.data;
const pagination = response.pagination;

      

Filtering by Location

js
        const response = await fetch("https://api.packagex.io/v0/ai/inferences/images/bills-of-lading?location_id=loc_abc123", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const inferences = response.data;

      

Filtering by Status

js
        const response = await fetch("https://api.packagex.io/v0/ai/inferences/images/bills-of-lading?statuses=completed,inferred", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const inferences = response.data;

      

Retrieve Bill of Lading Inference

GET
`/v0/ai/inferences/images/bills-of-lading/:inference_id`

Retrieve a single Bill of Lading inference by its ID.

Parameter Type Description
inference_id String The ID of the Bill of Lading inference to retrieve. Must start with inf_bol_.
js
        const response = await fetch("https://api.packagex.io/v0/ai/inferences/images/bills-of-lading/inf_bol_abc123", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const scan = response.data;

      

Update Bill of Lading Inference

POST
`/v0/ai/inferences/images/bills-of-lading/:inference_id`

Update an existing Bill of Lading inference. You can modify the inferred data, set the status, or update metadata. At least one property must be provided in the request body.

Parameter Type Description
inference_id String The ID of the Bill of Lading inference to update. Must start with inf_bol_.

Body Parameters

Parameter Type Description
status String Set the inference status. Allowed values: completed, canceled. completed can only be set on inferred or matched statuses. canceled can only be set on error status.
metadata Object Custom key-value metadata to attach to the inference. Set to null to clear all metadata.
inference Object The inference data to update. At least one property is required within this object.
Inference Object Properties
Parameter Type Description
sender Object Sender contact details (name, email, phone, business, contact_id, address).
transit Object Transit/middle-mile contact details.
recipient Object Recipient contact details.
barcode_values Array.<String> Barcode values extracted from or associated with the BOL. Set to null to clear.
logistics_attributes Object Logistics-related fields for the BOL.
logistics_attributes.house_bill_of_lading String House bill of lading number.
logistics_attributes.line_bill_of_lading String Line bill of lading number.
logistics_attributes.master_bill_of_lading String Master bill of lading number.
logistics_attributes.invoice_number String Invoice number.
logistics_attributes.order_number String Order number.
logistics_attributes.purchase_order_number String Purchase order number.
logistics_attributes.reference_number String Reference number.
logistics_attributes.customer_purchase_order_number String Customer purchase order number.
logistics_attributes.container_number String Container number.
logistics_attributes.load_number String Load number.
logistics_attributes.shipping_id String Shipping ID.
logistics_attributes.shipping_date Object Shipping date with year, month, and day properties.
custom_attributes Object Key-value pairs for custom attributes. Keys max 127 chars, values max 511 chars. Set to null to clear.
tables Array Array of arrays of objects representing table data extracted from the BOL. Set to null to clear.

WARNING

Inferences in a processing state (inferring, matching, transforming) cannot be updated. Inferences in a finished state (completed, canceled) can only have their metadata updated.

js
        const data = {
  status: "completed",
  metadata: { warehouse: "east-coast" },
  inference: {
    sender: {
      name: "ACME Corp",
      business: "ACME Corporation",
    },
    logistics_attributes: {
      order_number: "ORD-12345",
      purchase_order_number: "PO-67890",
    },
  },
};

const response = await fetch("https://api.packagex.io/v0/ai/inferences/images/bills-of-lading/inf_bol_abc123", {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

const scan = response.data;

      

Delete Bill of Lading Inference

DELETE
`/v0/ai/inferences/images/bills-of-lading/:inference_id`

Permanently delete a Bill of Lading inference and its associated image. This action cannot be undone.

Parameter Type Description
inference_id String The ID of the Bill of Lading inference to delete. Must start with inf_bol_.
js
        const response = await fetch("https://api.packagex.io/v0/ai/inferences/images/bills-of-lading/inf_bol_abc123", {
  method: "DELETE",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

console.log(response.data); // { success: true }