Working with API
API Errors
FlatPeak uses HTTP status codes to indicate the success or failure of API requests. This includes:
Code | Description |
---|---|
2XX | Indicates success. |
4XX | Indicates an invalid request. |
5XX | indicates 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"
}
Field | Description |
---|---|
object | Indicates API object type, i.e. error . |
live_mode | Indicates if live or test mode API key was used. |
context | Indicates error context. It provides information on which service and method has errored. For example, connect.postal_address_capture or api.location_create . |
type | Indicates 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). |
code | Connect-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 . |
message | Error description in the English language. Example: Country code is required . |
connect_token | The Connect token used to make the request resulted in an error. |
time_created | Timestamp 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
Context | Code | Message |
---|---|---|
api.connect_token_create | tariff_direction_invalid | Direction parameter must be EXPORT or IMPORT |
api.connect_token_create | tariff_direction_not_supported | Direction LOCAL (beta) is not supported for your account |
api.connect_token_create | tariff_type_invalid | Tariff type must be COMMODITY or NON_COMMODITY |
api.connect_token_create | tariff_type_not_supported | Tariff type NON_COMMODITY is not supported for EXPORT direction |
api.connect_token_create | callback_uri_missing | Callback URI is required |
api.connect_token_create | callback_uri_invalid | Callback URI XX is invalid |
api.connect_token_create | connect_web_uri_invalid | Connect web URI XX is invalid |
api.connect_token_create | object_lookup_conflict | Specify customer_id or customer_reference_id, but not both |
api.connect_token_create | object_lookup_conflict | Specify location_id or location_reference_id, but not both |
api.connect_token_create | object_lookup_conflict | Specify customer_id or location_id, but not both |
api.connect_token_create | object_lookup_conflict | Specify tariff_id or customer_reference_id, but not both |
api.connect_token_create | object_lookup_conflict | Specify tariff_id or location_reference_id, but not both |
api.connect_token_create | tariff_not_found | Tariff ID trf_XX not found |
api.connect_token_create | location_not_found | Location ID loc_XX not found |
api.connect_token_create | customer_not_found | Customer ID cus_XX not found |
api.connect_token_create | reference_id_mismatch | The customer_reference_id XX does not match location_reference_id YY |
api.location_create | customer_not_found | Customer ID cus_XX not found |
api.location_create | address_line1_missing | First line of address is required |
api.location_create | city_missing | City name is required |
api.location_create | post_code_missing | Postal (zip) code is required |
api.location_create | country_code_missing | Country code is required |
api.location_create | country_code_invalid | Country code must be two-letter in ISO 3166-1 alpha-2 |
api.location_create | timezone_not_found | Unable to detect timezone using postal address provided, include at least country and city |
api.location_update | customer_not_found | Customer ID cus_XX not found |
api.location_update | address_line1_missing | First line of address is required |
api.location_update | city_missing | City name is required |
api.location_update | post_code_missing | Postal (zip) code is required |
api.location_update | country_code_missing | Country code is required |
api.location_update | country_code_invalid | Country code must be two-letter in ISO 3166-1 alpha-2 |
api.location_update | timezone_not_found | Unable to detect timezone using postal address provided, include at least country and city |
api.tariff_create | tariff_direction_invalid | Direction parameter must be EXPORT or IMPORT |
api.tariff_create | tariff_direction_not_supported | Direction LOCAL is not supported for your account |
api.tariff_create | tariff_type_invalid | Tariff type must be COMMODITY or NON_COMMODITY |
api.tariff_create | tariff_type_not_supported | Tariff type NON_COMMODITY is not supported for EXPORT direction |
api.tariff_create | contract_start_date_missing | The contract start date must be provided |
api.tariff_create | contract_end_date_missing | The contract end date must be provided |
api.tariff_create | contract_end_date_invalid | Contract end date must not be in the past |
api.tariff_create | contract_period_mismatch | Contract start date must not be after the end date |
api.tariff_create | month_invalid | Specified month parameter XX is invalid |
api.tariff_create | month_duplicated | Specified month parameter XX is duplicated |
api.tariff_create | parameter_mismatch | Time period mismatch, valid_from is YY and valid_to is XX |
api.tariff_create | day_is_invalid | Specified parameter day XX is invalid |
api.tariff_create | day_is_duplicated | Specified parameter day XX is duplicate |
api.tariff_create | valid_from_invalid | Time period start must be in format HH:mm:ss |
api.tariff_create | valid_to_invalid | Time period end must be in format HH:mm:ss |
api.tariff_create | gap_found_in_time_period | Gap between XX and YY is found in time period provided |
api.tariff_create | incomplete_time_period | Time period must cover full 24 hours |
api.tariff_create | location_not_found | Location ID loc_XX not found |
api.tariff_create | provider_not_found | Provider ID prv_XX not found |
api.* | unhandled_error | An error has occurred, but a specific error code is not available |
api.* | account_disabled | Your 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.
Was this page helpful?