FlatPeak uses HTTP status codes to indicate the success or failure of API requests. This includes:

CodeDescription
2XXIndicates success.
4XXIndicates an invalid request.
5XXindicates FlatPeak-related issues.

Error object

When an error needs to be returned in API response, FlatPeak uses a standardised error object across all endpoints:

{
  "object": "error",
  "live_mode": false,
  "context": "connect.postal_address_capture",
  "type": "invalid_request",
  "code": "country_code_missing",
  "message": "Country code is required",
  "connect_token": "cot_6587fa4362341be5b524de3b",
  "time_created": "2022-01-24T14:15:22.003"
}
FieldDescription
objectIndicates API object type, i.e. error.
live_modeIndicates if live or test mode API key was used.
contextIndicates error context. It provides information on which service and method has errored. For example, connect.postal_address_capture or api.location_create.
typeIndicates error type; possible values are invalid_request - when your request is invalid. And api_error when the FlatPeak service cannot process the request (these are rare).
codeConnect-related error codes are listed in connect-headless guide under code sample of every page. API-related error codes are listed in the API error codes table later on this page. Example: country_code_missing.
messageError description in the English language. Example: Country code is required.
connect_tokenThe Connect token used to make the request resulted in an error.
time_createdTimestamp when this error has occurred.

Connect Error codes

Connect-related error codes are found in the connect-headless guide under page code samples.

API Error codes

ContextCodeMessage
api.connect_token_createtariff_direction_invalidDirection parameter must be EXPORT or IMPORT
api.connect_token_createtariff_direction_not_supportedDirection LOCAL (beta) is not supported for your account
api.connect_token_createtariff_type_invalidTariff type must be COMMODITY or NON_COMMODITY
api.connect_token_createtariff_type_not_supportedTariff type NON_COMMODITY is not supported for EXPORT direction
api.connect_token_createcallback_uri_missingCallback URI is required
api.connect_token_createcallback_uri_invalidCallback URI XX is invalid
api.connect_token_createconnect_web_uri_invalidConnect web URI XX is invalid
api.connect_token_createobject_lookup_conflictSpecify customer_id or customer_reference_id, but not both
api.connect_token_createobject_lookup_conflictSpecify location_id or location_reference_id, but not both
api.connect_token_createobject_lookup_conflictSpecify customer_id or location_id, but not both
api.connect_token_createobject_lookup_conflictSpecify tariff_id or customer_reference_id, but not both
api.connect_token_createobject_lookup_conflictSpecify tariff_id or location_reference_id, but not both
api.connect_token_createtariff_not_foundTariff ID trf_XX not found
api.connect_token_createlocation_not_foundLocation ID loc_XX not found
api.connect_token_createcustomer_not_foundCustomer ID cus_XX not found
api.connect_token_createreference_id_mismatchThe customer_reference_id XX does not match location_reference_id YY
api.location_createcustomer_not_foundCustomer ID cus_XX not found
api.location_createaddress_line1_missingFirst line of address is required
api.location_createcity_missingCity name is required
api.location_createpost_code_missingPostal (zip) code is required
api.location_createcountry_code_missingCountry code is required
api.location_createcountry_code_invalidCountry code must be two-letter in ISO 3166-1 alpha-2
api.location_createtimezone_not_foundUnable to detect timezone using postal address provided, include at least country and city
api.location_updatecustomer_not_foundCustomer ID cus_XX not found
api.location_updateaddress_line1_missingFirst line of address is required
api.location_updatecity_missingCity name is required
api.location_updatepost_code_missingPostal (zip) code is required
api.location_updatecountry_code_missingCountry code is required
api.location_updatecountry_code_invalidCountry code must be two-letter in ISO 3166-1 alpha-2
api.location_updatetimezone_not_foundUnable to detect timezone using postal address provided, include at least country and city
api.tariff_createtariff_direction_invalidDirection parameter must be EXPORT or IMPORT
api.tariff_createtariff_direction_not_supportedDirection LOCAL is not supported for your account
api.tariff_createtariff_type_invalidTariff type must be COMMODITY or NON_COMMODITY
api.tariff_createtariff_type_not_supportedTariff type NON_COMMODITY is not supported for EXPORT direction
api.tariff_createcontract_start_date_missingThe contract start date must be provided
api.tariff_createcontract_end_date_missingThe contract end date must be provided
api.tariff_createcontract_end_date_invalidContract end date must not be in the past
api.tariff_createcontract_period_mismatchContract start date must not be after the end date
api.tariff_createmonth_invalidSpecified month parameter XX is invalid
api.tariff_createmonth_duplicatedSpecified month parameter XX is duplicated
api.tariff_createparameter_mismatchTime period mismatch, valid_from is YY and valid_to is XX
api.tariff_createday_is_invalidSpecified parameter day XX is invalid
api.tariff_createday_is_duplicatedSpecified parameter day XX is duplicate
api.tariff_createvalid_from_invalidTime period start must be in format HH:mm:ss
api.tariff_createvalid_to_invalidTime period end must be in format HH:mm:ss
api.tariff_creategap_found_in_time_periodGap between XX and YY is found in time period provided
api.tariff_createincomplete_time_periodTime period must cover full 24 hours
api.tariff_createlocation_not_foundLocation ID loc_XX not found
api.tariff_createprovider_not_foundProvider ID prv_XX not found
api.*unhandled_errorAn error has occurred, but a specific error code is not available
api.*account_disabledYour account is disabled

Account disabled error

When your account is out of subscription or is disabled for any other reason, you will receive an error 422 when trying to access any of the API endpoints.

{
  "object": "error",
  "live_mode": true,
  "context": "api.tariff_create",
  "type": "api_error",
  "code": "account_disabled",
  "message": "Your account is disabled",
  "time_created": "2024-05-16T17:41:50Z",
}

When it happens, open Dashboard and go to Settings > Billing to restore your subscription.