Response Property Details
To build advanced logical flows and conditional tests, you can directly access the raw HTTP response object returned from the API call.
Accessing Response
ab.response— A direct property exposing the native payload object.
ts
const res = ab.response;
// Read the native status code
if (res.status === 201) {
ab.expect("Created Successfully").toBeOK();
}
// Read the native body payload directly
const totalCount = res.body.metadata.total;
if (totalCount > 100) {
ab.print("High traffic detected", totalCount);
}
// Read native headers
const isJson = res.headers["content-type"]?.includes("application/json");The Response Interface
The response exposes the exact standard properties returned from ApiBolt runner:
ts
export interface ResponseInterface {
body: unknown;
headers: Record<string, unknown>;
cookies?: Array<CookieInterface>;
status: number;
statusText: string;
statusDescription?: string;
requestSize: RequestResponseSizeInterface;
responseSize: RequestResponseSizeInterface;
}
export interface CookieInterface {
key: string;
value: string;
domain?: string;
path?: string;
secure?: boolean;
httpOnly?: boolean;
hostOnly?: boolean;
maxAge?: number | null;
expires?: string | null;
sameSite?: "lax" | "strict" | "none";
creation?: string;
lastAccessed?: string;
}
export interface RequestResponseSizeInterface {
header: number;
body: number;
}