# Conditional Success Action

Different results may be required for the same endpoint based on certain criteria. It is possible to define any number of success elements such as:

```xml
<endpoint name="foo">
    <success if="${language}" equals="en">
        <response-from-static filename="path-to-english-file"/>
    </success>
    <success if="${language}" equals="de">
        <response-from-static filename="path-to-german-file"/>
    </success>
    <success if="${language}" notequals="es">
        <response-from-static filename="path-to-english-file"/>
    </success>
    <success>
        <!-- no condition => "otherwise" -->
        <response-from-static filename="path-to-spanish-file"/>
    </success>
</endpoint>
```

The conditions are considered in the order they’re written in the file, so put more general “catch-all” items at the bottom and more specific “if...” items at the top.

Parameters may also be used in the "equals" or "notequals" attribute. You could for example create a condition like

```xml
<success if="${delivery-address}" notequals="${invoice-address}">
```

Only `if=".." equals=".."` and `if=".." notequals=".."` are available.

If the parameter has a value like `foo||bar` i.e. created as a result of a request such as `?param=foo&param=bar` then the `equals=".."` will check if *any* of the values match, and `notequals=".."` will check that *none* of the values match the value.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://onestopconcept.gitbook.io/open-endpoints/configuration/types-of-endpoints/conditional-success-action.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
