You need to enable JavaScript to use this application.
POST احراز هویت

National Code Birthday Match API

This API verifies whether an Iranian national code matches a given Gregorian birth date. A successful inquiry deducts the service tariff from the caller's wallet and returns identity attributes such as serial, name, and registry office information.

POST /api/services/national-code-birthday-match/
نیاز به احراز هویت Token 100 requests/minute

مستندات

Overview

Overview

The National Code Birthday Match API verifies whether an Iranian national code belongs to the person born on a specific Gregorian date. This service is useful for identity verification, fraud prevention, and customer onboarding flows.

On each successful call, the service:

  • Validates the national code format
  • Validates the Gregorian birth date format
  • Checks the match via Sepal Yar
  • Returns identity information such as first name, last name, and serial
  • Deducts the service tariff from the wallet
  • Returns a unique request reference for audit purposes

Authentication

Authentication

This API requires token-based authentication plus a unique code header.

  1. Retrieve your API token and unique code from the admin panel.
  2. Send them in the following headers:
Authorization: Token YOUR_AUTH_TOKEN
X-Unique-Code: YOUR_UNIQUE_CODE

If authentication fails, a 401 Unauthorized response will be returned.

Request Format

Request Format

Send a POST request with application/json content.

Headers:

  • Authorization: Token YOUR_AUTH_TOKEN
  • X-Unique-Code: YOUR_UNIQUE_CODE
  • Content-Type: application/json

Body:

{
  "national_code": "1234567890",
  "birth_date": "2001-04-21"
}

Birth date must be supplied in the Gregorian calendar. Convert Jalali dates to Gregorian before sending the request.

Response Format

Response Format

Successful responses include the following fields:

  • success: Boolean flag indicating success
  • request_ref: Unique reference for the request
  • amount: Charged amount (in Rials)
  • response_data: Matching result and identity fields
  • response_time_ms: Upstream response time
  • error_message: Null for successful calls

On failure, the response contains success: false and an error object with details.

Error Handling

Error Handling

The API uses standard HTTP status codes:

  • 200 OK: Request processed successfully
  • 400 Bad Request: Invalid or missing parameters
  • 401 Unauthorized: Missing or invalid authentication headers
  • 402 Payment Required: Insufficient wallet balance
  • 502 Bad Gateway: Sepal Yar service error

Always inspect the error.details field when present to identify validation errors returned by the platform.

Best Practices

Best Practices

  • Validate national code and convert dates to Gregorian before sending requests.
  • Log and store the returned request_ref for traceability.
  • Handle validation errors gracefully and surface details to clients.
  • Monitor wallet balance to avoid 402 responses.
  • Use exponential backoff for transient 5xx errors.

پارامترهای درخواست

پارامتر نوع اجباری توضیحات مثال
national_code String اجباری Iranian national code (10 digits). Only numeric characters are allowed.
اعتبارسنجی: Must be exactly 10 digits. Numbers only.
1234567890
birth_date String اجباری Gregorian birth date in YYYY-MM-DD format. Shamsi dates must be converted to Gregorian before calling the API.
اعتبارسنجی: Must follow YYYY-MM-DD format. Gregorian calendar.
2001-04-21
include_details Boolean اجباری -

مثال‌های کد

Python Example

Example using Python requests library.

import requests

url = "https://inquiry.sepal.ir/api/services/national-code-birthday-match/"
headers = {
    "Authorization": "Token YOUR_AUTH_TOKEN",
    "X-Unique-Code": "YOUR_UNIQUE_CODE",
    "Content-Type": "application/json",
}
data = {
    "national_code": "1234567890",
    "birth_date": "2001-04-21"
}

response = requests.post(url, json=data, headers=headers)
print(response.json())
C# Example

Example using C# HttpClient.

using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Token YOUR_AUTH_TOKEN");
        client.DefaultRequestHeaders.Add("X-Unique-Code", "YOUR_UNIQUE_CODE");

        var payload = new
        {
            national_code = "1234567890",
            birth_date = "2001-04-21"
        };

        var json = JsonSerializer.Serialize(payload);
        var content = new StringContent(json, Encoding.UTF8, "application/json");

        var response = await client.PostAsync(
            "https://inquiry.sepal.ir/api/services/national-code-birthday-match/",
            content
        );

        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}
PHP Example

Example using PHP cURL.

<?php

$url = "https://inquiry.sepal.ir/api/services/national-code-birthday-match/";
$data = [
    "national_code" => "1234567890",
    "birth_date" => "2001-04-21"
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Token YOUR_AUTH_TOKEN",
    "X-Unique-Code: YOUR_UNIQUE_CODE",
    "Content-Type: application/json"
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
cURL Example

Command-line cURL example.

curl -X POST "https://inquiry.sepal.ir/api/services/national-code-birthday-match/" \
  -H "Authorization: Token YOUR_AUTH_TOKEN" \
  -H "X-Unique-Code: YOUR_UNIQUE_CODE" \
  -H "Content-Type: application/json" \
  -d '{
    "national_code": "1234567890",
    "birth_date": "2001-04-21"
  }'

فرمت پاسخ

200
پاسخ موفق

Successful response when the national code matches the supplied birth date.

ساختار پاسخ:
{
  "amount": "integer",
  "success": "boolean",
  "request_ref": "string",
  "error_message": "null",
  "response_data": {
    "alive": "boolean",
    "match": "boolean",
    "serial": "string",
    "last_name": "string",
    "birth_date": "integer (epoch milliseconds)",
    "first_name": "string",
    "father_name": "string",
    "gender_type": "string",
    "office_code": "integer",
    "office_name": "string",
    "national_code": "string"
  },
  "response_time_ms": "integer"
}
مثال پاسخ:
{
  "amount": 15000,
  "success": true,
  "request_ref": "AAA1BBB2CCC3DDD4EEE5FFF6GGG7HHH8",
  "error_message": null,
  "response_data": {
    "alive": true,
    "match": true,
    "serial": "987654",
    "last_name": "کاظمی",
    "birth_date": 988588800000,
    "first_name": "رضا",
    "father_name": "مسعود",
    "gender_type": "MALE",
    "office_code": 101,
    "office_name": "تهران مرکزی",
    "national_code": "1234567890"
  },
  "response_time_ms": 320
}
401
خطا

Unauthorized - Authentication token or unique code missing/invalid.

ساختار پاسخ:
{
  "error": {
    "code": "string (optional)",
    "errors": "list (optional)",
    "details": "object (optional)",
    "message": "string"
  },
  "success": "boolean"
}
مثال پاسخ:
{
  "error": {
    "code": "AUTHENTICATION_ERROR",
    "message": "Authentication credentials were not provided."
  },
  "success": false
}
402
خطا

Payment Required - Insufficient wallet balance.

ساختار پاسخ:
{
  "error": {
    "code": "string (optional)",
    "errors": "list (optional)",
    "details": "object (optional)",
    "message": "string"
  },
  "success": "boolean"
}
مثال پاسخ:
{
  "error": {
    "code": "INSUFFICIENT_BALANCE",
    "message": "Insufficient wallet balance."
  },
  "success": false
}
400
خطا

Sepal Yar validation error (returned as-is).

ساختار پاسخ:
{
  "error": {
    "code": "string (optional)",
    "errors": "list (optional)",
    "details": "object (optional)",
    "message": "string"
  },
  "success": "boolean"
}
مثال پاسخ:
{
  "error": {
    "errors": [
      {
        "code": "81007",
        "message": "اطلاعات هویتی یافت نشد."
      }
    ]
  },
  "success": false
}