# Creating vendors by referral

In case your platform uses a referral flow to invite vendors to your payments product (for example: an accountant inviting their customers to accept payments via your platform), you should pass information about both the referrer and the referred parties to Unipaas upon creation.

## General referral flow

The following describes a typical referral flow, with actions that must be taken on each step:

| User flow                                                               | Technical steps                                                                                                                                                                                                                                                                                                                                      |
| ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| A **new** referrer invites a vendor to join your payments product       | 1. Create a vendor for the referrer using a regular [`create vendor`](/reference/#tag/vendor/POST/vendors)' API call.

2. Save the referrer's `vendorid` for later

3. Create the vendor using a [`create vendor`](/reference/#tag/vendor/POST/vendors) API call, add the referrer's `vendorid` to the `referrerVendorId` field. (see example below) |
| An **existing** referrer invites a vendor to join your payments product | 1) Create the vendor using a [`create vendor`](/reference/#tag/vendor/POST/vendors) API call, add the relevant referrer's `vendorid` to the `referrerVendorId` field. (see example below)                                                                                                                                                            |

## Integration example

The following example uses the [`create vendor`](/reference/#tag/vendor/POST/vendors) API call that is used to create all vendors in Unipaas.

**1. Creating a referrer**\
Creating a referrer (accountant) profile is exactly same as creating any other vendor:

* JSON

  ```json
  {
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@example.com",
    "country": "GB",
    "type": "individual"
  }
  ```

The response will include the referrer's `vendorid`, which will be used to link the vendors they invited:

* JSON

  ```json
  {
    "id": "63ea04cf6d3161e1ba997d52", // Used to connect to invited vendors
    "name": "John Doe",
    "email": "john.doe@example.com",
    "createdAt": "2029-02-13T09:37:19.286Z",
    "updatedAt": "2029-02-13T09:37:19.286Z",
    "merchantId": "62c3ee08f396b3c46e240044"
  }
  ```

**2. Linking an invited vendor to their referrer**

When creating a vendor that was referred by a referrer, use the `referrerVendorId` field to link the vendor with their referrer.

* JSON

  ```json
  {
    "businessName": "New Vendor",
    "firstName": "John",
    "lastName": "Doe2",
    "email": "john.doe@example.com",
    "country": "GB",
    "phone": "+447911123456",
    "birthDate": "1980-01-01",
    "serviceDescription": "Fast delivery",
    "url": "https://google.com",
    "category": "FOOD_DELIVERY",
    "type": "individual",
    "referrerVendorId":"63ea04cf6d3161e1ba997d52", // Referrer's vendor id
    "createOnboardingLink": true

  }
  ```
