tr Skip to content

Custom Webhook Response: Send Your Own Status, Headers and Data

FlowMattic Webhook Response: a webhook request looks up an order and replies with JSON and a 200 or 404 status code.

A custom webhook response is the reply your WordPress site sends back to whoever called a webhook: the body, the HTTP status code and the headers. FlowMattic’s Webhook Response module builds that reply from the data in your workflow, so a caller gets an answer instead of a generic “Response Captured”.

It is for anyone turning a webhook trigger into a small API: slash commands, order lookups, form handlers, SMS replies, or a front end that needs JSON back. This guide covers the response types, status codes, headers and redirects, how the reply is timed, and seven practical uses.

What is the Webhook Response module?

Webhook Response is a built-in action app for workflows that start with a webhook trigger. It has two actions:

  • Set Webhook Response: sets the body, status code and extra headers the caller receives, using data from earlier steps.
  • Set Webhook Redirect URL: sets where a visitor is sent after the run, for webhooks opened in a browser.

The webhook trigger can already send a fixed reply through its Send a custom webhook response box. The module is what you use when the reply depends on the run, such as a looked-up record, an AI answer or an error code.

How to set a custom webhook response

  1. Start the workflow with Webhooks by FlowMattic and capture a sample request.
  2. Add the steps that produce your answer, such as a table lookup or an API call.
  3. Add Webhook Response with Set Webhook Response.
  4. Choose a Response Type and fill in its field, mapping values from earlier steps.
  5. Optionally set a Status Code and Response Headers.
  6. Send a test request and check what the caller receives.
FlowMattic workflow builder showing the Webhook Response Set Webhook Response action with Parameters as JSON selected and a 404 status code.
Set Webhook Response with the Response Type, Response Parameters, Status Code and Response Headers fields.

Response types and options

OptionWhat it does
Response Type: StringReturns the text in Response String.
Response Type: Parameters as JSONBuilds a JSON object from the key and value rows under Response Parameters.
Response Type: Custom JSONReturns the JSON you write in the Custom JSON box, with dynamic tags inside.
Response Type: Parameters as XMLBuilds XML from the rows under XML Parameters, inside a <Response> root element, sent as application/xml.
Response Type: Custom XMLReturns the XML you write in the Custom XML box, sent as application/xml.
Status CodeAny HTTP status from 200 to 599, including codes WordPress has no name for. Leave it empty for 200.
Response HeadersExtra headers such as Cache-Control or a custom X- header. The response type sets Content-Type, and header names cannot use dynamic tags.
Redirect URLOn Set Webhook Redirect URL, the address the visitor is sent to.

Status codes and headers work on both webhook URL styles, permalink-based and REST API-based. If the webhook trigger delivers via FlowMattic Cloud, Cloud forwards the request straight away instead of queueing it and returns your site’s reply to the sender.

When the caller gets the reply

A workflow that contains a Webhook Response step keeps the request open while it runs, and the caller receives the reply when the run in that request has finished. That is what lets later data reach the response, and it also means every step adds to the caller’s wait. Keep slow work, such as long AI calls or big loops, out of workflows whose callers have short timeouts.

If several Set Webhook Response steps run, the last one decides the reply. Steps in Router routes that do not run have no effect, so each route can carry its own answer.

Use cases

Answer a Slack slash command

A support team’s /order 1042 command posts to the trigger. A lookup finds the order and Parameters as JSON returns a text key with its status, which Slack shows to the user who asked.

Flow: Webhook → Look up order → Set Webhook Response (Parameters as JSON)

An order status endpoint with real error codes

An e-commerce site gives its mobile app a URL that takes an order number. A Router sends found orders to a 200 reply with the order details, and unknown numbers to a 404 with a short message, so the app can handle each case properly.

Flow: Webhook → Get order → Router → Set Webhook Response (200 or 404)

Reject incomplete submissions

A partner posts leads to your site. When required fields are missing, one route returns Status Code 422 with a JSON list of what is wrong; complete leads go on to the CRM and get a 201.

Flow: Webhook → Router (fields present?) → CRM or Set Webhook Response 422

Reply to an SMS with XML

Some SMS providers read the webhook’s XML reply to decide what to text back. Parameters as XML wraps your keys in a <Response> element; Custom XML covers any other shape the provider expects.

Flow: Webhook (incoming SMS) → AI Agent reply → Set Webhook Response (Custom XML)

A questions endpoint for your own front end

A SaaS help widget posts a customer’s question to a webhook. An AI Agent drafts the answer from your docs and Custom JSON returns it with a sources field for the widget to display.

Flow: Webhook → AI Agent → Set Webhook Response (Custom JSON)

A cacheable public data feed

A marketing site shows upcoming events in a widget that calls a webhook. The reply carries the events from a WP Tables lookup and a Cache-Control response header, so browsers do not ask again on every page view.

Flow: Webhook (GET) → WP Tables find records → Set Webhook Response with Cache-Control

Send visitors to the right thank-you page

An agency’s landing page form posts straight to a webhook URL. With the trigger’s Workflow End Action set to Redirect to URL, a Set Webhook Redirect URL step sends trial sign-ups and demo requests to different pages.

Flow: Webhook (form post) → Router → Set Webhook Redirect URL

Tips and gotchas

  • Redirects need the trigger set up. Set Webhook Redirect URL only takes effect when the webhook trigger’s Workflow End Action is Redirect to URL.
  • Some headers are dropped. Response Headers never sends headers that set cookies (Set-Cookie), change the status (Status), redirect without a 3xx status (Location), allow credentialed cross-origin requests (Access-Control-Allow-Credentials) or make the web server send a file (X-Accel-Redirect, X-Sendfile), nor Refresh, Content-Security-Policy or transport headers such as Content-Type, Content-Length and Connection. Header names must be valid, and line breaks are removed from values. Any dropped header is listed in the step’s output in Task History.
  • Out-of-range codes fall back. A status code that is not a number from 200 to 599 is ignored and the reply goes out as 200. 1xx codes are interim responses, so they are not accepted.
  • Verification challenges win. When a request carries hub_challenge or challenge, the trigger echoes that value as plain text instead of your response, as subscription checks expect.
  • XML keys are cleaned. In Parameters as XML, characters that are not valid in element names become underscores, and list items take the singular of the parent key or item.
  • Test what the caller sees. Use the sending app’s delivery log or a command-line request to confirm the status, headers and body before going live.

Related features

  • Webhook trigger: the URL, sample capture and signature checks that start the run.
  • Router: send each run down a route with its own response.
  • Webhooks overview: receive, send and respond in one place.

FAQ

How do I return a custom webhook response in WordPress?

Start a FlowMattic workflow with the webhook trigger and add a Webhook Response step with Set Webhook Response. Choose String, JSON or XML, map the data you want to return, and the caller receives it when the run finishes.

Can I return a status code other than 200?

Yes. Enter any HTTP status from 200 to 599 in Status Code, such as 201, 404 or 422. Leave the field empty to reply with 200.

Can a webhook response be XML?

Yes. Parameters as XML builds XML from key and value rows inside a Response root element, and Custom XML returns whatever XML you write. Both are sent with the application/xml content type.

Does a Webhook Response step slow down my webhook?

The caller waits for the run to finish, because the reply is built from its data. Keep these workflows short, and move slow follow-up work into a separate workflow when the caller has a tight timeout.

Webhook Response is included with every FlowMattic plan. Try FlowMattic and turn your first webhook into an endpoint that answers.

More from the blog