# National Identity

{% hint style="info" %}
This endpoint only supports Indonesian identity cards (KTP)
{% endhint %}

{% embed url="<https://youtu.be/8aZIGgGsmu0>" %}

## Endpoints

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

### 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>Boolean</p><p><strong><code>(Default: true)</code></strong></p>  | Use card detection model                                                                                                                                                                              |
| passCardDetect                                              | <p>Boolean</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>Boolean</p><p><strong><code>(Default: false)</code></strong></p> | If `true`, the system will flip your image                                                                                                                                                            |
| checkFlipImage                                              | <p>Boolean</p><p><strong><code>(Default: false)</code></strong></p> | If `true`, the system will check whether your image is flipped or not                                                                                                                                 |
| validateResult                                              | <p>Boolean</p><p><strong><code>(Default: false)</code></strong></p> | If `true`, you will get format validation information about result.                                                                                                                                   |
| {% 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,
  "validateResult": true
}
```

{% endtab %}
{% endtabs %}

### **Response**

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

| Field         | Type                                                                       | Description       |
| ------------- | -------------------------------------------------------------------------- | ----------------- |
| identityId    | `String`                                                                   | Identity id (NIK) |
| fullName      | `String`                                                                   | Full name         |
| birthPlace    | `String`                                                                   | Place of birth    |
| birthDate     | <p><code>Date</code> </p><p><strong><code>(dd-mm-yyyy)</code></strong></p> | Date of birth     |
| gender        | `String`                                                                   | Gender            |
| address       | `String`                                                                   | Address           |
| province      | `String`                                                                   | Province          |
| city          | `String`                                                                   | City              |
| district      | `String`                                                                   | District          |
| village       | `String`                                                                   | Village           |
| rtrw          | `String`                                                                   | RT/RW             |
| religion      | `String`                                                                   | Religion          |
| maritalStatus | `String`                                                                   | Marital status    |
| occupation    | `String`                                                                   | Occupation        |
| nationality   | `String`                                                                   | Nationality       |

`information`

<table><thead><tr><th width="196.41311856857652">Field</th><th width="190.62541806020067">Type</th><th>Description</th></tr></thead><tbody><tr><td>tilt</td><td><code>Float</code></td><td>Tilt degree (0-360) on identity card. If it is upside-down, then the value is 180.</td></tr><tr><td>cardDetected</td><td><code>Boolean</code></td><td>Return true if out system detected identity card on the image.</td></tr></tbody></table>
{% endtab %}

{% tab title="Example" %}

```
{
  "message": "string",
  "data": {
    "id": "string",
    "result": {
      "identityId": "string",
      "fullName": "string",
      "birthPlace": "string",
      "birthDate": "string",
      "gender": "string",
      "address": "string",
      "province": "string",
      "city": "string",
      "district": "string",
      "village": "string",
      "rtrw": "string",
      "religion": "string",
      "maritalStatus": "string",
      "occupation": "string",
      "nationality": "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="261">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" %}
In general, the error response structure is as belo&#x77;**:**

```
{
   "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.
