# Rupi Connect

The Connect module handles wallet and payroll source linking for a given user. A user must have at least one active wallet connection and one active payroll connection before a VIP can be generated.

#### Create a wallet connection

**Request nonce**

http

```http
GET /connect/wallet/nonce
Authorization: Bearer sk_live_xxxx
X-User-Id: usr_01J2K...
```

**Response**

json

```json
{
  "nonce": "a8f3b2c1d4e5",
  "expires_at": "2024-12-01T10:05:00Z"
}
```

**Submit signed message**

http

```http
POST /connect/wallet
Authorization: Bearer sk_live_xxxx
Content-Type: application/json

{
  "user_id": "usr_01J2K...",
  "address": "0xUser5678...EfGh",
  "network": "polygon",
  "message": "rupi.finance wants you to sign in...",
  "signature": "0x4f5e6d..."
}
```

**Response**

json

```json
{
  "connection": {
    "id": "con_wallet_9KxP...",
    "user_id": "usr_01J2K...",
    "type": "wallet",
    "provider": "metamask",
    "identifier": "0xUser5678...EfGh",
    "network": "polygon",
    "status": "active",
    "created_at": "2024-12-01T10:01:00Z",
    "last_synced_at": "2024-12-01T10:01:00Z"
  }
}
```

#### Create a platform connection

Redirect the user to the OAuth authorization URL for their platform data source, or pass platform data directly via server-to-server API if the integrating platform is itself the data source.

**Option A: OAuth redirect (third-party platform)**

Used when the data source is a platform other than the one integrating Rupi — for example, a user of a neobank that also receives Deel payroll.

http

```http
GET /connect/platform/authorize?platform=deel&user_id=usr_01J2K...
Authorization: Bearer sk_live_xxxx
```

**Response**

json

```json
{
  "redirect_url": "https://app.deel.com/oauth/authorize?client_id=rupi_client&scope=employment%3Aread+payments%3Aread&state=xyz789&redirect_uri=https%3A%2F%2Fapi.rupi.finance%2Fv1%2Fconnect%2Fplatform%2Fcallback"
}
```

Examples of Supported platforms and scopes:

| Platform | Type     | Scope                            |
| -------- | -------- | -------------------------------- |
| Deel     | Payroll  | `employment:read payments:read`  |
| Rise     | Payroll  | `profile:read payroll:read`      |
| Bitwage  | Payroll  | `account:read payroll:read`      |
| DolarApp | Neobank  | `account:read transactions:read` |
| Belo     | Neobank  | `account:read transactions:read` |
| Binance  | Exchange | `account:read history:read`      |
| Bitso    | Exchange | `account:read transactions:read` |

**Option B: Direct platform data push (integrating platform is the data source)**

When the integrating platform is a neobank, exchange, or wallet passing its own user data to Rupi, no OAuth redirect is needed. The platform submits account history directly.

http

```http
POST /connect/platform/direct
Authorization: Bearer sk_live_xxxx
Content-Type: application/json

{
  "user_id": "usr_01J2K...",
  "platform": "dolarapp",
  "source_type": "neobank_account",
  "account_id": "acct_ext_9876",
  "data": {
    "account_holder": "user@example.com",
    "currency": "USDC",
    "transaction_history": [
      {
        "date": "2024-11-30",
        "amount": 4500.00,
        "direction": "inbound",
        "from_reference": "0xDeel1234...AbCd",
        "description": "payroll_inbound"
      }
    ]
  }
}
```

**Response**

json

```json
{
  "connection": {
    "id": "con_platform_5MnQ...",
    "user_id": "usr_01J2K...",
    "type": "platform",
    "source_type": "neobank_account",
    "provider": "dolarapp",
    "status": "active",
    "created_at": "2024-12-01T10:03:00Z",
    "last_synced_at": "2024-12-01T10:03:00Z"
  }
}
```

After OAuth callback or direct push, Rupi creates the platform connection automatically. A `connection.platform.created` webhook event is fired.

#### List connections

http

```http
GET /connections?user_id=usr_01J2K...
Authorization: Bearer sk_live_xxxx
```

**Response**

json

```json
{
  "connections": [
    {
      "id": "con_wallet_9KxP...",
      "type": "wallet",
      "provider": "metamask",
      "identifier": "0xUser5678...EfGh",
      "status": "active",
      "created_at": "2024-12-01T10:01:00Z"
    },
    {
      "id": "con_platform_5MnQ...",
      "type": "platform",
      "source_type": "neobank_account",
      "provider": "dolarapp",
      "identifier": "user@example.com",
      "status": "active",
      "created_at": "2024-12-01T10:03:00Z"
    }
  ]
}
```


---

# 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://docs.rupi.global/core-documentation/markdown/rupi-connect.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.
