> 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-initiation.md).

# Transaction Initiation

## Selfie ID Init - Provisioning

The SelfieID-Based Authentication Provisioning starts when a user initiates a request to set up Selfie ID credentials. The server then provides a session ID, bearer token, and a follow-up URL. To finalize the authentication setup, the user must send their selfie image to the follow-up URL specified by the server.

### API  Description

**Method** : `GET`

**URL** : `https://{environment-url}/realms/{partner-id}/protocol/api/init`

#### Parameter

| Name                                             | Type   | Description                                                                 |
| ------------------------------------------------ | ------ | --------------------------------------------------------------------------- |
| client\_id<mark style="color:red;">\*</mark>     | String | A unique client id that is shared for each partner.                         |
| client\_secret<mark style="color:red;">\*</mark> | String | A unique key that is generated for each parter and will be provided by VIDA |
| type<mark style="color:red;">\*</mark>           | String | Type of the authentication  `FaceID`                                        |

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

```json
{
    "uri": "https://{environment-url}/realms/{partner-id}/protocol/api/authenticate",
    "bearerToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIzZTU4Yjc4ZC1mMDE2LTQwMWMtYTI1Yi0zMzQ3Mzk2MWRlYzgiLCJleGVjdXRpb24iOiJhYmVjYWVjZS03ZmZmLTQ0Y2QtYTQ5Mi1hYTQ3Y2ZhMDA2N2UiLCJ0YWJfaWQiOiJkb0FmdE5ibzItOCIsIm5iZiI6MTcwMzU3OTg5Mywic2Vzc2lvbl9jb2RlIjoiRFZ1cFdUeENINlJKTW03UlRJdnN6NU5Nc1c2Rlh1SzRrYldULXVWdVVYbyIsInNlc3Npb25faWRlbnRpZmllciI6ImRvQWZ0TmJvMi04IiwiZXhwIjoxNzAzNTgwMTkzLCJpYXQiOjE3MDM1Nzk4OTMsImF1dGhfc2Vzc2lvbl9pZCI6IjNlNThiNzhkLWYwMTYtNDAxYy1hMjViLTMzNDczOTYxZGVjOCIsImp0aSI6ImMxZjgxMmJmLWZiYzMtNGRiMy04NDBjLWZhZDU3NDI2ZDRjYiJ9.iztTiqwC7T0TlDtHNmzfYfwwoEb7g5_yNCkXuhvrDOw",
    "authType": "FaceID",
    "sessionIdentifier": "doAftNbo2-8"
}
```

{% endtab %}
{% endtabs %}

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

```http
curl --location --request GET 'https://{environment-url}/realms/{partner-id}/protocol/api/init?type=FaceID&client_id=api&client_secret=enESfot4PPpSWxTa74vR8D9nrW4UTtT3'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://{environment-url}/realms/{partner-id}/protocol/api/init?type=FaceMatch&client_id=api&client_secret=enESfot4PPpSWxTa74vR8D9nrW4UTtT3"

payload={}
headers = {}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
var axios = require('axios');

var config = {
  method: 'get',
  url: 'https://{environment-url}/realms/{partner-id}/protocol/api/init?type=FaceMatch&client_id=api&client_secret=enESfot4PPpSWxTa74vR8D9nrW4UTtT3',
  headers: { }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://{environment-url}/realms/{partner-id}/protocol/api/init?type=FaceMatch&client_id=api&client_secret=enESfot4PPpSWxTa74vR8D9nrW4UTtT3")
  .method("GET", body)
  .build();
Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new RestClient("https://{environment-url}/realms/{partner-id}/protocol/api/init?type=FaceMatch&client_id=api&client_secret=enESfot4PPpSWxTa74vR8D9nrW4UTtT3");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://{environment-url}/realms/{partner-id}/protocol/api/init?type=FaceMatch&client_id=api&client_secret=enESfot4PPpSWxTa74vR8D9nrW4UTtT3',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}
{% endtabs %}

### Success Response

The follow up request can be initiated with the URI and the bearerToken along with the required parameters using the Transaction Completion API. &#x20;

```json
{
    "uri": "https://{environment-url}/realms/{partner-id}/protocol/api/authenticate",
    "bearerToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIzZTU4Yjc4ZC1mMDE2LTQwMWMtYTI1Yi0zMzQ3Mzk2MWRlYzgiLCJleGVjdXRpb24iOiJhYmVjYWVjZS03ZmZmLTQ0Y2QtYTQ5Mi1hYTQ3Y2ZhMDA2N2UiLCJ0YWJfaWQiOiJkb0FmdE5ibzItOCIsIm5iZiI6MTcwMzU3OTg5Mywic2Vzc2lvbl9jb2RlIjoiRFZ1cFdUeENINlJKTW03UlRJdnN6NU5Nc1c2Rlh1SzRrYldULXVWdVVYbyIsInNlc3Npb25faWRlbnRpZmllciI6ImRvQWZ0TmJvMi04IiwiZXhwIjoxNzAzNTgwMTkzLCJpYXQiOjE3MDM1Nzk4OTMsImF1dGhfc2Vzc2lvbl9pZCI6IjNlNThiNzhkLWYwMTYtNDAxYy1hMjViLTMzNDczOTYxZGVjOCIsImp0aSI6ImMxZjgxMmJmLWZiYzMtNGRiMy04NDBjLWZhZDU3NDI2ZDRjYiJ9.iztTiqwC7T0TlDtHNmzfYfwwoEb7g5_yNCkXuhvrDOw",
    "authType": "FaceID",
    "sessionIdentifier": "doAftNbo2-8"
}
```

Response Schema

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

### Error Response

```json
{
    "error": "invalid_request",
    "errorDescription": "Client ID invalid"
}
```

Response Schema

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

### Error Codes

If a request to our API is successful, it will return an HTTP status code `200 (OK)`

For a complete list of error codes and their meanings, refer to the Error Scenarios section.

{% hint style="info" %}
To complete the Selfie ID Authentication process, follow up by using the Selfie ID Authentication Completion API.
{% endhint %}
