Skip to main content
POST
Barcode Scan decodes an uploaded image and checks the extracted value for suspicious content. It reads Code 128/39/93, Codabar, ITF, EAN-8/13, and UPC-A/E barcodes.

Authentication

Send your API key as Authorization: Bearer enc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.

Request

string
required
Set this value to bar.
file
The barcode image to scan, uploaded as multipart/form-data. Send this field or content_base64. When you omit filename, the uploaded file’s name is used. Prefer this for large images: it’s about a third smaller than base64.
string
For a JSON body, send this field or file. The base64-encoded barcode image. Send raw base64 only. A data URL prefix such as data:image/png;base64, returns 400.
string
The original image file name. Encrata checks it against the real file type: a PNG named invoice.pdf, or a name that hides an executable behind an image extension (scan.png.exe), raises a signal.
boolean
Set to true to include STIX 2.1 output when available. Defaults to false.
The image can be PNG, JPEG, GIF, WebP, BMP, or TIFF, up to 10 MB and 50 megapixels. Barcodes are read upright, upside down, tilted, or turned 90°, and every barcode in the image is returned.

Example request

Upload the barcode image from disk as multipart/form-data. Replace barcode.png with the path to your barcode image.
To send JSON instead, base64-encode the barcode image into content_base64:

Example response

A scan of a Code 128 barcode:

How the verdict is decided

Each barcode gets its own verdict from the value it holds. The scan’s verdict is the worst of its barcodes and the image’s own signals, such as a misleading file name. Text that looks like SQL or script injection isn’t flagged.

Barcode result fields

A bar result has the common fields plus sha256, image, and codes.
integer
Credits this scan charged: 1 per barcode found, or 0 when you scanned the same image before.
object
The uploaded image: format, width, height, size_bytes, detected_type (the real type, read from the file’s bytes), extension (from filename, such as .png), extension_matches, and second_extension (a risky extension hidden before the last one). See QR Code Scan for each field.
object[]
Every barcode decoded from the image. A successful barcode scan always has at least one.Each item has the same shape as a QR Code Scan codes item: format, payload_type, raw, payload, final_url, url_scans, verdict, score, signals, and position (the barcode’s box in image pixels). Barcodes carry no error_correction or sequence.
object[]
code_decode (reading the image) and link_scans (scanning the barcodes’ links, not_applicable when there are none). See Checks and coverage.
object[]
Signals about the image itself. Each item contains source, malicious, detail, and optional severity. source is file for the file name, or bar when the image holds more than one barcode (a malicious code can be pasted over a real one).
See Malware Scan for the shared fields: assessment, recommended_action, confidence_reason, coverage, data_flow, duration_ms, and iocs.

When no barcode is found

If the image has no readable barcode, the scan returns 422 with result.code set to validation_failed, and no scan result. message says why when it can tell: the image is too small (the thinnest bars need to be at least 2 pixels wide), or too blurry. Otherwise the barcode may be cropped or partly covered.
A QR code sent as bar also returns 422. Send it as kind: qr.

Errors

Errors use the same envelope as successful responses, with success set to false. Branch on result.code. message is a sentence you can show to users. The response panel shows an example of each status. Errors aren’t charged.

Credits

A scan costs 1 credit for each barcode it decodes: an image with two barcodes costs 2 credits. Scanning the same image again is free and returns credits: 0.