Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Self-Service API

CRM.COM has a concept of Contacts that represent the customers of a business and can either be a person ( B2C ) or a business ( B2B ).

...

In the example the minimal amount of data collected  of a user forename and surname, and the Identity information of the Phone Number.

Step 1 - Register a new customer

New customers can be registered by collecting a minimal amount of customer data including Title, Forename, Surname and a way of providing credentials for future authentication. Optionally the contact can use OTP via email or Phone for future authentication. If using OTP make sure you have configured an SMS or Email provider in the  Platform → Integrations menu.

Code Block
POST /contacts/register HTTP/1.1 

api_key: ab5f8b2e-092f-4848-8f46-31df1c014060
Content-Type: application/json

{
    "first_name": "Ahmed",
    "last_name": "Samir",
    "identity": {
        "provider": "PHONE",
        "phone_number": "9947823",
        "country_code": "CYP"
    },
    "service_acceptance": "true",
    "email_opt_out": "true",
    "sms_opt_out": "true"
}

Step 2

If the Registration required an OTP to be sent then the system will send a unique code via either email or SMS system. This code is then validated, and if validated then an Authenticated JWT token will be return for further API actions.

Code Block
curl --location --request POST 'https://app.crm.com/self-service/v1/contacts/validate-otp' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'api_key: af42c488-b040-4991-b300-97378626fd63' \
--data-raw '{
    "credentials": [
        {
            "name": "EMAIL",
            "value": "andystewarduk+me1@gmail.com"
        }
    ],
    "code": "812279"
}'

Step 3

If the OTP is validated, then the response of the API provides

...

The authentication tokens are JWT token that can be used for subsequent API calls that require authentication.

Step 4 –  Request an OTP token if user logged out

In order to be able to sign in again then it is possible to request an OTP and follow the same flow as on the previous step.

...

The OTP will be sent via the Selected communication PHONE (SMS) or EMAIL and the OTP validation api used in the same way as on the registration request.

Step 5 – Using a Refresh Token

 The refresh token allows the APP or portal to renew the token to allow the User to remained logged in if that behavior is required.

...

Code Block
curl -X POST "https://sandbox.crm.com/self-service/v1/contacts/refresh"  \
 -H "Authorization: eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMjc4ZDNlNS05YjhlLTQzNmUtOTIzMC03MGYzZTJkZjFjYTUiLCJleHAiOjE1Njg1NTQxMjJ9.LemqPPThkqfakkKS6CdkNvV1Lnc88CWirEpHOPnWjJPQz02zgkKSwfbvrEsl3OmR2LUhDILsOXf4x-GPFmNJCg"

Back-Office API

Contacts in the Backoffice API do not use a registration flow to capture the details and or provide Identity for authentication. Creating a contact can be used to store and manage the contact details but cannot be used to store / change authentication credentials.

Step 1 - Add Contact

Contact can be created from server-based flows or agent based flows. The CRM entities allow an external system to provide either the unique ID ( max 36 typically a guid ) or if not one will be generated and cross reference code can be used to link.

https://speca.io/CRM/backoffice-admin#create-contact

Step 2 – Add Authentication credentials

For example, in a scenario where a new user is captured and created via a server to server request or some agent based flow and the user subsequently wants to access Portals or APP’s, and access to an APP or Portal is needed.

...