> For the complete documentation index, see [llms.txt](https://docs.xaman.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xaman.dev/js-ts-sdk/examples-user-stories/sign-requests-payloads/xapp.md).

# xApp

xApps are natively aware of the end user context, so a Sign Request payload can easily be served with the `xumm.xapp.openSignRequest` method: [openSignRequest({ … })](/js-ts-sdk/sdk-syntax/xumm.xapp/opensignrequest.md)

{% hint style="info" %}
For more information about the object contents to be used for Payloads & the return URL replacement variables, see: <https://xumm.readme.io/reference/post-payload>
{% endhint %}

{% tabs %}
{% tab title="JavaScript (VanillaJS)" %}

```html
<html lang="en">
  <head>
    <script src="https://xumm.app/assets/cdn/xumm.min.js"></script>
  </head>
  <body>
    <pre id="payload">...</pre>

    <script>
      var xumm = new Xumm('your-api-key')

      xumm.on('payload', event => {
        document.getElementById('payload').innerHTML = JSON.stringify(event, null, 2)
      })

      xumm.payload
        .create({
          txjson: {
            TransactionType: "Payment",
            Destination: "r...",
            Amount: "1000000"
          },
          options: {
            return_url: {
              app: "https://sample.test/?...",
              web: "https://sample.test/?id={id}"
            },
            force_network: "MAINNET"
          },
          custom_meta: {
            identifier: "123123",
            instruction: "Please sign this to..."
          }
        })
        .then(payload => {
          document.getElementById('payload').innerHTML = JSON.stringify(payload, null, 2)
          xumm.xapp.openSignRequest(payload)
        })
    </script>
  </body>
</html>
```

{% endtab %}

{% tab title="TypeScript / mjs" %}

```typescript
const payload = await xumm.payload?.create({
  txjson: {
    TransactionType: "Payment",
    Destination: "r...",
    Amount: "1000000"
  },
  options: {
    return_url: {
      app: "https://sample.test/?...",
      web: "https://sample.test/?id={id}"
    },
    force_network: "MAINNET"
  },
  custom_meta: {
    identifier: "123123",
    instruction: "Please sign this to..."
  }
})

xumm.xapp?.openSignRequest(payload)
```

{% endtab %}
{% endtabs %}

When a payload (Sign Request) has been created and opened in your xApp, you probably want to be informed if the payload has been signed or rejected, then to check the payload results and act on the results. You can do so by subscribing to the `payload` event, see: [Xumm.on(event, fn)](/js-ts-sdk/sdk-syntax/xumm.on-event-fn.md)

{% tabs %}
{% tab title="Promise" %}

```javascript
xumm.on('payload', data => {
  if (data?.uuid) {
    xumm.payload.get(data.uuid).then(payload => {
      // Payload contains the full paylaod data
    })
  }
})
```

{% endtab %}

{% tab title="Async" %}

```typescript
xumm.on('payload', data => {
  if (data?.uuid) {
    const payload = await xumm.payload.get(data.uuid)
    // Payload contains the full paylaod data
  }
})
```

{% endtab %}
{% endtabs %}


---

# 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:

```
GET https://docs.xaman.dev/js-ts-sdk/examples-user-stories/sign-requests-payloads/xapp.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.
