Add National ID OCR to Your App using Cursor in 5 Minutes
Cursor's AI writes your boilerplate. StructOCR reads the identity cards. Here's the exact prompt to feed into Cursor's Composer to wire them together for instant KYC — zero backend required.

Why Cursor + StructOCR is a natural fit for Identity Verification
Cursor generates incredibly accurate full-stack code using advanced AI models right in your IDE. It handles your UI components, state management, and routing automatically — but securely extracting names, birth dates, and MRZ codes from a laminated ID card photo is something the AI can't do natively. StructOCR fills exactly that gap: one API call, structured JSON back. Feed the prompt below into Cursor's Composer, and your driver onboarding flow will be ready in seconds.
The problem: AI coding assistants can't parse holograms
Tools like Cursor are remarkable at writing code — but they stop at the boundary of complex vision tasks. You can instruct Cursor to build a beautiful KYC upload interface in minutes, yet the actual extraction of names, document numbers, and MRZ lines from a laminated ID card requires a dedicated National ID OCR API. Standard vision models routinely misread security fonts, hallucinate personal data, or fail entirely on holographic overlays and glare.
The solution: Global ID parsing, instantly
StructOCR's /v1/national-id endpoint accepts a photo and returns a clean JSON object with the validated identity fields. It automatically decodes Machine Readable Zones (MRZ) and handles complex, localized ID layouts. Because it speaks plain HTTP, Cursor can easily generate the client or server-side fetch logic to wire it up.
Integrate StructOCR using Cursor (3 Steps)
Open your project in Cursor and use Composer
Open your web or mobile project in Cursor. Hit
Cmd+I(orCtrl+I) to open the Composer. Describe the onboarding UI you want to build.Try this prompt: "Build a mobile-friendly KYC onboarding UI component using shadcn. Users can upload a photo of their National ID card, and the app will display the extracted full name, document number, date of birth, and address in a clean card."Tell Cursor to call the StructOCR API
Once Cursor scaffolds the component, paste the follow-up prompt below. Cursor will write the fetch call, handle the form data, and wire the response to your state variables.
Follow-up prompt: "When a user uploads an image, send it as a multipart/form-data POST to https://api.structocr.com/v1/national-id with an Authorization header containing my API key. Display the returned JSON fields in the UI."// Cursor generates something like this in your frontend framework const response = await fetch('https://api.structocr.com/v1/national-id', { method: 'POST', headers: { Authorization: `Bearer ${process.env.NEXT_PUBLIC_STRUCTOCR_KEY}` }, body: formData, });Add your StructOCR API key to your .env file
Open your local .env or .env.local file in Cursor and securely add your StructOCR key. Restart your development server to see the live scanner.
Variable name: NEXT_PUBLIC_STRUCTOCR_KEY — get your free key at structocr.com/dashboardNEXT_PUBLIC_STRUCTOCR_KEY=sk_live_xxxxxxxxxxxxxxxx
What you can build in Cursor with this integration
- Fintech onboarding (KYC): Let users snap a photo of their ID to instantly populate sign-up forms without manual typing, drastically reducing drop-off rates in financial onboarding flows.
- Gig economy driver signup: Build a mobile portal where contractors upload their ID cards for instant identity verification, a crucial step for mobility and delivery apps.
- Age verification gates: Create a tool that scans a user's ID, calculates their age based on the extracted `date_of_birth`, and conditionally grants access to age-restricted goods or services.
- Visitor management systems: Add an upload step to a corporate check-in flow: extract visitor details automatically from their national ID to print temporary badges in seconds.
The prompt and the code
Copy the follow-up prompt into Cursor's Composer (Cmd+I) to generate the integration. The code block shows the standard fetch logic Cursor will likely produce.
Prerequisite: A free StructOCR account — get your API key at structocr.com/dashboard (no credit card required)
I need to add National ID OCR to this component.
When a user uploads an image:
1. Send it as multipart/form-data to: POST https://api.structocr.com/v1/national-id
2. Include the header: Authorization: Bearer ${process.env.NEXT_PUBLIC_STRUCTOCR_KEY}
3. The response is JSON with fields: data.surname, data.given_names, data.document_number, data.date_of_birth, data.address
4. Display the extracted identity data in a clear, formatted profile card
5. Show a loading spinner while the request is in flight
6. Show an error message if the upload fails
Use the environment variable NEXT_PUBLIC_STRUCTOCR_KEY for the API key.What the API returns
A comprehensive JSON object containing both primary identity fields and specialized MRZ strings. Cursor can easily type this interface for TypeScript projects.
{
"success": true,
"data": {
"type": "national_id",
"country_code": "ROU",
"nationality": "ROMANA",
"document_number": "123456",
"card_series": "KS",
"personal_number": "1920319123456",
"surname": "POPESCU",
"given_names": "ANDREI",
"sex": "M",
"date_of_birth": "1992-03-19",
"place_of_birth": "Jud. CS Mun. Reșița",
"address": "Jud. CS Orș. Bocșa Str. Nucilor Nr. 15",
"date_of_issue": "2020-05-10",
"date_of_expiry": "2030-05-10",
"issuing_authority": "SPCLEP Bocșa",
"additional_fields": {
"phone_number": null,
"tramite_number": null,
"ejemplar": null,
"mrz_line_1": "IDROU123456<0<<<<<<<<<<<<<<<<",
"mrz_line_2": "9203195M3005108ROU19203191234562",
"mrz_line_3": null
}
}
}Technical Specs
- Formats accepted: PNG, JPG, WEBP — optimized for smartphone and webcam photos
- Response time: typically 1–2 seconds per ID
- Condition handling: robust against lamination glare, holographic overlays, and poor lighting
- Data Privacy: Zero data retention architecture; images are processed in memory and immediately discarded
- Global coverage: supports 150+ countries and thousands of localized card templates
Key Features
- MRZ Decoding: automatically extracts and validates data from the Machine Readable Zone (MRZ) if present
- Format validation: automatically verifies document numbers and personal identity numbers against regional checksum rules
- Multi-angle support: reads IDs held at skewed angles or taken in busy backgrounds
- Cross-referencing: compares the visual inspection zone (VIZ) against the MRZ for fraud detection
Live Demo: ID card scanner
No registration required. Upload a file to test the extraction.
Drop files here or click to browse
JPG · PNG · WebP · up to 500 files · max 4.5 MB each
Frequently Asked Questions
Can Cursor generate the integration code for StructOCR?
Where should I store the API key when building with Cursor?
Does StructOCR store the ID photos?
Can it read IDs with holograms and heavy glare?
How can I test the accuracy before writing code?
Is there a free tier to test with?
More Tutorials
Add Container OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR shipping container API using the Cursor AI code editor. Build logistics and yard management tools rapidly.
Add Driver's License OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API using the Cursor AI code editor. Build car rental and mobility onboarding flows rapidly.
Add HIN OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR HIN (Hull Identification Number) scanner API using the Cursor AI code editor. Build marine and boat management tools rapidly.
Add Invoice OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR invoice API using the Cursor AI code editor. Build accounts payable and expense tracking tools rapidly.
Precise Data Extraction and Seamless
Integration with AI-powered OCR API.
Empower your solutions with automated data extraction by
integrating best-in class StructOCR via API seamlessly.
No credit card required • Full API access included