Standard API Response Object
All API responses follow a consistent structure to ensure clarity and predictability for clients interacting with the API. The response object includes several key fields that provide valuable information about the status of the request, any relevant data, and potential errors that occurred during processing.
The status
field indicates whether the request was successfully processed, with values of either "success"
or "failure"
. In the case of success, the message
field will contain a descriptive statement confirming the action taken (e.g., "Shipment created successfully"). If an error occurs, the message
will provide a brief explanation of the failure, while the errors
field contains a list of more detailed error messages. This can help clients pinpoint specific issues, such as validation errors or missing fields.
In addition to status and message, the data
field will contain the same object that was submitted in the request (for successful operations). The correlationId
provides a unique identifier for each request, which is useful for logging and troubleshooting. Finally, the timestamp
field records the exact date and time at which the request was received and processed, ensuring that each response is traceable and easy to audit.
This response structure provides a consistent format across all API endpoints, ensuring that responses are predictable and easy to work with.
Here is a detailed description of each field in this standard response object:
status
(string): Indicates whether the request was successful or failed. Possible values:
-
"success"
: The request was processed successfully."failure"
: The request failed due to an error.
-
message
(string): A human-readable statement describing the result of the request. For example:"Shipment created successfully."
"Invalid request parameters."
-
data
(object, optional): Contains the data object that was submitted to the API in case of a successful request. For example, when creating a shipment, this will return the sameShipmentDto
object. -
errors
(array of strings, optional): A list of detailed error messages, provided when the request fails. -
correlationId
(string): A unique identifier assigned to the request for tracking purposes. This is useful for troubleshooting or auditing and will be generated for every request, whether successful or not. -
timestamp
(string): The date and time when the request was received and processed. The format isISO 8601
, for example:"2024-09-01T10:15:30Z"
.
Updated 8 months ago