> For the complete documentation index, see [llms.txt](https://docs.vida.id/identity-stack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vida.id/identity-stack/authentication/authentication-factors/biometric-device-selfie-id/integration-methods/selfie-id-api/api/api-reference/provisioning-registration/transaction-completion.md).

# Transaction Completion

In the authentication phase, the user presents their face for verification, and the API compares this against the stored template for validation. The process is initiated by an API call, which responds with a session ID, bearer token, and a challenge. The user then responds to this challenge by submitting a selfie.

The authentication process can follow one of three options based on the selected preference. The following types of parameters can be passed to the API:

* **Using KYC Event ID :**  `kyc_event_id` obtained during the KYC process can be included part of the request.&#x20;
* **Using Liveness Transaction ID**: The `liveliness_transaction_id`, obtained during the liveness verification process, can be included as part of the request
* **Using Template URL:** The partner can provide the URL of the template image (`template_url`), which represents the user-selfie.&#x20;
* **Using Image:** User selfie `image` can be submitted as a Base64 encoded string

### Authentication Preferences

<table><thead><tr><th width="142">Preference</th><th width="144">KYC Event ID</th><th width="159">Liveness Transaction ID</th><th width="155">Template URL</th><th>Image</th></tr></thead><tbody><tr><td><strong>Required Params</strong></td><td>kyc_event_id</td><td><code>liveliness_transaction_id</code></td><td>template_url</td><td>image (Base64)</td></tr><tr><td><strong>Preference</strong></td><td>First</td><td>Second</td><td>Third</td><td>Fourth</td></tr><tr><td><strong>User Verification</strong></td><td>User’s verification is done by VIDA, and the image from the same verification is used for authentication.</td><td>User’s liveliness has been done by VIDA’s product (liveness service or SDK) and transactionId from same is being used for authentication</td><td>User is verified by partner</td><td>User is verified by partner</td></tr><tr><td><strong>Business Use Case</strong></td><td>When partners are using KYC solution provided by VIDA.</td><td>When partner don’t want to perform liveliness again. For avoiding duplicate liveness check and reducing network latency</td><td>When partners don’t have any KYC prior integration with VIDA.</td><td>When partners don’t have any KYC prior integration with VIDA.</td></tr><tr><td><strong>Liveness During Provisioning</strong></td><td>NO</td><td>NO</td><td>YES</td><td>YES</td></tr><tr><td><strong>User Attributes stored during provisioning</strong></td><td><p></p><ol><li>kyc_event_id</li><li>credential_id</li></ol></td><td><p></p><ol><li>templateLivelinessTransactionId</li><li>credential_id</li></ol></td><td><p></p><ol><li>credential_id</li><li>liveliness related details (trxId, livelinessScore, imgManipulation Score, code, message)</li></ol></td><td><p></p><ol><li>credential_id</li><li>liveliness related details (trxId, livelinessScore, imgManipulation Score, code, message)</li></ol></td></tr><tr><td><strong>Image Storage</strong></td><td>Image fetched based on <code>kyc_event_id</code> is stored.</td><td>Image fetched from the based on <code>liveliness_transaction_id</code> is being stored</td><td>Image downloaded with the help of <code>template_url</code>.</td><td>Image supplied by partner in <code>image</code> parameter is stored.</td></tr></tbody></table>

### Selfie ID Followup - API  Description

**Method** : <mark style="color:red;">`POST`</mark>

**URL** : Follow up url received as part of the response of the Transaction Initiation API

#### Headers

<table><thead><tr><th width="155.1348876953125">Name</th><th width="154.65057373046875">Type</th><th>Description</th></tr></thead><tbody><tr><td>Authentication<mark style="color:red;">*</mark></td><td>String</td><td>Bearer {Bearer Token Received in Transaction Initiation API}</td></tr><tr><td>Content-Type</td><td>String</td><td>application/<code>x-www-form-urlencoded</code></td></tr></tbody></table>

### Parameters

**Using KYC Event ID**

<table><thead><tr><th width="154.50921630859375">Name</th><th width="154.5545654296875">Type</th><th>Description</th></tr></thead><tbody><tr><td>client_id<mark style="color:red;">*</mark></td><td>String</td><td>A unique client id that is shared for each partner</td></tr><tr><td>kyc_event_id<mark style="color:red;">*</mark></td><td>String</td><td>Obtained during the KYC process</td></tr></tbody></table>

**Using Liveness Transaction ID**

<table><thead><tr><th width="219.7073974609375">Name</th><th width="123.23565673828125">Type</th><th>Description</th></tr></thead><tbody><tr><td>client_id<mark style="color:red;">*</mark></td><td>String</td><td>A unique client id that is shared for each partner</td></tr><tr><td>liveliness_transaction_id<mark style="color:red;">*</mark></td><td>String</td><td>The liveliness verification transaction id received as part of the Vida Liveliness verification process (e.g. Vida Liveliness SDK)</td></tr></tbody></table>

**Using Template URL**

| Name                                            | Type   | Description                                         |
| ----------------------------------------------- | ------ | --------------------------------------------------- |
| client\_id<mark style="color:red;">\*</mark>    | String | A unique client id that is shared for each partner  |
| template\_url<mark style="color:red;">\*</mark> | String | template image url which represents the user-selfie |

**Using Image**

| Name                                         | Type          | Description                                        |
| -------------------------------------------- | ------------- | -------------------------------------------------- |
| client\_id<mark style="color:red;">\*</mark> | String        | A unique client id that is shared for each partner |
| image<mark style="color:red;">\*</mark>      | base64 string | Selfie Image of the user as Base 64                |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "entity": {
        "accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJYbnNBNFVPdlkyU0JLSkdnX1ppTHN1Tk8tZ2dlLVB0RXZzX2twRTBhd3RnIn0.eyJleHAiOjE3MDM1ODE5NzUsIm5iZiI6MTcwMzU4MTY3NSwiaWF0IjoxNzAzNTgxNjc1LCJhdXRoX3RpbWUiOjE3MDM1ODE2NzUsImp0aSI6IjQwODczODM2LWRkNDAtNDI0NS1iNzYwLTQ4ZjgxYTRmMzg4ZiIsImlzcyI6Imh0dHBzOi8va2V5Y2xvYWsuYXV0aC1zdGFnZS52aWRhLmlkL3JlYWxtcy9zcHJpbmdib290LXF1aWNrc3RhcnQiLCJzdWIiOiJlY2FiYzIzYS1iYThlLTQ3ZGUtYjdhNy1iZDlkZGYzZTAxNzEiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJhcGkiLCJzZXNzaW9uX3N0YXRlIjoiZWZjNmM4OGItYTIyZC00ZWFmLTgyY2MtOTg0MGViYzNlMDA0Iiwic2NvcGUiOiIiLCJzaWQiOiJlZmM2Yzg4Yi1hMjJkLTRlYWYtODJjYy05ODQwZWJjM2UwMDQiLCJreWNfZXZlbnRfaWQiOiI4MjljODM3Zi01YmFjLTQ4YWYtYTViZC0zNDk5NTFjYzM2NDgiLCJsaXZlbGluZXNzVHJhbnNjYXRpb25JZCI6IjIwMjAwNjk0LTNiYzgtNDg4OS05MTIzLWM2OTI2ZD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MTcwMzU4MTY3NSwianRpIjoiMDI5OTExNmMtMGY2OS00NjEyLTgyZTYtNzdiMzIwM2I3NDNlIiwiaXNzIjoiaHR0cHM6Ly9rZXljbG9hay5hdXRoLXN0YWdlLnZpZGEuaWQvcmVhbG1zL3NwcmluZ2Jvb3QtcXVpY2tzdGFydCIsImF1ZCI6Imh0dHBzOi8va2V5Y2xvYWsuYXV0aC1zdGFnZS52aWRhLmlkL3JlYWxtcy9zcHJpbmdib290LXF1aWNrc3RhcnQiLCJzdWIiOiJlY2FiYzIzYS1iYThlLTQ3ZGUtYjdhNy1iZDlkZGYzZTAxNzEiLCJ0eXAiOiJSZWZyZXNoIiwiYXpwIjoiYXBpIiwic2Vzc2lvbl9zdGF0ZSI6ImVmYzZjODhiLWEyMmQtNGVhZi04MmNjLTk4NDBlYmMzZTAwNCIsInNjb3BlIjoiIiwic2lkIjoiZWZjNmM4OGItYTIyZC00ZWFmLTgyY2MtOTg0MGViYzNlMDA0In0.XGkS03_dTcVCA2hwYfN-6BI1AmdoJEYIORE_i4-wD2w",
        "refreshExpiresIn": 1800,
        "authType": "FaceID"
    },
    "uri": "https://{environment-url}/realms/{partner-id}/protocol/api/authenticate",
    "bearerToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJlZmM2Yzg4Yi1hMjJkLTRlYWYtODJjYy05ODQwZWJjM2UwMDQiLCJleGVjdXRpb24iOm51bGwsInRhYl9pZCI6IkliZ3BiR2ktd2ljIiwibmJmIjoxNzAzNTgxNjc1LCJzZXNzaW9uX2NvZGUiOiJSRFpLVXFId1oxeHZseTFnYm8ySkhIblVMUkk4VEV5VjM3SVFPM0ZsTEdzIiwic2Vzc2lvbl9pZGVudGlmaWVyIjoiSWJncGJHaS13aWMiLCJleHAiOjE3MDM1ODE5NzUsImlhdCI6MTcwMzU4MTY3NSwiYXV0aF9zZXNzaW9uX2lkIjoiZWZjNmM4OGItYTIyZC00ZWFmLTgyY2MtOTg0MGViYzNlMDA0IiwianRpIjoiYmZkYmI4ZGUtZjY5MC00OWZlLWEwYjAtNzYxNjMyOGU2NDI2In0.t7hWqOupNrB_a7EMhLfthxCRfK-hDf35x09FPJFWnj0",
    "authType": "FaceID"
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Curl" %}

```http
curl --location --request POST '{{FOLLOW UP URI RECEIVED AS PART OF THE RESPONSE OF THE TRANSACTION INITIATION REQUEST}}' \
--header 'Authorization: Bearer <Bearer Token>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'image=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAMAAAD8CC+4+ipPLnhsiBY4oRVTogCWPuy71gAg5NUdg8J/wvc/wBDUDohi1/pvwAAAABJRU5ErkJggg==' \
--data-urlencode 'client_id=api'
```

{% endtab %}
{% endtabs %}

```json
{
    "uri": "{URI OF THE FOLLOW UP REQUEST FOR TRANSACTION COMPLETION}",
    "bearerToken": "{BEARER TOKEN TO BE ADDED IN AUTHORIZATION HEADER OF FOLLOW UP REQUEST}",
    "authType": "{AUTHENTICATION TYPE}",
}
```

### Error Response

```json
{
    "error": "Unprocessable Entity",
    "errorDescription": "message=Unprocessable Entity;livelinessScore=0.0;faceMatchScore=0.0"
}
```

Response Schema

```json
{
    "error": "{TYPE OF ERROR}",
    "errorDescription": "{REASONING FOR THE ERROR}"
}
```
