> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spojit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Response

> Return an HTTP response to the webhook caller from within a workflow.

The **Response** node is a terminal node that produces the HTTP response sent back to a webhook caller when the trigger is configured with **Sync (wait for result)** response mode.

***

## When to use it

Use the Response node when you want webhook callers to receive a **meaningful response body** synchronously, for example:

* An API-style webhook that returns the processed result immediately
* A Slack slash command endpoint that needs to reply within its 3-second window
* A webhook call where the sender needs to know the outcome before proceeding

For fire-and-forget webhooks (most common pattern), no Response node is needed; leave the trigger in **Async (return immediately)** mode and Spojit returns a `202 Accepted` automatically.

***

## Configuration

| Field           | Description                                                             | Templated |
| --------------- | ----------------------------------------------------------------------- | --------- |
| **Label**       | Display name on the canvas                                              | No        |
| **Status Code** | HTTP status (100–599). Defaults to 200.                                 | No        |
| **Headers**     | List of header key-value pairs. Both keys and values support templates. | Yes       |
| **Body**        | The response body. JSON or plain text. Supports templates.              | Yes       |

See [Passing Data Between Nodes](/workflow-editor/passing-data) for template syntax details.

***

## How it terminates the workflow

The Response node is **terminal**: it has no outgoing connections. When a workflow run reaches a Response node, it:

1. Renders all templates (status code, headers, body) against the current workflow state
2. Captures the rendered result as the workflow's output
3. Ends the run

If your graph branches (via a Condition or Parallel node), you can place a Response node on each branch; whichever branch executes first produces the response.

***

## Interaction with the trigger's response mode

The Response node's behavior depends on the **webhook trigger's Response Mode** setting:

### Sync (WAIT\_FOR\_COMPLETION)

Spojit holds the HTTP connection until the workflow reaches the Response node, then sends the rendered status/headers/body back to the caller.

If the workflow doesn't finish within the configured **Timeout (seconds)**, Spojit returns `202 Accepted` with an execution ID; the workflow keeps running, and the Response node's eventual output is stored on the execution record so it can be retrieved via the execution status endpoint later.

### Async (RETURN\_IMMEDIATELY)

Spojit returns `202 Accepted` immediately after dispatch. The Response node still runs: it still terminates the workflow and records its output on the execution, but the output isn't sent back to the original caller. You can inspect it later via the execution logs.

***

## Examples

### Echo request back with a status

Trigger payload:

```json theme={null}
{ "name": "Alice" }
```

Response node body:

```json theme={null}
{
  "status": "processed",
  "greeting": "Hello, {{ input.name }}!"
}
```

Response to caller:

```json theme={null}
{
  "status": "processed",
  "greeting": "Hello, Alice!"
}
```

### Return an AI-generated answer

Graph:

```
Webhook  →  AI Agent (outputVariable: answer)  →  Response
```

Response body:

```json theme={null}
{
  "question": "{{ input.question }}",
  "answer": "{{ answer }}"
}
```

### Return different status codes based on validation

Graph:

```
Webhook  →  Condition (valid?)
              ├─ true  →  ... →  Response (statusCode: 200)
              └─ false →  Response (statusCode: 400)
```

Two Response nodes on separate branches; the one whose branch executes wins.

### Custom headers

Set headers like `X-Request-Id` or `Cache-Control` to anything, with or without templates:

| Key             | Value              |
| --------------- | ------------------ |
| `X-Request-Id`  | `{{ input.id }}`   |
| `Cache-Control` | `no-store`         |
| `Content-Type`  | `application/json` |

***

## Validation

Spojit enforces:

* **Response nodes must be terminal**: they cannot have outgoing connections. Disconnect any edges leaving a Response node before saving.
* You can have **multiple Response nodes** in a single workflow (e.g., one per branch); there's no limit.

***

## Tips

* Always set **Content-Type** explicitly; the default `application/json` is implied if you leave it off, but being explicit makes webhook docs clearer for integrators.
* Keep status codes meaningful (200 for success, 4xx for client errors, 5xx for server errors). Spojit doesn't enforce this but callers expect it.
* If a field in the body needs to stay a number or object (not a string), use a standalone `{{ ... }}` expression; see [Type Preservation](/workflow-editor/passing-data#type-preservation).
