Skip to main content

API Guidelines

All our API's must always consume and produce application/json.

Response objects

Success response

Structure

type SuccessResponse = {
status: number;
timestamp: number;
data: {[key: string]: any} | {[key: string]: any}[]
// @todo metafields
}

Error response

Structure

type ErrorResponse = {
status: number;
error: string;
timestamp: number;
code: string;
data?: { [key: string]: any } | {[key: string]: any}[];
}

Examples:

Bad Request example
const response: ErrorResponse = {
status: 400,
error: "Bad Request",
timestamp: 1721995731391, // EPOCH Seconds
code: "BR_VALIDATION_ERRORS",
data: {
firstName: {required: true},
email: {required: true},
password: {minLength: 7},
},
}
Internal Server Error example
const response: ErrorResponse = {
status: 500,
timestamp: 1721995731391,
error: "Bad Request",
code: "IR_SERVER_ERROR",
}