Create a Session

Every time an end user elects to supply an ID document on the relying party app/website/custom product, you will need to create a session with Yoti to perform the ID checks.

Before you start
You will need the Yoti App on your phone and to have registered your business with Yoti.
API Link
Jump straight to our API references with code snippets if you prefer.

Generate the request using our SDK

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

The Yoti SDKs are available via popular dependency management systems.

Javascript
PHP
Python
Java
Go
C#
Ruby
Copy

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.

Javascript
PHP
Python
Java
Go
C#
Ruby
Copy

Creating the session object

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

You will need to specify the following:

1) System preferences

  • Yoti Doc scan session length
  • User tracking
  • Status at certain points in the flow

2) Checks

  • ID Document Authenticity
  • Liveness
  • ID Document Face Match

3) Tasks

  • Document data extraction (OCR technology)

4) Client preferences

  • Camera and pre set country options and where the user should be directed after the user journey (success/error redirect URL)
NameActs onTypeComment
ID_AUTHENTICITY_CHECK1x Document ResourceAsynchronousMust wait for the TextDataCheck, if there is one.
TEXT_DATA_CHECK1x Document ResourceAsynchronousUsed to recover a failed TextExtractionTask
LIVENESS_CHECK1x Liveness ResourceSynchronousRuns as soon as the FaceMap is uploaded. Can be repeated until it succeeds, but only one successful Check is allowed in each Session.
FACEMATCH_CHECK1x Doc Resource & 1x Liveness ResourceAsynchronousMust wait for the TextDataCheck, if there is one
Good to know
The request payload should be in the following format (full details of request parameters are provided in the 'explained' section, below). This JSON string will be the SESSION_OBJ parameter in the withPayload above code snippet.
JSON
Copy

Example response

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

JSON
Copy
ResponseDescription
client_session_token_ttlTime in seconds until the client session expires
client_session_tokenUsed to authenticate the session
session_idID of the session

Creating Sessions explained

1. System preferences

The table below explains the optional parameters for the session and data retention configuration.

JSON
Copy
ParametersDescriptionRequired
client_session_token_ttlThis is how long the full Yoti Doc Scan session is open for in seconds. This must be longer than 5 minutes.optional
resources_ttlRetention period for uploaded documents/images in number of seconds. Default is one week (60*60*24*7=604800). This can be a minimum of 24 hours and must be at least 24 hours longer than the client_session_token_ttl. This starts once the client_session_token_ttl is completed.optional
user_tracking_idAllows the relying business backend to track the same user across multiple sessions. Note: Should not contain any personal identifiable information.optional
notifications { }

If provided, Yoti Doc Scan posts (POST endpoint required) an update notification every time the session state changes, based on the selected subscription topics "endpoint" : "https://yourdomain.com/idverify/updates".

Only HTTPS endpoints with TLS are supported.

If there is no 'topics' array then only session completion notifications are sent.

optional
auth_tokenAllows the relying business backend to define an authorisation token, if they have secured API endpoints, allowing Yoti to call endpoints.optional
Knowledge base
Please head over to our knowledge base for more information on notifications or selecting multiple documents / countries.

2. Checks Configuration

1) ID Document authenticity

A request to assess the characteristics of a document, to determine the validity of the ID document.

JSON
Copy

This requires there to be image media attached to the resource (images of the front and back of the document - the back of the document is not always required).

Jump to..
On successful completion, the check outputs a report in the form of a structured JSON object, which can be found in the ‘retrieve results’ section. Updates are sent to the updates URL (if subscribed to notifications).

2) Liveness

A requested check to assess whether the document scan is being performed by a real person and not someone wearing a mask or an automated system.

JSON
Copy

You must provide the max number of retries your users can have before the liveness is failed. This must be greater than 1.

An "attempt" is a completed liveness check that is either rejected or approved. If the user does not complete the liveness check this does not count as an attempt and the user will be prompted to try again.

Liveness check

Liveness check

Jump to
This will produce a liveness_capture resource in the session as well as a report in the form of a structured JSON object for each attempted liveness check.

3) ID Document face match

A request to assess whether the user's face matches the face on the ID document. The user's facial image is obtained from the liveness check, which must be performed first.

JSON
Copy

This is performed as an automated check, however you can configure whether the check is passed on to our security centre for a manual check by qualified Yoti staff. This can be set to always, fallback or never.

Manual CheckExplanation
ALWAYSThe requested check will always go to the security centre regardless of the success of the automated check.
NEVERThe requested check will never go to the security centre.
FALLBACKThe requested check will only go to the security centre if the machine check fails.
Jump to...
On successful completion, the check outputs a report in the form of a structured JSON object, which can be found in the ‘checks retrieval’ section of the session retrieval

3. Tasks Configuration

Yoti can complete the following optional task(s), if requested:

ID Document text data extraction

A request to obtain the data printed visually on a document, in structured form.

If machine data extraction is not successful, there is an option (selected at session creation) to fallback to manual data extraction. This generates a ‘text data check’ automatically, and the document is reviewed by one of our document processing experts.

JSON
Copy
Manual Data ExtractionExplanation
FALLBACKThis will initiate manual data extraction only if the automatic extraction fails. We strongly recommend this option.
NEVERIf the ID fails on automatic extraction, Yoti will not attempt manual extraction and will return a failure in the report.
ALWAYSThe document is always referred for manual review at Yoti's security centre, regardless of whether machine data extraction has succeeded or failed.
Jump to
On successful completion, see the task results section
Knowledge base
For more information on ID Document Text Data Extraction please head to our knowledge base.

4. Client Preferences

The method sdk_config is explained below. If not defined then they will be set to default (indicated)

JSON
Copy
Document capture

Document capture

TypeParameters (examples)DescriptionRequired
allowed_capture_methodsCAMERA_AND_UPLOAD, CAMERA(default)The user must use a camera to take a photo of their ID document, or the user can take a photo or has the option to upload an image of the document from file.optional
primary_colour#2d9fff(default), #ff0000Colours of the button provided in the frontend client as a hexadecimal value.optional
preset_issuing_countryUSA, GBR

The user must select the issuing country of the document they are uploading. This setting determines which issuing country is selected by default.

NOTE: Must be a 3 letter ISO code.

optional
success_urlhttps://yourdomain.com/successIf the upload/photo is successfully captured redirect your users here. Yoti will then begin to carry out the requested checks and tasks. If undefined, the page will not redirect and you can listen to Yoti's post messages on the same page.optional
error_urlhttps://yourdomain.com/errorIf the upload/photo is unsuccessfully captured redirect your users here. If undefined, the user view will display an error screen, with the error code as a query parameter and won't redirect. (Details on the error codes can be found here.)optional
localeen-GB(default)Force language locale for the frontend client. Full list shown below.optional

Supported Documents Endpoint

To see all documents that are supported for Yoti Doc Scan you can send a GET request to our supported-documents endpoint. The request is built in a similar fashion to other Yoti requests, see the example promises below.

Javascript
PHP
Python
Java
Go
C#
Ruby
Copy

Yoti will return a JSON object with countries listed by ISO country code. Each country will list an array of supported documents from that country. See the example below:

JSON
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard