Per-Status Responses
Response schemas and test requests for each HTTP status code
2 min read
The same API can return different responses depending on the situation — result data on success, error details on failure. Layerz lets you define the shape of the response per HTTP status code.
Per-Status Response Schemas
Response schemas are defined per status code (or group of codes).
200— an exact code4XX— a group of codes starting with 4default— everything else not covered above
After a request, only the response matching the status code actually received is parsed into a data structure. Matching happens in the order exact code → code group → default.
The Shape of the Response
The output of the API Call action has the following structure.
HTTPStatusCode— the actual response status codeData— the raw response data- Per-status fields — the response corresponding to the received status is parsed into data here.
Combine this output with Conditions & Branching to handle a 2XX case differently from a 4XX case.
Send Test Request
If defining the response schema by hand is difficult, send a real request once with the Send Test Request button. Based on the returned JSON response, Layerz automatically generates the response schema and maps it to the received status code.
When you import OpenAPI / Swagger, the per-status response schemas declared in the spec are created automatically. When building one yourself, starting with Send Test Request is the fastest way.