Creating Customer Profiles

Prerequisites

  1. Successful registration of user read guide
  2. User has sucessfully logged in for fist time read guide

Linking the logged in user to fabric Customer

fabric Customer API and Model is built to be agnostic of the login mechanism used for your storefront. So the first step of registering a customer profile is to create a user in fabric Customer. If you have followed the previous guides and are using fabric Identity for handling your logins. Then a "fabric Customer" user will be created for you at the time of registation.

First try and get the existing user once the user has logged in.

Make a GET request to https://{domain}/data-customer/v1/users/{userId}

The userId that you will pass to this endpoint is fabricUserId in the access_token you obtained from the user login flow.

If the user was created during user registration you will recieve the user details for that registered user.

If you do not recieve a user object back from the API you should now call POST /data-customer/v1/users to create the customer. And pass the fabricUserId claim as the userIdentifier.

Creating a User

POST /data-customer/v1/users

{
    "userIdentifier": {access_token_jwt.fabricUserId},
    "username": {user_name_of_user} // usually the email address
    "email": {email_of_user},
    "status": "ACTIVE"
}

Creating a profile for user

Once you have obtained the "fabric Customer" user object from the previous step, you can now create the rest of the profile for the customer.

Make a call to POST https://{domain}/data-customer/v1/individuals

{
    "partyType": "P",
    "name": {name_of_customer},
    "additionalAttributes: {
        "someKey: "someData" // here you can provide any key value pair you want
    }
}

Linking the user to the individual

You now should have both a user and an individual profile. You must now link the two so you can easily retrieve the profile on the next login

Make a call to POST https://{domain}/data-customer/v1/user-party

{
    "userId": {user.id} // Not userIdentifier this must be the user object Id,
    "partyId": {party.id} // this was returned in the creation of the individual profile
}