Customer Management (Customer Managed) Tutorial
How to manage customer authentication
1
Requesting an anonymous token
curl -i -X GET
'https://api.emporix.io/customerlogin/auth/anonymous/login?tenant={tenant}&client_id={client_id_storefront}'{
"token_type": "Bearer",
"access_token": "tpYgJPZqddEQ2zwfzNtx79noBP65",
"expires_in": 3599,
"refresh_token": "7FnviYrxvQWYdzUVBVTvXeNAA4Jy1HPe",
"refresh_token_expires_in": 86399,
"sessionId": "6d4d4d5e-04b9-40c5-9074-4df1405c6081",
"scope": "tenant={tenant}"
}2
Refreshing an anonymous token
curl -i -X GET \
'https://api.emporix.io/customerlogin/auth/anonymous/refresh?tenant={tenant}&refresh_token={refresh_token}&client_id={client_id_storefront}'{
"token_type": "Bearer",
"access_token": "tpYgJPZqddEQ2zwfzNtx79noBP65",
"expires_in": 3599,
"refresh_token": "7FnviYrxvQWYdzUVBVTvXeNAA4Jy1HPe",
"refresh_token_expires_in": 86399,
"sessionId": "6d4d4d5e-04b9-40c5-9074-4df1405c6081",
"scope": "tenant={tenant}"
}3
Creating a new customer
curl -i -X POST
'https://api.emporix.io/customer/{tenant}/signup'
-H 'Authorization: Bearer {anonymous_access_token}'
-H 'Content-Type: application/json'
-d '{
"email": "[email protected]",
"password": "password123",
"customerDetails": {
"title": "MR",
"firstName": "John",
"middleName": "",
"lastName": "Doe",
"contactEmail": "[email protected]",
"contactPhone": "123456789",
"company": "Emporix",
"preferredLanguage": "en_US",
"preferredCurrency": "EUR",
"preferredSite": "main",
"b2b": {
"companyRegistrationId": "123-456-789",
"legalEntities": [
{
"id": "67e162a3ad4e2f12bc4f9306",
"name": "ABC",
"contactAssignmentId": "91033918"
}
]
}
},
"customerAddress": {
"contactName": "John Doe",
"companyName": "Emporix",
"street": "Platz der Republik",
"streetNumber": "1",
"streetAppendix": "",
"extraLine1": "",
"extraLine2": "",
"zipCode": "11011",
"city": "Berlin",
"country": "DE",
"state": "Berlin",
"contactPhone": "123456789",
"tags": ["BILLING", "SHIPPING"]
}
}'4
5
Logging in a customer
curl -i -X POST
'https://api.emporix.io/customer/{tenant}/login'
-H 'Authorization: Bearer {anonymous_access_token}'
-H 'Content-Type: application/json'
-d '{
"email": "[email protected]",
"password": "password123"
}'{
"access_token": "aYR3Lu3rpsQ9ODhBIR83b3txTr5K",
"saas_token": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMzg2OTAwMCIsImV4cCI6MTY0MDQ0NDAzMn0.lvxFOeCOk-DWi3kqwJwR8eKal3ON2rr53e9I6Pha5rI",
"expires_in": 2591999,
"refresh_token": "94tKQ2Tsvlf9dYbmyccA7X1Rqe54B6dH",
"refresh_token_expires_in": 86399,
"token_type": "Bearer",
"session_id": "45c9726e-77c8-4bd0-b29d-61ab56f59726",
"initialPassword": false
}6
7
Validating a token
curl -i -X GET \
'https://api.emporix.io/customer/{tenant}/validateauthtoken' \
-H 'Authorization: Bearer {customer_access_token}'{
"token_type": "Bearer",
"expires_in": 2591974,
"scope": "approval.approval_read_own customermanagement.legalentity_read_own customer.customer_read_own quote.quote_read_own returns.returns_read_own iam.scope_read_own iam.user_read_own customersegment.segment_read_own iam.group_read_own order.order_readascustomer coupon.coupon_redeem customer.customerprofile_edit quote.quote_manage_own returns.returns_manage_own customer.customer_manage_own approval.approval_manage_own order.order_updateascustomer iam.assignment_delete_own customer.consent_view customer.customerprofile_view order.history_view iam.assignment_create_own customer.consent_manage tenant=test",
"sessionId": "415c340b-5996-4112-bb3b-38139a409f93",
"email": "[email protected]",
"legalEntityId": "53ac81fd0cce8b26b36f3492"
}8
Logging in a customer using social login
curl -i -X POST \
'https://api.emporix.io/customer/{tenant}/socialLogin?code={authorization_code}&redirect_uri={redirect_uri}&code_verifier={code_verifier}' \
-H 'Authorization: Bearer {anonymous_access_token}' \
-H 'session-id: {session_id}'{
"social_access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"social_id_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "94tKQ2Tsvlf9dYbmyccA7X1Rqe54B6dH",
"refresh_token_expires_in": "86399",
"session_idle_time": 3600,
"token_type": "Bearer",
"access_token": "aYR3Lu3rpsQ9ODhBIR83b3txTr5K",
"saas_token": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMzg2OTAwMCIsImV4cCI6MTY0MDQ0NDAzMn0.lvxFOeCOk-DWi3kqwJwR8eKal3ON2rr53e9I6Pha5rI",
"expires_in": "2591999",
"scope": "tenant={tenant}"
}How to manage a customer's profile
1
Retrieving a customer profile
curl -i -X GET
'https://api.emporix.io/customer/{tenant}/me?expand=addresses,mixin:*'
-H 'Authorization: Bearer {customer_access_token}'{
"title": "MR",
"firstName": "John",
"lastName": "Doe",
"contactPhone": "123456789",
"company": "Emporix",
"preferredLanguage": "en_US",
"preferredCurrency": "USD",
"preferredSite": "default",
"metadata": {
"mixins": {},
"version": 2
},
"mixins": {},
"customerNumber": "13869000",
"id": "13869000",
"accounts": [
{
"id": "[email protected]"
}
],
"contactEmail": "[email protected]",
"businessModel": "B2B",
"b2b": {
"companyRegistrationId": "123-456-789",
"legalEntities": [
{
"id": "D165356",
"name": "Emporix",
"contactAssignmentId": "D436432"
}
]
}
}2
Updating a customer profile
curl -i -X PATCH
'https://api.emporix.io/customer/{tenant}/me'
-H 'Authorization: Bearer {customer_access_token}'
-H 'Content-Type: application/json'
-d '{
"title": "MR",
"firstName": "John",
"lastName": "Doe",
"contactEmail": "[email protected]",
"contactPhone": "123456789",
"company": "Emporix",
"preferredLanguage": "en_US",
"preferredCurrency": "EUR",
"preferredSite": "DE",
"b2b": {
"companyRegistrationId": "123-456-789"
},
"metadata": {
"version": 1
}
}'3
Adding an address to a customer profile
curl -i -X POST
'https://api.emporix.io/customer/{tenant}/me/addresses'
-H 'Authorization: Bearer {customer_access_token}'
-H 'Content-Type: application/json'
-d '{
"contactName": "John Doe",
"companyName": "Emporix",
"street": "Platz der Republik",
"streetNumber": "1",
"streetAppendix": "",
"extraLine1": "",
"extraLine2": "",
"extraLine3": "",
"extraLine4": "",
"zipCode": "11011",
"city": "Berlin",
"country": "DE",
"state": "Berlin",
"contactPhone": "123456789",
"tags": ["BILLING", "SHIPPING"]
}'{
"id": "b05c20e034"
}4
Retrieving customer addresses
curl -i -X GET
'https://api.emporix.io/customer/{tenant}/me/addresses'
-H 'Authorization: Bearer {customer_access_token}'[
{
"contactName": "John Doe",
"companyName": "Emporix",
"street": "Platz der Republik",
"streetNumber": "1",
"streetAppendix": "",
"extraLine1": "",
"extraLine2": "",
"extraLine3": "",
"extraLine4": "",
"zipCode": "11011",
"city": "Berlin",
"country": "DE",
"state": "Berlin",
"contactPhone": "123456789",
"tags": ["BILLING", "SHIPPING"],
"id": "b05c20e034",
"isDefault": true
}
]5
Retrieving a specific customer address
curl -i -X GET
'https://api.emporix.io/customer/{tenant}/me/addresses/{addressId}'
-H 'Authorization: Bearer {customer_access_token}'{
"contactName": "John Doe",
"companyName": "Emporix",
"street": "Platz der Republik",
"streetNumber": "1",
"streetAppendix": "",
"extraLine1": "",
"extraLine2": "",
"extraLine3": "",
"extraLine4": "",
"zipCode": "11011",
"city": "Berlin",
"country": "DE",
"state": "Berlin",
"contactPhone": "123456789",
"tags": ["BILLING", "SHIPPING"],
"id": "b05c20e034",
"isDefault": true
}6
Updating a customer address
curl -i -X PATCH
'https://api.emporix.io/customer/{tenant}/me/addresses/{addressId}'
-H 'Authorization: Bearer {customer_access_token}'
-H 'Content-Type: application/json'
-d '{
"contactName": "John Doe",
"companyName": "Emporix",
"street": "Platz der Republik",
"streetNumber": "2",
"streetAppendix": "Platz",
"extraLine1": "",
"extraLine2": "",
"extraLine3": "",
"extraLine4": "",
"zipCode": "11011",
"city": "Berlin",
"country": "DE",
"state": "Berlin",
"contactPhone": "123456789",
"tags": ["BILLING", "SHIPPING"],
"isDefault": true
}'7
8
How to manage customer credentials
1
Requesting a password reset
curl -i -X POST
'https://api.emporix.io/customer/{tenant}/password/reset'
-H 'Authorization: Bearer {anonymous_access_token}'
-H 'Content-Type: application/json'
-d '{
"email": "[email protected]",
"site": "main"
}'2
Resetting a password using token
curl -i -X POST
'https://api.emporix.io/customer/{tenant}/password/reset/update'
-H 'Authorization: Bearer {anonymous_access_token}'
-H 'Content-Type: application/json'
-d '{
"token": "beExUmshJC5gnuXk1kET5dCLyQWkrAfKRGFOxVXLcJI13R1fn5USjaWku5G71whM",
"password": "P@ssw0rd123"
}'3
4
Request an email change
curl -i -X POST
'https://api.emporix.io/customer/{tenant}/me/accounts/internal/email/change'
-H 'Authorization: Bearer {customer_access_token}'
-H 'Content-Type: application/json'
-d '{
"email": "[email protected]",
"password": "password123",
"newEmail": "[email protected]",
"syncContactEmail": true
}'5
Last updated
Was this helpful?

