> For the complete documentation index, see [llms.txt](https://docs.thedex.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thedex.cloud/introduction/redirect.md).

# Redirect

### 📤 **Success & Failure & Return Redirect URLs**

These are **redirect URLs** (not webhooks) that return the **user** to your website after an invoice-related action is completed.

* ✅ **Success redirect**:\
  Triggered when an invoice is **successfully paid**. The user is redirected to the configured `successUrl`.
* ❌ **Failure Redirect**:\
  Triggered when the invoice is **canceled**, **rejected**, **expired**, or if an **error** occurs. The user is redirected to the configured `failureUrl`.
* ↩️ **Return Redirect**:\
  Triggered when the invoice in a **waiting**, **pending confirm**, **unpaid**, or **underpaid** status. The user is redirected to the configured `returnUrl`.

### 🔧 Configuration

To enable redirect functionality, the URLs must be defined in one of the following ways:

* **Merchant-level configuration**:\
  Set the `successUrl` and `failureUrl` and `merchantSiteUrl` fields in your merchant profile in the Thedex merchant settings.
  1. Sign in at [app.thedex.cloud](https://app.thedex.cloud).
  2. After logging in, navigate to the **"Merchants"** section.
  3. Click the **"Edit"** button on your merchant.
  4. Fill in **Success redirect Url**, **Failure redirect Url** or **Merchant site**.
  5. Complete form.
* **Per-request configuration**:\
  If not set at the merchant level, you can specify `successUrl` and `failureUrl`, `returnUrl` directly in your **API request** when creating an invoice.

> If both options are used, the values passed in the API request will override the merchant defaults

### 🔄 **Behavior**

* **Automatic redirect (If the invoice was created via API)**:\
  The user is redirected automatically to either the success or failure URL as soon as the invoice status is updated or user click a button **"Return to website"** manually.
* **If the invoice was created via Thedex UI**:

  The user must click a button (e.g., **"Return to website"**) to initiate the redirect.

> ⚠️ **Important:** These URLs are intended for **user redirection only**. They are **not** intended for server-to-server communication or for receiving payment status updates.\
> Use [webhooks ](/introduction/callback.md)for backend notification and processing.

<figure><img src="/files/7GPJYQt1cwIAJUuGFlXu" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/tIzAPaC5s96MOZnZBFM4" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6XicbSFkA40Vumw47QMR" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.thedex.cloud/introduction/redirect.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
