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

# Create a token to initialize the Benji Connect SDK

> Create a token to initialize an instance of the Benji Connect SDK or Benji Hosted Connect.

> [!NOTE]
>
> The `x-api-key` header value to be used on this API is your **partner API
> key**, which can be generated through the [Developer](https://docs.withbenji.com/pilot/developer.md) page
> in Pilot.

> [!NOTE]
>
> The Connect Token API resolves **merchant** and **partner** from
> **`partnership_id`**.

### Request body

**partnership\_id** `string` *required*

The unique identifier of the partnership on the Benji Platform.

**mode** `number` *required*

The connection mode for the SDK (Connect = 1, Transfer = 3, and Redeem = 4).
See [Connect modes](https://docs.withbenji.com/connect/modes.md).

**display\_name** `string`

Display name shown in the Connect UI. If omitted, the name configured for the
partnership on the platform is used.

**user\_external\_id** `string`

A unique identifier for the user in your system. When set, the flow can skip
the authentication step for your user.

**custom\_attributes** `object`

Custom attributes for the connection flow (e.g. transfer actions).

**properties**

**actions** `array`

Array of actions (e.g. transfer amounts).

**action properties**

**mode** `number`

Action mode: **Transfer = 3**

**amount** `number`

Preselected points amount for action.

**allows\_editing** `boolean`

Whether the user can edit the amount in the UI.

### Example requests

> [accordion] Minimal request (Connect mode)
>
> ```json theme={null}
> {
>     "partnership_id": 49,
>     "mode": 1,
>     "display_name": "Reward Cookies"
> }
> ```

> [accordion] With user\_external\_id
>
> ```json theme={null}
> {
>     "partnership_id": 49,
>     "mode": 1,
>     "display_name": "Reward Cookies",
>     "user_external_id": "user-1234"
> }
> ```

> [accordion] Transfer mode (mode 3) with custom\_attributes
>
> ```json theme={null}
> {
>     "partnership_id": 49,
>     "mode": 3,
>     "display_name": "Reward Cookies",
>     "custom_attributes": {
>         "actions": [
>             {
>                 "mode": 3,
>                 "amount": 1000,
>                 "allows_editing": true
>             }
>         ]
>     }
> }
> ```

> [accordion] Redeem mode (mode 4)
>
> ```json theme={null}
> {
>     "partnership_id": 49,
>     "mode": 4,
>     "display_name": "Reward Cookies"
> }
> ```

### Return values

**token** `string` *required*

The connect token to pass when [initializing the Benji Connect
SDK](https://docs.withbenji.com/connect/initialization.md) or as `connect_token` on the [**Benji Hosted
Connect**](https://docs.withbenji.com/connect/hosted/introduction.md) URL.

**connect\_url** `string`

Base URL for **Benji Hosted Connect** for this partnership. Append `?connect_token=<token>` (and optional query parameters) to send users into **Benji Hosted Connect**. May be empty if **Benji Hosted Connect** URLs are not enabled for your account.

```json 200 theme={null}
{
    "code": "ok",
    "data": {
        "token": "0c371a1c-aa81-11ef-b28c-0a58a9feac02",
        "connect_url": "https://connect.withbenji.com/khkgfoud76td"
    }
}
```

```json 401 theme={null}
{
  "error": "unauthorized_partner",
  "message": "Invalid key, or key is not authorized to make this call"
}
```

```json 500 theme={null}
{
  "error": "unexpected_error",
  "message": "An unexpected error has occurred"
}
```


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