Default behavior
When your handler returns a plain object, the platform responds with200 OK and Content-Type: application/json:
Response builder
Importresponse from @jelou/functions:
Custom status code
Custom headers
Multiple headers at once
Full chaining
The builder is immutable — each method returns a new instance:API
.json() and .noContent() are the terminal methods — after calling them you get a final response, not a builder.Practical examples
- 201 Created
- 404 Not Found
- Cache headers
- 202 Accepted
- 204 No Content
Output validation
When usingresponse.json(body) with an output schema, validation applies to the body — same as with plain objects. Validation never blocks the response.
MCP behavior
When invoked via MCP (Brain Studio AI agents):- The body is emitted as
structuredContent - Status code and headers are ignored — MCP has no HTTP status concept
- The body is also sent as JSON text for compatibility
Limitations
For advanced needs (streaming, binary, dynamic content-type), use raw mode.