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

# Create links

> POST /partner/links — shared envelope, flow discriminator, and config examples

## Overview

`POST /partner/links` creates a magic link. The body is a **discriminated union** on `flow`. Shared envelope fields apply to every flow; each flow adds its own `config`.

Base URL (sandbox): `https://raas-widgets-backend-sandbox.up.railway.app`

## Shared envelope

| Field              | Required       | Description                                       |
| ------------------ | -------------- | ------------------------------------------------- |
| `referenceId`      | Yes            | Your end-user id                                  |
| `flow`             | Yes            | Flow slug (`smart`, `m2m`, …)                     |
| `expiresInMinutes` | No             | TTL 5–10080 (default partner setting, usually 60) |
| `externalId`       | No             | Your order/ticket id (copied to operations)       |
| `metadata`         | No             | Arbitrary JSON                                    |
| `theme`            | No             | Opaque theme object for the flow UI               |
| `language`         | No             | `en` or `es`                                      |
| `callbackUrl`      | No             | Per-link webhook override                         |
| `headerName`       | No             | Brand name in widget header                       |
| `cipTemplateId`    | No             | CIP template override                             |
| `presentation`     | No             | `{ showSplash?, showAgreement? }`                 |
| `config`           | Flow-dependent | Flow-specific payload                             |

## Smart (minimal)

```bash theme={null}
curl -X POST https://raas-widgets-backend-sandbox.up.railway.app/partner/links \
  -H "X-API-Key: raas_sandbox_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "referenceId": "user-12345",
    "flow": "smart",
    "language": "es",
    "presentation": { "showSplash": false }
  }'
```

## M2M (prefill)

```bash theme={null}
curl -X POST https://raas-widgets-backend-sandbox.up.railway.app/partner/links \
  -H "X-API-Key: raas_sandbox_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "referenceId": "user-12345",
    "flow": "m2m",
    "expiresInMinutes": 120,
    "config": {
      "userData": {
        "name": { "firstName": "Ana", "lastName": "García" },
        "paymentMethod": {
          "type": "bank_account",
          "bankAccount": {
            "country": "MX",
            "accountNumber": "012345678901234567"
          }
        }
      },
      "themeMode": "dark"
    }
  }'
```

## Common errors

| Code                             | HTTP | Meaning                                |
| -------------------------------- | ---- | -------------------------------------- |
| `FLOW_REQUIRED` / `UNKNOWN_FLOW` | 400  | Missing or invalid `flow`              |
| `VALIDATION_FAILED`              | 400  | Envelope or `config` failed validation |
| `FLOW_NOT_ALLOWED`               | 403  | Flow not in partner `allowedFlows`     |
| `USER_BLOCKED`                   | 403  | User cannot receive new links          |

## Discover enabled flows

```bash theme={null}
curl https://raas-widgets-backend-sandbox.up.railway.app/partner/flows \
  -H "X-API-Key: raas_sandbox_your_api_key_here"
```

## Next steps

<CardGroup cols={2}>
  <Card title="Embed & WebView" icon="mobile" href="/raas-widgets/guides/embed-webview">
    Delivery and presentation flags.
  </Card>

  <Card title="API Reference" icon="code" href="/raas-widgets/api-reference/introduction">
    Full OpenAPI for every variant.
  </Card>
</CardGroup>
