Skip to content

HTTP Response ​

The HTTP Response task defines what data is returned to the application that called the endpoint. It needs three settings: the data format, the status code, and the body.

TIP

This page is about returning data from the endpoint. To handle the response of an HTTP Request task, see HTTP Response Handler instead.

Settings ​

Format ​

Format simply chooses what data format you're sending back. Your data should match the format you choose, and this may be defined by the application that calls the endpoint. For example, if your application expects JSON, then you should select JSON here.

Status Code ​

Status Code is an HTTP status code. Typically, if everything went well, this will be 200, or if things went wrong, it will be 400. You can find a full list of status codes on the Mozilla website.

Headers ​

Multiple Headers can be optionally appended to your http response. Each header can have a Key and one or more Values. For example:

  1. Single Value Header:

    • Key: Location
    • Values: https://example.com
    Location: https://example.com
  2. Multiple Value Header:

    • Key: Link
    • Values: <https://api.example.com/page/1>; rel="prev" <https://api.example.com/page/3>; rel="next"
    Link: <https://api.example.com/page/1>; rel="prev"
    Link: <https://api.example.com/page/3>; rel="next"

TIP

You can view the headers that are set by enabling Debug Mode on your endpoint and examining the Endpoint Task Values Resolved in the metrics.

Body ​

Finally, the body should be the data you wish to return. This should match the Format you have selected, but otherwise the content is completely flexible.

Notes ​

  • The HTTP Response task is typically the last task in an endpoint.
  • You do not typically need to use this task in addition to the HTTP Redirect task. If you are using both, set up filters to decide which one is used by the endpoint.

Omitting this task ​

If an endpoint has no HTTP Response task, it returns the result of every task in the endpoint as a JSON array, in task order. For an endpoint with two HTTP Request tasks, where the second downloads a PDF, this looks like:

json
[
  {
    "contentType": "application/json",
    "format": null,
    "headers": {},
    "redirectUrl": null,
    "result": "{ \"id\": 123 }",
    "skipped": false,
    "statusCode": 200,
    "streamResult": null,
    "success": true
  },
  {
    "contentType": "application/pdf",
    "format": null,
    "headers": {},
    "redirectUrl": null,
    "result": null,
    "skipped": false,
    "statusCode": 200,
    "streamResult": "{streamResultRedacted}",
    "success": true
  }
]

This includes each HTTP Request task's full response body. File content, such as a PDF, isn't returned - streamResult shows {streamResultRedacted} instead. Response headers aren't returned either, so headers is always empty. To use a task's response headers, map them with Liquid.

If Debug Mode is enabled, this output is also stored in the endpoint's metrics for synchronous calls.

WARNING

Response bodies from the services you call can contain sensitive values, such as tokens or personal data. Add an HTTP Response task and map only the data your caller needs.

Exceptions:

  • If Stop on Task Failure is enabled and a task fails, only that task's status code and body are returned.
  • If a task has Retain status code enabled, only that task's status code and body are returned.
  • If an HTTP Redirect task runs, the caller is redirected instead.

See How the endpoint response is decided for the full order.