logo

The Response Envelope

ConceptUpdated 2026-06-20

Every MultiCartAPI endpoint — success or failure — returns HTTP 200 and wraps its payload in the same three-field envelope. Branch on body.status, never on the HTTP status code.

Envelope structure

{
  "code": 200,
  "data": <payload>,
  "status": 1
}
FieldTypeMeaning
status1 or 01 = success, 0 = failure
codeintegerThe intended HTTP code — 200 on success, or 400 / 402 / 404 / 409 / 500 on failure
dataanyThe response payload on success, or an error message string on failure

The HTTP transport layer always returns 200 OK. The code field is what you would expect from a REST API's HTTP status — use it for error classification after you check status.

Success example

200 OK — success
{
"code": 200,
"data": {
  "id": 101,
  "name": "AU Laptops",
  "status": "enable",
  "request_type": "amazon",
  "schedule": "Daily",
  "created_at": "2026-06-20T03:14:00Z"
},
"status": 1
}

Failure example

A failure response still arrives over HTTP 200. The code carries the intended error class and data contains a human-readable message.

HTTP 200 — failure (insufficient credits)
{
"code": 402,
"data": "Not enough credits — upgrade your plan or wait for your quota to reset.",
"status": 0
}

Common code values on failure:

codeMeaning
400Bad request — missing or invalid field
402Insufficient credits
404Resource not found
409Conflict — duplicate or state violation
500Server error

Two endpoints return raw bytes, not the envelope

The result-file download endpoint (GET /results/{collection_id}/{runner_id}/{file_name}) and the invoice PDF endpoint (GET /users/payments/{invoice_id}/invoice.pdf) stream raw binary content — application/octet-stream and application/pdf respectively. They have no JSON envelope. Check Content-Type before parsing.

Branching on status in code

Check body.status first. If it is 0, read body.code to classify the error and body.data for the message. Never rely on response.status (the HTTP transport code) for business logic.

const resp = await fetch(
"https://multicartapi.com/api/v1/schedules/run/result/",
{
  method: "POST",
  headers: {
    "x-api-key": "YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ collection_id: 101 }),
}
);

// HTTP transport is always 200 — parse the envelope instead
const body = await resp.json();

if (body.status === 1) {
console.log("Success:", body.data);
} else {
// body.code holds the intended HTTP error class
if (body.code === 402) {
  console.error("Insufficient credits:", body.data);
} else {
  console.error(`API error [${body.code}]:`, body.data);
}
}