---
title: "referralRecordCreate"
description: >
  Create a referral relationship between the referrer and the invitee based on the referral code.
doc_type: graphql
doc_category: storefront
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/docs/storefront-api/member-system/mutations/referral-record-create'
  md: 'https://developer.shopline.com/docs/storefront-api/member-system/mutations/referral-record-create.md'
---
# referralRecordCreate

Create a referral relationship between the referrer and the invitee based on the referral code.

- **API Version:** v20270301
- **API Type:** Storefront
- **API Protocol:** GraphQL
- **Operation Type:** Mutation

## Arguments

* `customerAccessToken`

  [String!](https://developer.shopline.com/docs/storefront-api/common/scalars/string.md)

  The customer access token of the invitee.

* `senderReferralCode`

  [String!](https://developer.shopline.com/docs/storefront-api/common/scalars/string.md)

  The referral code of the referrer.

## Returns

* `userErrors`

  [[MemberUserError!]!](https://developer.shopline.com/docs/storefront-api/member-system/objects/member-user-error.md)

  The errors that occur when creating a referral relationship.

* `senderCustomer`

  [ReferralSenderCustomer](https://developer.shopline.com/docs/storefront-api/member-system/objects/referral-sender-customer.md)

  The referrer information.

* `receiverCustomer`

  [ReferralReceiverCustomer](https://developer.shopline.com/docs/storefront-api/member-system/objects/referral-receiver-customer.md)

  The invitee information.

## Examples

### Create a referral relationship between the referrer and the invitee

Create a referral relationship between the referrer and the invitee.

**Request:**

```json
mutation referralRecordCreate {
  referralRecordCreate(customerAccessToken:"tokenxxx",senderReferralCode:"7M**") 
  {
   senderCustomer{
                customerId
                email
                phone
                firstName
                lastName
                levelName
                levelCode
                referralUrl
                referralCode
         },
         receiverCustomer{
             customerId
                email
                phone
                firstName
                lastName
                levelName
                levelCode
                referralUrl
                referralCode
         }

  }
}
```

**Response:**

```json
{
  "data": {
    "data": {
      "referralRecordCreate": {
        "receiverCustomer": {
          "lastName": "li",
          "levelCode": "gid://shopline/Membership/MLC644317****",
          "levelName": "middle",
          "referralCode": "G6***",
          "customerId": "gid://shopline/Customer/46037****",
          "email": "***@qq.com",
          "firstName": "zha**",
          "phone": "0086135604****",
          "referralUrl": "https://****.myshopline.com/user/signUp?referral_code=G6***&source_type=member_plugin_referral&slt=member_plugin_referral"
        },
        "senderCustomer": {
          "email": "***@qq.com",
          "firstName": "zha**",
          "customerId": "gid://shopline/Customer/420010****",
          "lastName": "mian***",
          "levelCode": "gid://shopline/Membership/MLC6443****",
          "levelName": "middle",
          "phone": "0086135604****",
          "referralCode": "7M***",
          "referralUrl": "https://***.myshopline.com/user/signUp?referral_code=7M2***&source_type=member_plugin_referral&slt=member_plugin_referral"
        }
      }
    }
  }
}
```

## Error Handling

For detailed information about common codes, see [Status and error codes](https://developer.shopline.com/docs/apps/api-instructions-for-use/storefront-api/overview.md#status-and-error-codes).

