Skip to main content

Subrite API: Third-Party Integration Guide

Overview

The purpose of this document is to help third-party applications integrate with Subrite API and utilize the correct API calls to meet business needs. This guide provides examples of key business operations that can be performed using Subrite API.

Scope of Integration

Third-party applications integrating with Subrite API should aim to maintain existing functionalities while ensuring smooth operations. The tasks to be performed are defined based on business requirements and may include:

  1. Fetching Member Information
  2. Checking if an Email Exists Before Creation
  3. Updating an Existing Member with a New Membership
  4. Creating a New Member with a New Membership
  5. Updating Custom Properties

This guide is designed to assist any third-party service provider in integrating with Subrite API efficiently, ensuring seamless user experience and data consistency.

Prerequisites

Before integrating with the Subrite API, ensure you meet the following requirements:

1️⃣ Obtain M2M Access Token

Subrite API requires an M2M (Machine-to-Machine) access token for authentication. You can generate the token from the respective environment:

Stage Environment

Production Environment

Process to create a M2M token:

Create a M2M token granting Member and Subscription permissions. You will receive the token once you click save.

Create a M2M token

API Details Specification

This section provides details on various API operations available for third-party integration.

🔍 Filter Members

To find an existing member using email or custom properties, you can use the following API call:

📌 API Call

POST /api/v1/members/filter

📌 Headers

Authorization: Bearer {m2m_token}
Content-Type: application/json

📌 Body

{
"filter": [
{
"field": "updatedAt",
"operator": "gte",
"value": "2024-01-08T07:02:23.742Z"
},
{
"field": "email",
"operator": "eq",
"value": "[email protected]"
},
{
"field": "customProperty.propertyKey",
"operator": "eq",
"value": 1144
},
{
"field": "subscriptionPlanId",
"operator": "eq",
"value": 17
},
{
"field": "subscriptionPlanStatus",
"operator": "eq",
"value": "active"
}
]
}

📌 Response

{
"items": [
{
"id": "string", // Updated: memberId is now a string,Ex: "1", "c29a724f-36cf-4584-9d47-1cdde8733f75" etc
"fullName": "string",
"nickName": "string",
"email": "string",
"birthDate": "2024-01-08T07:02:23.742Z",
"phone": "+4793155388", // Updated: Remove countryCode Return Phone along with calling code
"isCompany": true,
"companyName": "string",
"organizationNo": "string",
"memberNumber": 1234, // memberNumber is a number
"customPropertyValues": {
"propertyKey": "propertyValue"
}
}
]
}

More details on this API can be found here: Get all members of the tenant with filter & pagination.

🔍 Create or Update a Member

When integrating with Subrite API, you must first check if a member exists before deciding whether to create a new member or update an existing one.

⚠️ Important Notes:

  • If you attempt to create a member with an existing email, customPropertyKey1, or customPropertyKey2, the API will reject the request.
  • To avoid conflicts, always check if the member exists first before making a create request.

🔍 Step 1: Check if the Member Exists

Use the Filter Members API (as described in the previous section) to check if a member exists.

  • If the member exists, the response will include a memberId.
  • Use this memberId to update the member instead of creating a new one.

More details on creating and updating members will be covered in the following sections.

🆕 Create a Member

To create a new member in Subrite, use the following API request.

📌 API Call

POST /api/v1/members

📌 Headers

Authorization: Bearer {m2m_token}
Content-Type: application/json

📌 Body

{
"fullName": "string",
"email": "string",
"phone": "+4712345678", // Updated: Remove countryCode, Send calling code along with phone
"birthDate": "2024-01-08T11:26:36.376Z",
"nickName": "string",
"isCompany": true,
"companyName": "string",
"address": {
"line1": "string",
"line2": "string",
"city": "string",
"state": "string",
"postCode": "string",
"country": "string",
"addressType": "primary"
},
"customPropertyValues": {}
}

📌 Response

{
"id": "string", // Updated: memberId is now a string,Ex: "1", "c29a724f-36cf-4584-9d47-1cdde8733f75" etc
"fullName": "string",
"email": "string",
"phone": "+4793155388", // Updated: Remove countryCode Return Phone along with calling code
"birthDate": "2024-01-08T11:26:36.376Z",
"nickName": "string",
"isCompany": true,
"companyName": "string",
"memberNumber": 1234, // memberNumber is a number
"address": {
"line1": "string",
"line2": "string",
"city": "string",
"state": "string",
"postCode": "string",
"country": "string",
"addressType": "primary"
},
"customPropertyValues": {
"propertyKey": "propertyValue"
}
}

More details on this API can be found here: Create a new member.

🔄 Update a Member

To update an existing member, use the following API request.

📌 API Call

PUT /api/v1/members/{memberId}

📌 Headers

Authorization: Bearer {m2m_token}
Content-Type: application/json

📌 Body

{
"fullName": "string",
"email": "string",
"phone": "+4712345678", // Updated: Remove countryCode, Send calling code along with phone
"birthDate": "2024-01-08T11:26:36.376Z",
"nickName": "string",
"isCompany": true,
"companyName": "string",
"address": {
"line1": "string",
"line2": "string",
"city": "string",
"state": "string",
"postCode": "string",
"country": "string",
"addressType": "primary"
},
"customPropertyValues": {
"propertyKey": "propertyValue"
}
}

📌 Response

{
"id": "string", // Updated: memberId is now a string,Ex: "1", "c29a724f-36cf-4584-9d47-1cdde8733f75" etc
"fullName": "string",
"email": "string",
"phone": "+4793155388", // Updated: Remove countryCode Return Phone along with calling code
"birthDate": "2024-01-08T11:26:36.376Z",
"nickName": "string",
"isCompany": true,
"companyName": "string",
"organizationNo": "string",
"memberNumber": 1234, // memberNumber is a number
"address": {
"line1": "string",
"line2": "string",
"city": "string",
"state": "string",
"postCode": "string",
"country": "string",
"addressType": "primary"
},
"customPropertyValues": {
"propertyKey": "propertyValue"
}
}

More details on this API can be found here: Update a member.

🔄 Update a Member's Custom Properties

To update a member's custom properties, use the following API request.

📌 API Call

PATCH /api/v1/members/{memberId}

📌 Headers

Authorization: Bearer {m2m_token}
Content-Type: application/json

📌 Body

{
"customPropertyValues": {
"propertyKey": "propertyValue"
}
}

More details on this API can be found here: Update a member.

📦 Create a Subscription

To subscribe a member to a product package, use the following API request.

📌 API Call

POST /api/v1/product-packages/subscribe

📌 Headers

Authorization: Bearer {m2m_token}
Content-Type: application/json

📌 Body

{
"packageId": 17,
"paymentDate": "2024-01-08T07:43:30.122Z",
"memberId": "1" // Updated: memberId is now a string,Ex: "1", "c29a724f-36cf-4584-9d47-1cdde8733f75" etc
}

More details on this API can be found here: Create a subscription for pre-purchased package​.

📝 Summary of Key API Calls

API OperationAPI Endpoint
Fetch Member InfoPOST /api/v1/members/filter
Check if Email ExistsPOST /api/v1/members/filter
Update Existing MemberPATCH /api/v1/members/{memberId}
Create New MemberPOST /api/v1/members
Create SubscriptionPOST /api/v1/product-packages/subscribe
Update Custom PropertiesPATCH /api/v1/members/{memberId}

🔄 Changelog

📌 Filtered Members API

  • API Call: POST /api/v1/members/filter
  • Response Update:
    "phone": "+4793155388" // Removed countryCode, returning phone along with calling code

📌 Create Member API

  • API Call: POST /api/v1/members
  • Response Update:
    "phone": "+4793155388" // Removed countryCode, returning phone along with calling code

📌 Update Member API

  • API Call: PATCH /api/v1/members/{memberId}

  • Response Update:

    "phone": "+4793155388" // Removed countryCode, returning phone along with calling code

📌 Update memberId type

  • API Call: PATCH /api/v1/members/{memberId}

  • Response Update:

    "memberId": "1" // Updated: memberId is now a string,Ex: "1", "c29a724f-36cf-4584-9d47-1cdde8733f75" etc