# Response status codes, headers and APIkit errors

*MuleSoft Developer Study Guide · Building API Implementation Interfaces · Last updated October 28, 2026 · https://www.certifyforce.com/study-guide/mulesoft-developer/building-api-implementation-interfaces/response-status-codes-headers-and-apikit-errors*

How a Mule API returns the status codes and headers its RAML promises: the HTTP Listener's response and error-response settings, the httpStatus and outboundHeaders variables APIkit scaffolds, the main flow's APIKIT error handler, and hand-built 201 and 503 responses.

- Certification: Salesforce MuleSoft Developer
- Exam section: Building API Implementation Interfaces
- Study guide: https://www.certifyforce.com/study-guide/mulesoft-developer

**Official exam objective:**

> Implement correct responses based on a RAML specification, either manually or with APIkit.

## What the exam expects

- Predict the status code and body an HTTP Listener sends by default on success and on error, and customise them with the Response and Error Response settings.
- Return a RAML-declared status (such as 201) or header (such as `Location`) from a scaffolded APIkit flow with `vars.httpStatus` and `vars.outboundHeaders`.
- Predict what happens when `httpStatusVarName` or `outboundHeadersMapName` is renamed but the listener expressions are not.
- Change the body or status APIkit returns for a router error by editing the main flow's scaffolded error handler.
- Return success and failure statuses (201, 503) from a hand-built listener flow, and know why On Error Propagate rather than On Error Continue is needed.
- Key terms: **response / error-response** (listener settings for successful and failed flow executions); **`httpStatusVarName`** (`apikit:config` attribute naming the status variable, `httpStatus` by default); **`outboundHeadersMapName`** (names the response-headers map variable, `outboundHeaders` by default); **reason phrase** (text after the status code, such as `Created`).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| Listener success default | 200, payload as body | [Configure HTTP Listener Source](https://docs.mulesoft.com/http-connector/latest/http-listener-ref) |
| Listener error default | 500, error description as body | [Configure HTTP Listener Source](https://docs.mulesoft.com/http-connector/latest/http-listener-ref) |
| Customisable response parts | Body, Headers, Status code, Reason phrase | [Configure HTTP Listener Source](https://docs.mulesoft.com/http-connector/latest/http-listener-ref) |
| Status variable default name | `httpStatus` (`httpStatusVarName`) | [Configuring the Response Headers and Status Code](https://docs.mulesoft.com/apikit/latest/configure-headers4-task) |
| Headers map default name | `outboundHeaders` (`outboundHeadersMapName`) | [Configuring the Response Headers and Status Code](https://docs.mulesoft.com/apikit/latest/configure-headers4-task) |
| Scaffolded success status | `#[vars.httpStatus default 200]` | [APIkit for REST Scaffolding Reference](https://docs.mulesoft.com/apikit/latest/apikit-4-scaffolding-reference) |
| Scaffolded error status | `#[vars.httpStatus default 500]`, body `#[payload]` | [APIkit for REST Scaffolding Reference](https://docs.mulesoft.com/apikit/latest/apikit-4-scaffolding-reference) |
| Renamed variable | Update the listener expressions to match | [Configuring the Response Headers and Status Code](https://docs.mulesoft.com/apikit/latest/configure-headers4-task) |
| Router error bodies | Transform in each On Error Propagate of the main flow | [APIkit for REST Scaffolding Reference](https://docs.mulesoft.com/apikit/latest/apikit-4-scaffolding-reference) |
| On Error Continue | Owner completes as if successful | [On-Error Components](https://docs.mulesoft.com/mule-runtime/latest/on-error-scope-concept) |

## Check yourself

- Which four parts of a listener response can you customise?
- Why does an error that never sets `httpStatus` still get a status code from the scaffolded listener?
- When does the scaffolded console flow's error handler run?
- Which `apikit:config` attributes name the response variables, and what are their defaults?

## Sources

- [Configuring the Response Headers and Status Code](https://docs.mulesoft.com/apikit/latest/configure-headers4-task)
- [Configure HTTP Listener Source](https://docs.mulesoft.com/http-connector/latest/http-listener-ref)
- [APIkit for REST Scaffolding Reference](https://docs.mulesoft.com/apikit/latest/apikit-4-scaffolding-reference)
- [APIkit for REST Error Handling Reference](https://docs.mulesoft.com/apikit/latest/apikit-error-handling-reference)
- [APIkit for REST Module Reference](https://docs.mulesoft.com/apikit/latest/apikit-4-xml-reference)
- [On-Error Components](https://docs.mulesoft.com/mule-runtime/latest/on-error-scope-concept)
- [Configuring Behavior During Runtime](https://docs.mulesoft.com/apikit/latest/key-configurations)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 6 linked practice questions, and unlimited timed mock exams are included with the MuleSoft Developer pack (USD $19): https://www.certifyforce.com/practice-exams
