1. Scans
  2. Create Scans

Scans

Create Scans

You can create s scan via API or the Vision SDK. While the Vision SDk will do the network requests for you, the responses from this document will remain the same.

New Scan

POST
`/v1/scans`

To create a new scan, you'll need to pass the image_url 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_url string (required)
Base64 encoded data URL.
type "shipping_label","manifest",item,"invoice"
Will default to "shipping_label".
location_id String
The ID of the location you want to attribute to this scan.
metadata Object
Any custom key-value pairs you want to add to this scan.
barcode_values Array.<String>
Any existing values you've already extracted from the barcode.
weight Number
The weight in lbs for this scan, if it was already extracted such as for a shipping label if it was weighed on a scale while taking the scan image.
dimensions.length Number
The length in inches of this scanned item, if it was measured while taking the scan.
dimensions.width Number
The width in inches of this scanned item, if it was measured while taking the scan.
dimensions.height Number
The height in inches of this scanned item, if it was measured while taking the scan.
options.parse_addresses Boolean
If the extracted sender and recipient addresses should be run through the address parser.
options.match_contacts Boolean
If you want the extracted sender and recipient fields to be matched to existing contacts in your organization.
js
        const data = {
  image_url: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASA...", //truncated
  type: "shipping_label", //Other options are "manifest", "item", and "invoice"
  barcode_values: [], //If you have already extracted any barcode values from a shipping label
  location_id: null, //You an optionally pass the location ID to later filter scans by location
  metadata: {}, //Custom key value pairs you can add to the scans object
  options: {
    parse_addresses: true, //Will run the address parser on any addresses that are extracted
    match_contacts: true, //If true will attempt to match contacts the the parsed sender and recipient fields
  },
};

const res = await fetch("https://api.packagex.io/v1/scans", {
  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;