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

# Response

> Anything that is returned when the logic is complete

The response is what the logic will return when it's executed. It can be a value, a message, a JSON object; almost anything you want. Responses can be returned from a variable, or manually defined in the response itself.

Not all primitives support responses; see below.

| Primitive | Supports Response | Notes |
| - | - | - |
| API | Yes | Returns the JSON object defined in the response block |
| AI Agent | No | Your agent will return messages to the user, but you don't directly define the response like other primitives |
| Trigger | Yes | Returns the JSON object defined in the response block |
| Background Task | No | No responses are supported |
| Custom Function | Yes | Returns the JSON object defined in the response block |
| Middleware | Yes | Returns the JSON object defined in the response block |
| AI Tool | Yes | Returns the JSON object defined in the response block |
| MCP Server | No | Your tools will deliver messages back to the MCP client, but you don't directly define a response like other primitives |

## Adding a Response

Responses will usually come from a variable of some kind, but you can also manually define a static value, or use filters to create a combination of both.

When building visually, Xano will automatically add a response of the first variable in the stack. For example, if you start by adding a Query All Records function, Xano will make sure that the response is the output of that function.

Responses can be returned as `self`, meaning that it is not nested in another object.

```json lines icon="code" Example of a self response theme={null}
{
  "id": 1,
  "created_at": 1760368044972,
  "name": "Erin Porter",
  "email": "mei.payne@google.com"
}
```

You can also return each response as its own nested object.

```json lines icon="code" Example of a nested response theme={null}
{
  "user": {
    "id": 1,
    "created_at": 1760368044972,
    "name": "Erin Porter",
    "email": "mei.payne@google.com"
  }
}
```

> [tab] Visually: Canvas View
>
> Find your response block and choose **Add a Response**.
>
> ![response-20251013-135205](https://mintcdn.com/xano-997cb9ee/4xy0p5vdU3hAE_8U/images/response-20251013-135205.png?fit=max\&auto=format\&n=4xy0p5vdU3hAE_8U\&q=85\&s=090c4c42458039aad138aa0404d3520b)
>
> Give your response a name, and choose whether you want to return it as `self` or nested under another value.
>
> ![response-20251013-135552](https://mintcdn.com/xano-997cb9ee/4xy0p5vdU3hAE_8U/images/response-20251013-135552.png?fit=max\&auto=format\&n=4xy0p5vdU3hAE_8U\&q=85\&s=fe1271f41f8ed053bf5ac206e2891841)

> [tab] Visually: Function Stack
>
> Find your response block and choose **Add a Response**.
>
> ![response-20251013-135651](https://mintcdn.com/xano-997cb9ee/4xy0p5vdU3hAE_8U/images/response-20251013-135651.png?fit=max\&auto=format\&n=4xy0p5vdU3hAE_8U\&q=85\&s=e1e32429eb927ea4f0b6fae12f126f14)
>
> Give your response a name, and choose whether you want to return it as `self` or nested under another value.
>
> ![response-20251013-135552](https://mintcdn.com/xano-997cb9ee/4xy0p5vdU3hAE_8U/images/response-20251013-135552.png?fit=max\&auto=format\&n=4xy0p5vdU3hAE_8U\&q=85\&s=fe1271f41f8ed053bf5ac206e2891841)

> [tab] XanoScript
>
> The response block is placed towards the end of the primitive, after the logic and before any additional settings.
>
> ```javascript lines icon="code" Example of a response in XanoScript theme={null}
>   response {
>     value = {user: $model}
>   }
> ```
>
> To return a self response, forgo the object and keep only the `value` assignment.
>
> ```javascript lines icon="code" Example of a self response in XanoScript theme={null}
>   response {
>     value = $model
>   }
> ```


## Related topics

- [Response Caching](https://docs.xano.com/the-function-stack/additional-features/response-caching.md)
- [XanoScript Key Concepts](https://docs.xano.com/xanoscript/key-concepts.md)
- [Testing And Debugging Function Stacks](https://docs.xano.com/testing-debugging/testing-and-debugging-function-stacks.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.