# Face Match (Two Images)

***

```markdown
You can use the Face Match service by providing two face images to be compared.
The result will be "True" if similar or "False" if not.
```

## <mark style="color:blue;">Face Match (Two Images)</mark>

<mark style="color:green;">`POST`</mark> `https://valifystage.com/api/v1.1/face/match/`

#### Headers

| Name           | Type   | Description            |
| -------------- | ------ | ---------------------- |
| Content-Type   | string | application/json       |
| Authentication | string | Bearer \<access-token> |

#### Request&#x20;

| Name                                   | Type   | Description                                                                                                                                                                                                                              |
| -------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| data<mark style="color:red;">\*</mark> | object | <p>Request details</p><p><code>{</code> <br>  <code>first\_img: \<base64 str>,</code></p><p> <code>second\_img: \<base64 str>,</code><br>  <code>bundle\_key: \<str>,</code><br>  <code>lang: \<str></code><br><code>}</code></p><p></p> |

**Status Codes**

{% tabs %}
{% tab title="✅200 Successful" %}

```python
{
    'result': {
        'is_similar': '<bool>', 
         'confidence': '<float>'
     }, 
     'transaction_id': '<str>', 
     'trials_remaining': '<int>'
 }

```

{% endtab %}

{% tab title="400 Missing input data" %}

```python
{
    "message": "Bad Request – invalid request received (e.g. missing Bundle key, required parameters or invalid json) | Make sure all the required parameters are included"
}
```

{% endtab %}

{% tab title="401 Invalid bundle key" %}

```python
{
    "message": "Unauthorized – your Bundle key is invalid"
}
```

{% endtab %}

{% tab title="403 Access token error" %}

```python
{
    "message": "Forbidden – specified access_token could not be found"
}
```

{% endtab %}

{% tab title="404 Check the endpoint" %}

```python
{
    "message": "Not Found"
}
```

{% endtab %}

{% tab title="415 The format should be base64" %}

```python
{
    "message": "Unsupported Media Type"
}
```

{% endtab %}

{% tab title="422 Check Valify error codes" %}

```python
{
    "message": "<error-description>",
    "error_code": <valify-error-code>
}
```

{% endtab %}

{% tab title="500 Contact us" %}

```python
{
    "message": "Internal Server Error"
}
```

{% endtab %}
{% endtabs %}

***

## Integration

{% tabs %}
{% tab title="🚀Postman" %}

1. Download the JSON file.

{% file src="/files/gmvWxaxvVyY1Oxs4AvDf" %}
Face Match (2 images)
{% endfile %}

2. Open Postman and click on Import.

<figure><img src="/files/Dng233eovD5ju82Bh7uD" alt=""><figcaption></figcaption></figure>

3. Drop the JSON file.

<figure><img src="/files/WetQjcu6yhoqYF8tu37w" alt=""><figcaption></figcaption></figure>

4. Click on "Face Match" then click on "Authorization" and replace the \<access token> field with your access token and then click on "Body".

<figure><img src="/files/MS4eyQrbemV8bCog9Jr4" alt=""><figcaption></figcaption></figure>

4. Click on "Face Match" then "Body" and fill in the required fields then click on "Send".

{% hint style="info" %}
Please note that the front and back images should be converted to base 64 format. This can be done via an online tool; <https://base64.guru/converter/encode/image/jpg>&#x20;
{% endhint %}

<figure><img src="/files/x7DoOW77qxJQ0IFL6uy5" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="🐍Python" %}

```python
import requests
import base64

def base64_encode(file_name):
    with open(file_name, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read()).decode()
        return encoded_string
    return ""

first_img = base64_encode('<image path>')
second_img = base64_encode('<image path>')
token = '<token>'
data = {
        'first_img': first_img,
        'second_img': second_img,
        'bundle_key': '<bundle key>', # Place your bundle key here
        'lang': '<lang>' # optional
}

r = requests.post("https://valifystage.com/api/v1/face/match",
        json=data,
        headers={'Authorization': 'Bearer %s' % token}
    )
                      
print(r.json())
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://valify.gitbook.io/documentation/apis/face-match/face-match-two-images.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
