Add & fetch a Member

See the sample example how a member can be added and fetched. Links to more detailed instructions can be found at the end of the article.

How this example works

In this example, you can register a new member profile using the previously specified registration method and then fetch the member details.


Try adding a member yourself

  • Input the previous saved token and storeCode in the request header

  • Add a member Endpoint: POST /api/{storeCode}/member

    {
       "customer": {
            "email": "[email protected]",
            "firstName": "John",
            "lastName": "Smith",
            "gender": "male"
        }
    }
  • This action should trigger CustomerRegistered webhook


Endpoints used

Method allows registering new member.

post

This method allows registering a new Member as an Admin.

Authorizations
AuthorizationstringRequired

Open Loyalty has the JWT authorization. To learn what a JSON Web Token is and how it works, check out Introduction to JSON Web Tokens https://jwt.io/introduction/

Obtain an access token

Send a request with the parameters username and password

Definition

POST /api/admin/login_check Go to definition
POST /api/{storeCode}/member/login_check Go to definition

Example

curl {HOST}/api/admin/login_check
    -H 'Content-Type: application/json;charset=UTF-8'
    -H 'Accept: application/json, text/plain, */*'
    --data-binary '{"username":"admin","password":"password"}'

Example Response

{
    "token":"eyJhbGciOiJSUzI1NiIsInR5cCI6...",
    "refresh_token":"0558f8bb29948c4e54c443f..."
}

Using JSON Web Token

Add authorization header to each request
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...
You can now access any API method you want under the /api prefix.

Example

curl {HOST}/api/{storeCode}/analytics/members
    -H 'Accept: application/json'
    -H 'Content-type: application/x-www-form-urlencoded'
    -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...'

Refresh JSON Web Token

You can refresh token using refresh_token that was given during login.
There are two endpoints
To refresh admin token POST /api/token/refresh Go to definition
To refresh member token POST /api/{storeCode}/token/refresh Go to definition

Path parameters
storeCodestringRequired

Store code

Body
Responses
post
/api/{storeCode}/member

Try fetching a member yourself

  • Input the previous saved token and storeCode in the request header

  • Input the customerId of the member you wish to retrieve. Endpoint: GET /api/{storeCode}/member/{member}

  • 200 Returns the complete member profile as you can see below.

The retrieved JSON object contains a wealth of information. Retrieving this data is crucial for many operations, such as:

  • Personalizing communication (e.g., "Hello John, you have 500 points!").

  • Displaying the customer's status in a mobile app or e-commerce account.

  • Making business decisions in other systems (e.g., a CRM or Marketing Automation tool).

More resources

For a detailed overview and description of the members, please refer to these series of articles:

Members

Last updated

Was this helpful?