# Passport

{% hint style="info" %}
This service supports almost **all type** of passports from around the world
{% endhint %}

## Endpoints

| Method | URL                                |
| ------ | ---------------------------------- |
| POST   | `$vision`**`/v1/ocr/id/passport`** |

### Headers

| Header          | Value                                                                |
| --------------- | -------------------------------------------------------------------- |
| `Content-Type`  | `application/json`                                                   |
| `Authorization` | `Bearer` [`YOUR_API_KEY`](https://docs.kredibel.io/authentication-1) |

### **Request**

{% hint style="info" %}
The OCR inference time may vary. It depends on many factors, one of them is the **image size**. We recommend you to **resize** the image before sending it to Kredibel system.
{% endhint %}

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

| Field                                                       | Type                                                                             | Description                                                                                                                                                                                           |
| ----------------------------------------------------------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>image</p><p><strong><code>(Required)</code></strong></p> | `<base64:image>`                                                                 | <p>Image binary encoded in base64 without \<data:image/png;>.<br>- <strong>Supports:</strong> JPG, JPEG, PNG<br>- <strong>Max Size:</strong> 2MB<br>- <strong>Recommended size:</strong> 1024x768</p> |
| cardDetect                                                  | <p><code>Boolean</code></p><p><strong><code>(Default: true)</code></strong></p>  | Use card detection model                                                                                                                                                                              |
| passCardDetect                                              | <p><code>Boolean</code></p><p><strong><code>(Default: true)</code></strong></p>  | If `false`, when identity card is not detected on the image it will return an **error message**                                                                                                       |
| flipImage                                                   | <p><code>Boolean</code></p><p><strong><code>(Default: false)</code></strong></p> | If `true`, the system will flip your image                                                                                                                                                            |
| checkFlipImage                                              | <p><code>Boolean</code></p><p><strong><code>(Default: false)</code></strong></p> | If `true`, the system will check whether your image is flipped or not                                                                                                                                 |
| {% endtab %}                                                |                                                                                  |                                                                                                                                                                                                       |

{% tab title="Example (Recommendation)" %}
You just need to declare image field in order to use this service.

```
{
  "image": "/9j/..."
}
```

{% endtab %}

{% tab title="Example (Verbose)" %}

```
{
  "image": "string",
  "cardDetect": true,
  "passCardDetect": true,
  "flipImage": true,
  "checkFlipImage": true
}
```

{% endtab %}
{% endtabs %}

### **Response**

{% tabs %}
{% tab title="Description" %}
`result`

| Field           | Type                                                                               | Description      |
| --------------- | ---------------------------------------------------------------------------------- | ---------------- |
| identityId      | `String`                                                                           | Identity id      |
| indicator       | `String`                                                                           | Indicator        |
| country         | `String`                                                                           | Country          |
| countryCode     | `String`                                                                           | Country code     |
| fullName        | `String`                                                                           | Full name        |
| nationality     | `String`                                                                           | Nationality      |
| nationalityCode | `String`                                                                           | Nationality code |
| birthDate       | `String`                                                                           | Date of birth    |
| sex             | <p><code>String</code></p><p><strong><code>\["male", "female"]</code></strong></p> | Sex              |
| personalNumber  | `String`                                                                           | Personal number  |
| expirationDate  | <p><code>Date</code> </p><p><strong><code>(dd-mm-yy)</code></strong></p>           | Expiration date  |

`information`

| Field          | Type      | Description                                                                        |
| -------------- | --------- | ---------------------------------------------------------------------------------- |
| tilt           | `Float`   | Tilt degree (0-360) on identity card. If it is upside-down, then the value is 180. |
| `cardDetected` | `Boolean` | Return true if out system detected identity card on the image.                     |
| {% endtab %}   |           |                                                                                    |

{% tab title="Example" %}

```
{
  "message": "string",
  "data": {
    "id": "string",
    "result": {
      "identityId": "string",
      "indicator": "string",
      "country": "string",
      "countryCode": "string",
      "fullName": "string",
      "nationality": "string",
      "nationalityCode": "string",
      "birthDate": "string",
      "sex": "string",
      "personalNumber": "string",
      "expirationDate": "string"
    },
    "information": {
        "tilt": float,
        "cardDetected": boolean
    }
  }
}
```

{% endtab %}
{% endtabs %}

### **Errors**

{% hint style="info" %}
Please read this [page \<Responses & Errors>](https://docs.kredibel.io/responses-and-errors) to know more about response.
{% endhint %}

**Error 4XX**

{% tabs %}
{% tab title="Error Type" %}

<table><thead><tr><th width="256">Error Type</th><th width="352.3333333333333">Description</th><th>Is charged?</th></tr></thead><tbody><tr><td>invalid_base64_encoding</td><td>Invalid base64 encoding.</td><td><strong>false</strong></td></tr><tr><td>card_not_found</td><td>There is no identity card found in the image. This error only raised if you set <code>passCardDetect = False</code>.</td><td><strong>true</strong></td></tr><tr><td>text_not_found</td><td>There is no text found in the image.</td><td><strong>true</strong></td></tr><tr><td>invalid_document_type</td><td>The document sent does not appear to be the right identity type.</td><td><strong>true</strong></td></tr><tr><td>parsing_failed</td><td>System fail to parse identity card.</td><td><strong>true</strong></td></tr></tbody></table>
{% endtab %}

{% tab title="Structure" %}

```
{
   "errors":{
      "errorId": <log_id:uuid>,
      "errorType": <error_type:str>
   },
   "message": <message:str>
}
```

{% endtab %}
{% endtabs %}

**Error 5XX**

**F**or every 5XX http code response, there will be no charge.
