Container OCR API ISO 6346 Shipping Container Number Extraction

Streamline your logistics and port operations with our Container OCR API. We provide highly accurate extraction of the standard 11-character ISO 6346 shipping container numbers from images. The engine automatically parses the owner code (BIC), equipment category, serial number, and check digit, performing strict mathematical validation to ensure absolute data reliability for your Terminal Operating Systems (TOS) or yard management workflows.

  • Port Automation
  • Freight Tracking
  • Yard Management

Endpoint

POSThttps://api.structocr.com/v1/container

Request Parameters

Important: This endpoint requires application/json Content-Type. Images must be sent as Base64 strings.

ParameterInRequiredDescription
x-api-keyHeaderRequiredYour unique API key generated from the dashboard.
Content-TypeHeaderRequiredMust be set to application/json.
imgBody (JSON)RequiredThe Base64 encoded string of the shipping container image.
  • Supports standard Data URI (e.g., data:image/jpeg;base64,...)
  • Supports raw Base64 strings
  • Max file size: 4.5MB
  • Formats: JPG, PNG, WebP

Response Schema

The following fields are extracted into the data object. The engine automatically separates the standard ISO 6346 components.

FieldDescription
container_numberThe full 11-character ISO 6346 container identification sequence.
is_validBoolean indicating if the check digit math validates correctly against the ISO 6346 standard algorithm.
confidenceThe confidence level of the recognition (High, Medium, Low).
parsed.owner_codeThe 3-letter Owner Code (BIC code) identifying the principal operator.
parsed.categoryThe 1-letter Equipment Category Identifier (typically 'U' for freight containers, 'J', or 'Z').
parsed.serial_numberThe 6-digit Serial Number assigned by the owner.
parsed.check_digitThe 1-digit Check Digit used to validate the entire container number.

Code Examples

Request Implementation

curl -X POST https://api.structocr.com/v1/container \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "img": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
  }'

Success Response (200 OK)

JSON EXAMPLE
{
  "success": true,
  "data": {
    "container_number": "ZCSU8921655",
    "is_valid": true,
    "confidence": "High",
    "parsed": {
      "owner_code": "ZCS",
      "category": "U",
      "serial_number": "892165",
      "check_digit": "5"
    }
  }
}

Error Responses

400 Bad Request - Invalid Input

Returned when JSON is invalid or image data is missing/corrupt.

{
  "status": 400,
  "code": "INVALID_REQUEST_FORMAT",  
  // or "INVALID_JSON", "INVALID_BASE64_FORMAT"
  "message":"The image data in 'img' field is malformed. Please check for illegal characters (spaces, newlines) or incorrect Base64 encoding."
}

402 Payment Required - Insufficient Credits

{
  "status": 402,
  "code": "INSUFFICIENT_CREDITS",
  "message": "Your account balance is insufficient to complete this operation."
}

413 Payload Too Large

The Base64 decoded image size exceeds 4.5MB.

{
  "error": "FILE_TOO_LARGE"
}

415 Unsupported Media Type

{
  "error": "INVALID_CONTENT_TYPE_USE_JSON"
}

422 Unprocessable Entity - Policy Violation

{
  "status": 422,
  "code": "CONTENT_POLICY_VIOLATION",
  "message": "The document content could not be processed due to safety policies."
}

500 Internal Server Error

{
  "status": 500,
  "code": "PROCESSING_ERROR",
  "message": "An internal error occurred while processing the document..."
}

503 Service Unavailable - System Busy

{
  "status": 503,
  "code": "SYSTEM_BUSY",
  "message": "StructOCR is currently processing a high volume of requests..."
}

Status Code Definitions

CodeError CodeDescription
200SUCCESSRecognition success
400INVALID_REQUEST_FORMATInvalid payload or corrupted Base64. Ensure the image string has no whitespace, newlines, or illegal characters.
402INSUFFICIENT_CREDITSAccount balance too low
413FILE_TOO_LARGEDecoded image exceeds 4.5MB
415INVALID_CONTENT_TYPENot using application/json
422CONTENT_POLICY_VIOLATIONAI safety/policy block
503SYSTEM_BUSYAPI Rate limit reached