> 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/verify/document-ai/ocr-and-document-verification/ocr-ktp/api-reference/sync.md).

# Sync

This API extracts information from the user’s KTP card image using OCR and  returns the extracted data in response.

## API Description

## KTP OCR Sync Call

<mark style="color:green;">`POST`</mark> `https://{vida.host}/verify/v1/ktp/ocr/transaction`

#### Headers

| Name                                            | Type             | Description                                                                                                |
| ----------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> |                  | <p>OAuth access token. </p><p>Get the token by calling the</p><p><strong>Get Access Token</strong> API</p> |
| Content-Type<mark style="color:red;">\*</mark>  | application/json | Format type of request body                                                                                |

#### Request Body

<table><thead><tr><th width="193.1640625">Name</th><th width="178.49609375">Type</th><th>Description</th></tr></thead><tbody><tr><td>ktp_image<mark style="color:red;">*</mark></td><td>String</td><td><p>Data URI scheme, Base64 encoded KTP image.</p><p><br>Supported image formats: JPG/JPEG.</p></td></tr></tbody></table>

#### Sample request json

<details>

<summary>Sample Request</summary>

```json
{
    "parameters": {
        "ktp_image": "base64 encoded.."
}
}
```

</details>

## **API Response**

### OCR Request Successful

OCR  API Request Successful.

HTTP Status Code: `200`

<details>

<summary>JSON Response</summary>

```json
{
	"data": {
		"result": {
			"provinsi": "JAWA BARAT",
			"kabupaten_kota": "KOTA BANDUNG",
			"golongan_darah": "",
			"agama": "ISLAM",
			"alamat": "SARIMANIS 13 TOWN HOUSE B3",
			"berlaku_hingga": "SEUMUR HIDUP",
			"kewarganegaraan": "WNI",
			"nik": "1234567890123456",
			"nama": "TEST NAME",
			"pekerjaan": "KARYAWAN SWASTA",
			"tempat_lahir": "BUKIT TINGGI",
			"kecamatan": "SUKASARI",
			"jenis_kelamin": "",
			"rt_rw": "002/006",
			"tanggal_lahir": "01-01-2001",
			"status_perkawinan": "KAWIN",
			"kelurahan_desa": "SARIJADI"

		},
		"status": "success",
		"transaction_id": "1fa03f48-12db-4abc-9c4b-c25bb7d98eab"
	}
}
```

</details>

### Invalid Image Extension

Invalid image extension type Recommendation: ensure to give KTP image file extension JPEG/JPG.

HTTP Status Code: `400`

<details>

<summary>JSON Response</summary>

```json
{
    "errors": [
        {
            "code": 2006,
            "title": "Unsupported media type",
            "detail": "Unsupported media or image type"
        }
       ]
}
```

</details>

### Invalid KTP Image Format

Invalid image format due to below reasons:&#x20;

* The KTP object resolution is less than 300x400 pixels
* The KTP object resolution is greater than 3000x4000 pixels&#x20;
* No text in the KTP image&#x20;

**Recommendation**: Ensure to give KTP image input as the specific recommendation

HTTP Status Code: `400`

<details>

<summary>JSON Response</summary>

```json
{
	"errors": [
		{
		"code": 2000,
		"title": "Bad Request",
		"detail": "Invalid image format"
	}
	]
}
```

</details>

### Image File Size Error

The image file size is greater than 2 MB.&#x20;

**Recommendation**: ensure to give image file size less than 2 MB

HTTP Status Code: `400`

<details>

<summary>JSON Response</summary>

```json
{
    "errors": [
        {
            "code": 2000,
            "title": "Bad Request",
            "detail": "Please recheck your image file size"
        }
    ]
}
```

</details>

## KTP OCR Sync Call

<mark style="color:green;">`POST`</mark> `https://{vida.host}/verify/v1/ktp/ocr/transaction`

#### Headers

| Name                                            | Type             | Description  |
| ----------------------------------------------- | ---------------- | ------------ |
| Authorization<mark style="color:red;">\*</mark> |                  | 3szVklNVpfJL |
| Content-Type<mark style="color:red;">\*</mark>  | application/json | QNRmJHAy55OO |

#### Request Body

| Name                                         | Type   | Description  |
| -------------------------------------------- | ------ | ------------ |
| ktp\_image<mark style="color:red;">\*</mark> | String | fRUTRr5l3FPA |

### Error Response

#### Bad Request Invalid Image Extension

HTTP Status Code: `400`

<details>

<summary>Error Response</summary>

```json
{
    "errors": [
        {
            "code": 2006,
            "title": "Unsupported media type",
            "detail": "Unsupported media or image type"
        }
       ]
}
```

</details>

#### Bad Request Invalid image format due to some reasons&#x20;

The KTP object resolution is less than 300x400 pixels. The KTP object resolution is greater than 3000x4000 pixels No text in the KTP image&#x20;

**Recommendation: ensure to give KTP image input as the specific recommendation**

HTTP Status Code: `400`

<details>

<summary>Error Response</summary>

```json
{
    "errors": [
        {
            "code": 2000,
            "title": "Bad Request",
            "detail": "Invalid image format"
        }
    ]
}
```

</details>

#### Bad Request The image file size is greater than 2 MB

HTTP Status Code: `400`

<details>

<summary>Error Response</summary>

```json
{
    "errors": [
        {
            "code": 2000,
            "title": "Bad Request",
            "detail": "Please recheck your image file size"
        }
    ]
}
```

</details>
