Error Codes & Handling

How errors can be recognized, understood and resolved.

Error Handling in CargoFP API

All errors from the CargoFP API follow a standard JSON structure. Errors are grouped into Validation Errors, Client Errors, and Server Errors.


Error Response Structure

{
  "type": "<error_type>",
  "errors": [
    {
      "code": "<error_code>",
      "detail": "<error_description>",
      "attr": "<request_attribute>"
    }
  ]
}
  • type can be validation_error, client_error, or server_error
  • errors is an array of error objects
  • code is a short error identifier
  • detail is a descriptive message
  • attr is the field associated with the error (or non_field_errors for global issues)

Example: Unknown Port

{
  "type": "validation_error",
  "errors": [
    {
      "code": "unknown_port",
      "detail": "Port is unknown.",
      "attr": "departure_port"
    }
  ]
}

Error Types & Details

Validation Errors

CodeDetailAttribute
requiredField is requiredAny field
min_valueMust be ≥ 0cargo_weight_mt
unknown_portPort is unknowndeparture_port_code, arrival_port_code, departure_port_name, arrival_port_name
same_portsDeparture and arrival cannot be the samenon_field_errors
arrival_before_departureArrival must be after departurenon_field_errors
ship_not_availableShip not in databasenon_field_errors
ship_data_not_availableMissing required ship datanon_field_errors
ship_type_not_acceptedShip type not allowednon_field_errors
new_shipShip too new for emission calculationnon_field_errors
emission_data_not_availableNo emissions data for voyagenon_field_errors
distance_not_availableDistance between ports not availablenon_field_errors
incorrect_number_of_digitsIMO number must have 7 digitsimo_number
invalid_imo_numberCheck of the IMO number via check mechanism resulted in invalidimo_number

Client Errors

HTTP CodeCodeDetail
400parse_errorMalformed request
401authentication_failedInvalid credentials
401not_authenticatedNo auth token provided
403permission_deniedNot allowed to access resource
404not_foundResource not found
405method_not_allowedHTTP method not allowed
406not_acceptableAccept header not satisfied
415unsupported_media_typeOnly application/json is supported
429throttledRate limit exceeded

Server Errors

HTTP CodeCodeDetail
500errorInternal server error
503service_unavailableService is temporarily unavailable