DocsSA Document Validator

SA Document Validator API

Validate and extract structured data from South African identity documents. Supports ID cards, ID books, passports, and driver's licenses.

2 tokens per validationBase URL: https://api.kcstudios.co.za

Authentication

All API requests require an API key passed in the Authorization header as a Bearer token.

  1. Sign up at kcstudios.co.za
  2. Navigate to Dashboard > API Keys
  3. Click “Create New Key” and copy the generated key

Include the key in your requests:

http
Authorization: Bearer sk_live_your_api_key

Keep your API keys secret. Do not share them in client-side code, public repositories, or anywhere publicly accessible. If a key is compromised, revoke it immediately from the dashboard.

Validate Endpoint

POSThttps://api.kcstudios.co.za/api/v1/validate-document

Upload an image of a South African identity document and receive validated, extracted data as JSON. The API performs OCR extraction and validates the document fields for consistency and correctness.

Each successful validation consumes 2 tokens from your balance. Failed validations do not consume tokens.

Request Format

Option 1: Multipart Form Data (Recommended)

Send the document image as a file upload using multipart/form-data.

FieldTypeRequiredDescription
fileFileYesThe document image file (JPEG, PNG, WebP, HEIC, or PDF)
documentTypeStringNoDocument type hint. If omitted, the API will auto-detect the document type.
bash
curl -X POST https://api.kcstudios.co.za/api/v1/validate-document \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -F "file=@id_card.jpg" \
  -F "documentType=sa_id_card"

Option 2: JSON with Base64

Send the document image as a base64-encoded string in a JSON body.

FieldTypeRequiredDescription
imageStringYesBase64-encoded image with data URI prefix
documentTypeStringNoDocument type hint for faster processing
bash
curl -X POST https://api.kcstudios.co.za/api/v1/validate-document \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "data:image/jpeg;base64,/9j/4AAQ...",
    "documentType": "sa_id_card"
  }'

Supported Document Types

Pass the documentType parameter to specify the type of document being uploaded. If omitted, the API will attempt to auto-detect the document type.

TypeDescriptionExtracted Fields
sa_id_cardSouth African smart ID cardID number, name, DOB, gender, citizenship, nationality, document number
sa_id_bookSouth African green ID bookID number, name, DOB, gender, citizenship, country of birth
sa_passportSouth African passportID number, name, DOB, gender, nationality, passport number, issue/expiry dates
foreign_passportForeign/international passportName, DOB, gender, nationality, passport number, issue/expiry dates, country code
sa_drivers_licenseSouth African driver's licenseID number, name, DOB, license number, vehicle codes, issue/expiry dates, restrictions

Tip: Providing the documentType parameter improves accuracy and processing speed. When omitted, the API uses an extra detection step to identify the document type.

Response Format

Successful responses return a JSON object with validation results, extracted data, and metadata.

Successful Validation

json
{
  "success": true,
  "data": {
    "documentType": "sa_id_card",
    "isValid": true,
    "validationErrors": [],
    "extractedData": {
      "idNumber": "9001015009087",
      "firstName": "JOHN",
      "lastName": "SMITH",
      "dateOfBirth": "1990-01-01",
      "gender": "Male",
      "citizenship": "South African",
      "countryOfBirth": "South Africa",
      "dateOfIssue": "2015-03-15",
      "expiryDate": null,
      "documentNumber": "ABC123456"
    },
    "confidence": "high"
  },
  "meta": {
    "scanId": "abc123",
    "processingTimeMs": 2340,
    "tokensUsed": 2,
    "remainingTokens": 48
  }
}

Validation with Errors

When the document is processed but validation issues are found, isValid is set to false and the validationErrors array contains descriptions of the issues found.

json
{
  "success": true,
  "data": {
    "documentType": "sa_id_card",
    "isValid": false,
    "validationErrors": [
      "ID number checksum digit is invalid",
      "Date of birth does not match ID number"
    ],
    "extractedData": {
      "idNumber": "9001015009088",
      "firstName": "JOHN",
      "lastName": "SMITH",
      "dateOfBirth": "1991-01-01",
      "gender": "Male",
      "citizenship": "South African",
      "countryOfBirth": "South Africa",
      "dateOfIssue": "2015-03-15",
      "expiryDate": null,
      "documentNumber": "ABC123456"
    },
    "confidence": "medium"
  },
  "meta": {
    "scanId": "def456",
    "processingTimeMs": 2580,
    "tokensUsed": 2,
    "remainingTokens": 46
  }
}

Response Fields

FieldTypeDescription
data.documentTypestringDetected or confirmed document type
data.isValidbooleanWhether the document passed all validation checks
data.validationErrorsstring[]List of validation errors found (empty if valid)
data.extractedData.idNumberstringSouth African ID number (13 digits)
data.extractedData.firstNamestringFirst name as it appears on the document
data.extractedData.lastNamestringLast name / surname as it appears on the document
data.extractedData.dateOfBirthstringDate of birth in YYYY-MM-DD format
data.extractedData.genderstringGender as stated on the document (“Male” or “Female”)
data.extractedData.citizenshipstringCitizenship status
data.extractedData.countryOfBirthstringCountry of birth if available
data.extractedData.dateOfIssuestringDocument issue date in YYYY-MM-DD format
data.extractedData.expiryDatestring | nullDocument expiry date (null for non-expiring documents like SA ID cards)
data.extractedData.documentNumberstringUnique document/card number
data.confidencestringConfidence level: “high”, “medium”, or “low”
meta.scanIdstringUnique identifier for this validation
meta.processingTimeMsnumberProcessing time in milliseconds
meta.tokensUsednumberTokens consumed for this request (always 2)
meta.remainingTokensnumberRemaining token balance

Error Codes

Errors return a JSON object with success: false and an error object.

json
{
  "success": false,
  "error": {
    "code": "INSUFFICIENT_TOKENS",
    "message": "Not enough tokens. Balance: 1, required: 2.",
    "status": 402
  }
}
StatusCodeDescription
400BAD_REQUESTInvalid request format or missing required fields.
401UNAUTHORIZEDMissing or invalid API key.
402INSUFFICIENT_TOKENSNot enough tokens to process the request. Requires 2 tokens.
403FORBIDDENAPI key has been revoked or account is suspended.
404NOT_FOUNDThe requested endpoint does not exist.
413FILE_TOO_LARGEImage exceeds the maximum file size of 10MB.
415UNSUPPORTED_TYPEFile type not supported. Use JPEG, PNG, WebP, HEIC, or PDF.
422PROCESSING_FAILEDCould not extract or validate data from the document image.
429RATE_LIMITEDToo many requests. Check rate limit headers.
500INTERNAL_ERRORAn unexpected server error occurred.

Code Examples

bash
curl -X POST https://api.kcstudios.co.za/api/v1/validate-document \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -F "file=@id_card.jpg" \
  -F "documentType=sa_id_card"

Rate Limits

Rate limits are applied per API key and per user account to ensure fair usage.

ScopeLimitWindow
Per API Key60 requests1 minute
Per API Key1,000 requests1 hour
Per User Account5,000 requests24 hours

Rate limit information is included in response headers:

http
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1706012400
© 2026 KCS Business Services. All rights reserved.