Create a session

Please use our Yoti SDKs to automatically build the relevant request.

The Yoti SDKs are available via popular dependency management systems.

npm install -S -E yoti
// Get the Yoti PHP SDK library via a Composer package
composer require yoti/yoti-php-sdk
pip install yoti
// If you are using Maven, add the following dependency:
<dependency>
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-impl</artifactId>
<version>3.10.0</version>
</dependency>

// If you are using Gradle, add the following dependency:
compile group: 'com.yoti', name: 'yoti-sdk-impl', version: '3.10.0'
go get "github.com/getyoti/yoti-go-sdk/v2"
// To install the Yoti NuGet package you will need to install NuGet.
// To import the latest Yoti SDK into your project, enter the following
// command from NuGet Package Manager Console in Visual Studio:

Install-Package Yoti

// For other installation methods, see https://www.nuget.org/packages/Yoti

Once you have added the Yoti SDK dependency to your project, you can use it to build and send your request. See the code snippets below for examples of how to construct the promise.

const { RequestBuilder, Payload } = require("yoti");

const request = new RequestBuilder()
.withBaseUrl("https://api.yoti.com/sandbox/idverify/v1")
.withPemFilePath("<YOTI_KEY_FILE_PATH>") // file path to PEM file
.withEndpoint("/sessions")
.withPayload(new Payload(SESSION_OBJ))
.withMethod("POST")
.withQueryParam("sdkId", "<YOTI_CLIENT_SDK_ID>")
.build();

//get Yoti response
const response = await request.execute();
<?php
use Yoti\Http\RequestBuilder;
use Yoti\Http\Payload;

$request = (new RequestBuilder())
->withBaseUrl('https://api.yoti.com/sandbox/idverify/v1')
->withPemFilePath('<YOTI_KEY_FILE_PATH>')
->withEndpoint('/sessions')
->withPayload(Payload::fromString(SESSION_JSON_STRING)) // * Version ^2: new Payload(SESSION_OBJ)
->withMethod('POST')
->withQueryParam('sdkId', '<YOTI_CLIENT_SDK_ID>')
->build()
//get Yoti Response
->execute();

// * For JSON data in Version >3 please use Payload::fromJsonData(SESSION_OBJ)
from yoti_python_sdk.http import SignedRequest, RequestHandler
import json
import requests

def execute(request):
response = requests.request(
url=request.url, data=request.data, headers=request.headers, method=request.method)
return response.content

def generate_session():

payload = {} # payload
payload_string = json.dumps(payload).encode()
signed_request = (
SignedRequest
.builder()
.with_pem_file("<YOTI_KEY_FILE_PATH>")
.with_base_url("https://api.yoti.com/sandbox/idverify/v1")
.with_endpoint("/sessions")
.with_http_method("POST")
.with_param("sdkId", "<YOTI_CLIENT_SDK_ID>")
.with_payload(payload_string)
byte[] SESSION_OBJ = ...

try {
SignedRequest signedRequest = SignedRequestBuilder.newInstance()
.withKeyPair(<YOTI_KEY_FILE_PATH>)
.withBaseUrl("https://api.yoti.com/sandbox/idverify/v1")
.withEndpoint("/sessions")
.withPayload(SESSION_OBJ)
.withHttpMethod("POST")
.withQueryParameter("sdkId", "<YOTI_CLIENT_SDK_ID>")
.build();

YourPojo yourPojo = signedRequest.execute(YourPojo.class);

} catch (GeneralSecurityException | URISyntaxException | IOException | ResourceException ex) {
ex.printStackTrace();
}
import (
"io/ioutil"
"net/http"
"github.com/getyoti/yoti-go-sdk/v2/requests"
)

key, _ := ioutil.ReadFile("<YOTI_KEY_FILE_PATH>")
// Create session
request, _ := requests.SignedRequest{
HTTPMethod: http.MethodPost,
BaseURL: "https://api.yoti.com/sandbox/idverify/v1",
Endpoint: "/sessions",
Params: map[string]string{
"sdkId": "<YOTI_CLIENT_SDK_ID>"
},
Headers: map[string][]string{
"Content-Type": {"application/json"},
"Accept": {"application/json"}
},
Body: func(data []byte, _ error) []byte {
return data
}(json.Marshal(jsonobj{ data },
})),
}.WithPemFile(key).Request()
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using Microsoft.AspNetCore.Mvc;
using Yoti.Auth.Web;

HttpClient httpClient = new HttpClient();
StreamReader privateKeyStream = System.IO.File.OpenText("PEM_FILE_PATH");

string serializedRequest = Newtonsoft.Json.JsonConvert.SerializeObject(new
{
client_session_token_ttl = 600,
resources_ttl = 604800
...
});

byte[] byteContent = Encoding.UTF8.GetBytes(serializedRequest);

Uri _baseUrl = new UriBuilder("https", "api.yoti.com", 443, "sandbox/idverify/v1").Uri;

Yoti.Auth.Web.Request ageScanRequest = new RequestBuilder()
.WithStreamReader(privateKeyStream)
.WithBaseUri(_baseUrl)
.WithEndpoint("/sessions")

Creating Session Object

Below is the full payload example of the request for creating the session.

You will need to specify the identity profile scheme you wish to use:

  • RTW/RTR

  • DBS

  • IDENTITY

  • CUSTOM

Payload Examples

{
"client_session_token_ttl": 600,
"resources_ttl": 604800,
"user_tracking_id": "<YOUR_USER_ID>",
"notifications": {
"endpoint": "https://yourdomain.example/idverify/updates",
"topics": [
"resource_update",
"task_completion",
"check_completion",
"session_completion"
],
"auth_token": "username:password"
},
"identity_profile_requirements": {
"trust_framework": "UK_TFIDA",
"scheme": {
"type": "RTW"
}
},
"sdk_config": {
"allowed_capture_methods": "CAMERA",
"primary_colour": "#2d9fff",
"success_url": "https://yourdomain.example/success",
"error_url": "https://yourdomain.example/error"
{
"client_session_token_ttl": 600,
"resources_ttl": 604800,
"user_tracking_id": "<YOUR_USER_ID>",
"notifications": {
"endpoint": "https://yourdomain.example/idverify/updates",
"topics": [
"resource_update",
"task_completion",
"check_completion",
"session_completion"
],
"auth_token": "username:password"
},
"identity_profile_requirements": {
"trust_framework": "UK_TFIDA",
"scheme": {
"type": "DBS",
"objective": "BASIC"
}
},
"sdk_config": {
"allowed_capture_methods": "CAMERA",
"primary_colour": "#2d9fff",
"success_url": "https://yourdomain.example/success",
{
"client_session_token_ttl": 600,
"resources_ttl": 604800,
"user_tracking_id": "<YOUR_USER_ID>",
"notifications": {
"endpoint": "https://yourdomain.example/idverify/updates",
"topics": [
"resource_update",
"task_completion",
"check_completion",
"session_completion"
],
"auth_token": "username:password"
},
"advanced_identity_profile_requirements": {
"profiles": [
{
"trust_framework": "YOTI_GLOBAL",
"schemes": [
{
"type": "IDENTITY",
"objective": "AL_M1",
"label": "EXAMPLE-AL-M1"
}
{
"client_session_token_ttl": 600,
"resources_ttl" = 604800,
"requested_checks": [
{
"type": "ID_DOCUMENT_AUTHENTICITY",
"config": {
"manual_check": "NEVER"
}
},
{
"type": "LIVENESS",
"config": {
"liveness_type": "ZOOM",
"max_retries": 3
}
},
{
"type": "ID_DOCUMENT_FACE_MATCH",
"config": {
"manual_check": "NEVER"
}
},
{
"type": "WATCHLIST_SCREENING",
"config": {
"manual_check": "NEVER",
"categories": [

Example Response

If the request is successful and a session is generated the API will send a response in the form:

{
"client_session_token_ttl": 599,
"client_session_token": "<uuid>",
"session_id": "<uuid>"
}

Response

Description

client_session_token_ttl

Time in seconds until the client session expires

client_session_token

Used to authenticate the session

session_id

ID of the session