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

Selfie National Code Birthday Match API

این API تصویر سلفی کاربر را به همراه کد ملی و تاریخ تولد دریافت می‌کند و با داده‌های هویتی موجود در سپال‌یار تطبیق می‌دهد. در صورت موفقیت، نتیجه تطبیق به همراه میزان شباهت برگردانده شده و هزینه سرویس از کیف پول کسر می‌شود.

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

مستندات

Overview

Overview

The Selfie National Code Birthday Match API accepts a selfie image, a national code, and a birth date and verifies whether they belong to the same person using Sepal Yar's KYC services.

Authentication

Authentication

Provide token authentication headers in every request:

Authorization: Token YOUR_AUTH_TOKEN
X-Unique-Code: YOUR_UNIQUE_CODE

Request Format

Request Format

Send a POST request with multipart/form-data body containing selfie image and fields:

curl -X POST /api/services/selfie-national-code-birthday-match/ \
  -H "Authorization: Token ..." \
  -H "X-Unique-Code: ..." \
  -F "national_code=4640229534" \
  -F "birth_date=13790514" \
  -F "selfie_image=@selfie.jpg;type=image/jpeg"

Response Format

Response Format

در پاسخ موفق، کلید response_data حاوی اطلاعات هویتی و نتیجه تطبیق است. فیلد verified نشان می‌دهد تطبیق موفق بوده است یا خیر و similarity میزان شباهت چهره را نشان می‌دهد. همچنین شناسه رهگیری در ref_id و زمان عملیات در operation_time بازگردانده می‌شود.

Best Practices

Best Practices

  • Use high-quality selfie images with good lighting and full face visible.
  • Ensure national code and birth date are validated on your side before calling the API.
  • Store request_ref, ref_id and operation_time for auditing.

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

پارامتر نوع اجباری توضیحات مثال
national_code String اجباری کد ملی ۱۰ رقمی (فقط ارقام).
اعتبارسنجی: باید دقیقا ۱۰ رقم و فقط عدد باشد.
4640229534
birth_date String اجباری تاریخ تولد شمسی به صورت عددی yyyymmdd (مثال: 13790514).
اعتبارسنجی: باید ۸ رقم باشد و فرمت yyyymmdd را رعایت کند.
13790514
selfie_image File اجباری عکس سلفی کاربر (حداکثر حجم ۳ مگابایت، فرمت‌های مجاز: JPG، PNG).
اعتبارسنجی: حداکثر حجم ۳ مگابایت. تصویر باید واضح باشد و چهره کامل دیده شود.
selfie.jpg

مثال‌های کد

Python Example

Example using Python requests library.

import requests

url = "https://inquiry.sepal.ir/api/services/selfie-national-code-birthday-match/"
headers = {
    "Authorization": "Token YOUR_AUTH_TOKEN",
    "X-Unique-Code": "YOUR_UNIQUE_CODE",
}
files = {
    "selfie_image": ("selfie.jpg", open("selfie.jpg", "rb"), "image/jpeg"),
}
data = {
    "national_code": "4640229534",
    "birth_date": "13790514",
}

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

Example using C# HttpClient with multipart/form-data.

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.IO;

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

        using var form = new MultipartFormDataContent();
        using var fileStream = File.OpenRead("selfie.jpg");
        var fileContent = new StreamContent(fileStream);
        fileContent.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
        form.Add(fileContent, "selfie_image", "selfie.jpg");

        form.Add(new StringContent("4640229534"), "national_code");
        form.Add(new StringContent("13790514"), "birth_date");

        var response = await client.PostAsync("https://inquiry.sepal.ir/api/services/selfie-national-code-birthday-match/", form);
        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}
PHP Example

Example using PHP cURL file upload.

<?php

$url = "https://inquiry.sepal.ir/api/services/selfie-national-code-birthday-match/";

$headers = [
    "Authorization: Token YOUR_AUTH_TOKEN",
    "X-Unique-Code: YOUR_UNIQUE_CODE"
];

$postFields = [
    "selfie_image" => new CURLFile("selfie.jpg", "image/jpeg", "selfie.jpg"),
    "national_code" => "4640229534",
    "birth_date" => "13790514"
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

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

echo $response;
?>
cURL Example

Command-line cURL example.

curl -X POST "https://inquiry.sepal.ir/api/services/selfie-national-code-birthday-match/" \
  -H "Authorization: Token YOUR_AUTH_TOKEN" \
  -H "X-Unique-Code: YOUR_UNIQUE_CODE" \
  -F "national_code=4640229534" \
  -F "birth_date=13790514" \
  -F "selfie_image=@selfie.jpg;type=image/jpeg"

فرمت پاسخ

200
پاسخ موفق

پاسخ موفق شامل نتیجه تطبیق چهره، کد ملی و تاریخ تولد و میزان شباهت.

ساختار پاسخ:
{
  "amount": "integer",
  "success": "boolean",
  "request_ref": "string",
  "error_message": "null",
  "response_data": {
    "kyc_id": "string",
    "ref_id": "string",
    "question": "string",
    "verified": "boolean",
    "last_name": "string",
    "birth_date": "integer",
    "first_name": "string",
    "similarity": "float",
    "father_name": "string",
    "national_code": "string",
    "operation_time": "integer"
  },
  "response_time_ms": "integer"
}
مثال پاسخ:
{
  "amount": 20000,
  "success": true,
  "request_ref": "XIHAUOLARKN7M0KLZKJTRNTNIPXUL7YZ",
  "error_message": null,
  "response_data": {
    "kyc_id": "78d399c8-ed0d-44d5-92e9-999de5a45b50",
    "ref_id": "54854cb0-dbe4-433a-b800-062015b63b81",
    "question": "2,1,4",
    "verified": true,
    "last_name": "علائي",
    "birth_date": 13790514,
    "first_name": "رامين",
    "similarity": 0.4369637072086334,
    "father_name": "تورج",
    "national_code": "4640229534",
    "operation_time": 1763287828519
  },
  "response_time_ms": 26000
}
400
خطا

پارامترهای ورودی نامعتبر هستند یا تصویر ارسال نشده است.

ساختار پاسخ:
{
  "error": {
    "errors": "list",
    "ref_id": "string",
    "operation_time": "integer"
  },
  "success": "boolean"
}
مثال پاسخ:
{
  "error": {
    "errors": [
      {
        "code": "1001",
        "message": "ارسال تصویر الزامی است."
      }
    ],
    "ref_id": "4d43a9dc-7cb1-4e61-8d10-4e2cdb2c9d23",
    "operation_time": 1762691215312
  },
  "success": false
}
422
خطا

تصویر توسط سپال‌یار قابل پردازش نیست (کیفیت پایین، ناقص یا نامعتبر).

ساختار پاسخ:
{
  "error": {
    "errors": "list",
    "ref_id": "string",
    "operation_time": "integer"
  },
  "success": "boolean"
}
مثال پاسخ:
{
  "error": {
    "errors": [
      {
        "code": "5001",
        "message": "تصویر سلفی خوانا نیست."
      }
    ],
    "ref_id": "7713c9e3-0b54-4a72-8a01-17fb37ee0ede",
    "operation_time": 1762691215312
  },
  "success": false
}