Start onboarding session

Introduction

Creating an onboarding session will provide us with a Session Token, required to add more data to our session later.

Requirements

  • x-api-key header is required with it's value set to your Api Key
  • api-version header is required and must be set to 1.0
  • configurationId field in the request body. Provide your Configuration Id
  • externalCustomerId field (Optional). If you have an id in your application that identifies the user doing the onboarding, you can provide it here.

Sample code

Starting an onboarding session is quite straightforward.

  1. Call the Start onboarding endpoint, providing your Configuration Id
  2. Store the Session Token contained in the response, under the token property. We will need it later when calling the subsequent endpoints.
curl --location 'https://demo-api.incodesmile.com/omni/start' \
--header 'Content-Type: application/json' \
--header 'api-version: 1.0' \
--header 'x-api-key: <your_api_key>' \
--data '{
  "countryCode": "ALL",
  "configurationId": "<your_configuration_id>",
  "externalCustomerId" : "<your_user_id>"
}
'
const axios = require('axios');

const data = JSON.stringify({
  countryCode: "ALL",
  configurationId: "<your_configuration_id>",
  externalCustomerId: "<your_user_id>
});

const config = {
  method: 'post',
  url: 'https://demo-api.incodesmile.com/omni/start',
  headers: { 
    'Content-Type': 'application/json', 
    'api-version': '1.0', 
    'x-api-key': '<your_api_key>'
  },
  data : data
};

axios(config).then(function (response) {
  const token = response.data.token;
  console.log(token);
}).catch(function (error) {
  console.log(error);
});

var client = HttpClient.newHttpClient();

var request = HttpRequest.newBuilder()
  .uri(URI.create("https://demo-api.incodesmile.com/omni/start"))
  .header("Content-Type", "application/json")
  .header("api-version", "1.0")
  .header("x-api-key", "<your_api_key>")
  .POST(BodyPublishers.ofString("{\"countryCode\":\"ALL\",\"configurationId\":\"<your_configuration_id>\", \"externalCustomerId\": \"<your_user_id>\"}"))
  .build();

var response = client.send(request, BodyHandlers.ofString());
var jsonResponse = new JSONObject(response.body());
var token = jsonResponse.getString("token");
System.out.println(token);
using var client = new HttpClient();

var json = "{\"countryCode\":\"ALL\",\"configurationId\":\"<your_configuration_id>\", \"externalCustomerId\": \"<your_user_id>\"}";
var content = new StringContent(json, Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("api-version", "1.0");
client.DefaultRequestHeaders.Add("x-api-key", "<your_api_key>");

var response = await client.PostAsync("https://demo-api.incodesmile.com/omni/start", content);
var responseString = await response.Content.ReadAsStringAsync();
var token = JObject.Parse(responseString)["token"].ToString();
Console.WriteLine(token);
import requests

url = "https://demo-api.incodesmile.com/omni/start"

payload = {
    "countryCode": "ALL",
    "configurationId": "<your_configuration_id>",
    "externalCustomerId": "<your_user_id>"
}
headers = {
    'Content-Type': 'application/json',
    'api-version': '1.0',
    'x-api-key': '<your_api_key>'
}

response = requests.post(url, json=payload, headers=headers)
token = response.json()['token']
print(token)

🚧

Make sure to do proper error handling and validations in your application.

The provided sample code is for learning purposes. It only contains the basics


What’s Next