> 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-and-document-verification-v1/summary-endpoint/ocr/ktp.md).

# KTP

{% hint style="info" %}
**Note:** Some cards may have the blood group recorded as `'-'`. This can happen for two reasons:

1. The card **explicitly** lists the blood group as `'-'`.
2. The blood group is **difficult to read**, making it unclear in the extracted data.
   {% endhint %}

### Request

<details>

<summary>Request</summary>

```json
{
  "operations": ["ocr"],
  "payload": {
    "partnerTrxId": "random-uuid",
    "groupId": "random-uuid",
    "idType": "ID_CARD",
    "country": "IDN",
    "idSubtype": "KTP",
    "idFrontSideImage": "Base64 encoded image of ID front side"
  },
  "userConsent": {
    "userIP": "0.0.0.0",
    "country": "MYS",
    "obtained": true,
    "obtainedAt": "1680700959"
  }
}
```

</details>

### Success Response

HTTP Status Code: `200`&#x20;

<details>

<summary>Success JSON Response</summary>

```json
{
  "transactionId": "unique transaction id generated to identify this transaction",
  "partnerTrxId": "partner transaction id submitted by customer in request",
  "groupId": "partner group id submitted by customer in request",
  "imageQualityResult": {
    "statusCode": 5000
  },
  "card": {
    "country": "INDONESIA",
    "type": "KTP",
    "isoAlpha3CountryCode": "IDN",
    "isoAlpha2CountryCode": "ID"
  },
  "ocrResult": {
    "idNumber": "ID-Number",
    "name": "NAME",
    "address": "Address",
    "dob": "DD-MM-YYYY",
    "gender": "Gender from id card (M/F/O)",
    "religion": "Religion",
    "province": "Provience",
    "city": "City",
    "placeOfBirth": "Place Of Birth",
    "bloodType": "Blood type",
    "neighborhoodAssociationGroup": "Neighborhood Assocaition Group",
    "village": "Village",
    "subDistrict": "Sub District",
    "maritalStatus": "Marital Status",
    "occupation": "Occupation",
    "nationality": "Nationality",
    "validUntil": "Validity",
  }
}
```

</details>

### Error 5026 - Extraction failed for the below ocr field. Please make sure the fields are properly visible on the card.

{% hint style="info" %}
This error is raised only for the critical fields of KTP cards. For other fields, no error will be thrown; instead, the response will contain `EXTRACTION_ERROR`.

**Note: Critical Fields for KTP cards are:**

1. **IdNumber**
2. **Name**
3. **DOB**
4. **ValidUntil**
   {% endhint %}

HTTP Status Code: `400`&#x20;

<details>

<summary>Error 5026 - Critical field extraction failed</summary>

```json
{
  "transactionId": "unique transaction id generated to identify this transaction",
  "partnerTrxId": "partner transaction id submitted by customer in request",
  "groupId": "partner group id submitted by customer in request",
  "errors": [
    {
      "message": "Extraction failed for the below ocr field. Please make sure the fields are properly visible on the card.",
      "code": 5026,
      "fieldName": "name",
      "operations": [
        "ocr"
      ]
    }
  ],
  "imageQualityResult": {
    "statusCode": 5000
  },
  "card": {
    "country": "INDONESIA",
    "type": "KTP",
    "isoAlpha3CountryCode": "IDN",
    "isoAlpha2CountryCode": "ID"
  },
  "ocrResult": {
    "idNumber": "ID-Number",
    "name": "EXTRACTION_ERROR", // Critical Field
    "address": "Address",
    "dob": "DD-MM-YYYY",
    "gender": "Gender from id card (M/F/O)",
    "religion": "Religion",
    "province": "Provience",
    "city": "EXTRACTION_ERROR", // Non Critical Field
    "placeOfBirth": "Place Of Birth",
    "bloodType": "Blood type",
    "neighborhoodAssociationGroup": "Neighborhood Assocaition Group",
    "village": "Village",
    "subDistrict": "Sub District",
    "maritalStatus": "Marital Status",
    "occupation": "Occupation",
    "nationality": "Nationality",
    "validUntil": "Validity",
  }
}
```

</details>

HTTP Status Code: `200`&#x20;

<details>

<summary>Success response - Extraction failed only for non critical field</summary>

```json
{
  "transactionId": "unique transaction id generated to identify this transaction",
  "partnerTrxId": "partner transaction id submitted by customer in request",
  "groupId": "partner group id submitted by customer in request",
  "imageQualityResult": {
    "statusCode": 5000
  },
  "card": {
    "country": "INDONESIA",
    "type": "KTP",
    "isoAlpha3CountryCode": "IDN",
    "isoAlpha2CountryCode": "ID"
  },
  "ocrResult": {
    "idNumber": "ID-Number",
    "name": "NAME",
    "address": "Address",
    "dob": "DD-MM-YYYY",
    "gender": "Gender from id card (M/F/O)",
    "religion": "Religion",
    "province": "Provience",
    "city": "EXTRACTION_ERROR", // Non Critical Field
    "placeOfBirth": "Place Of Birth",
    "bloodType": "Blood type",
    "neighborhoodAssociationGroup": "Neighborhood Assocaition Group",
    "village": "Village",
    "subDistrict": "Sub District",
    "maritalStatus": "Marital Status",
    "occupation": "Occupation",
    "nationality": "Nationality",
    "validUntil": "Validity",
  }
}
```

</details>
