The c2bspan REST API empowers B2B aggregators, distributor networks, fintech applications, and independent retailer systems to issue New PAN cards and process PAN Corrections via Religare's authorized NSDL E-KYC infrastructure.
Download the full guide, or hand a ready prompt to your AI assistant. The key never goes in the prompt.
Authentication, every endpoint, webhooks and error codes in one professional PDF.
Download PDFReads the key from C2B_API_KEY only. It never asks for the key or writes it into code.
You are a senior backend engineer. Build a small, production-ready client for the c2bspan PAN API.
SECURITY RULES (follow strictly)
- NEVER hard-code, print, log, or commit the API key. NEVER ask me to paste the key into this chat or into source code.
- Read the key only from the environment variable C2B_API_KEY (and the webhook secret from C2B_CALLBACK_SECRET).
Fail at startup with a clear message if C2B_API_KEY is missing. Do not generate a "set your key here" option or a config field for it.
- Call the API only from server-side code. Never put the key in browser, mobile or public client code.
- Provide a .env.example that contains only the variable names with empty values, and add .env to .gitignore.
API FACTS
- Base URL: https://www.c2bspan.in/api/v1 (HTTPS only)
- Auth header on every request: x-api-key: <value of C2B_API_KEY> (or Authorization: Bearer <value>)
- Rate limit 120 requests/minute per key. On HTTP 429 wait for the Retry-After header, then retry with backoff.
- Endpoints:
GET /wallet scope wallet:read -> { retailerId, balance, held, available } (INR)
POST /pan/start scope pan.new:create | pan.corr:create
body (all optional): { retailerId, firmName, logoUrl (https), copyright }
-> { launchUrl, expiresInSeconds: 120, religareRetailerId, retailerId }
launchUrl is single-use and valid for 120 seconds: open it immediately in a browser/webview.
GET /transactions?limit=1..100&status=Held|Pending|Success|Failure|Reversal|Expired&retailerId=... scope pan.status:read
GET /transactions/:id scope pan.status:read (add ?refresh=1 to re-check upstream)
GET /transactions/:id/pan scope pan.status:read -> allotted PAN + ackNo (only when status = Success)
- Errors are JSON with an error message. Handle 400, 401, 402 (insufficient wallet funds), 403 (scope or IP not allowed),
404, 429 and 502 (retry with exponential backoff).
- Each PAN application holds the fee from the wallet while Held/Pending; Success turns it into a debit,
Failure/Expired releases it, Reversal refunds it.
WEBHOOKS
- c2bspan POSTs status events to my callback URL with header X-Signature = HMAC-SHA256 (hex) of the RAW request body
using C2B_CALLBACK_SECRET as the key. Verify with a timing-safe comparison on the raw bytes before parsing JSON.
- Respond 2xx within 10 seconds. Retries come after 5s and 30s, so de-duplicate on the pair txnId + status.
DELIVERABLES
1. A small typed API client (wallet, startPan, listTransactions, getTransaction, getPan) with timeouts and retry on 429/502.
2. A webhook handler with signature verification and idempotency.
3. A .env.example (names only), a short README, and a few tests that mock the HTTP calls.
Ask me which language/framework to use if I have not said. Never ask for, display, or store the key.
POST /api/v1/pan/start with optional sub-retailer ID and firm branding.launchUrl valid for exactly 120 seconds.
Every request to the c2bspan REST API must be authenticated using an API Access Token. Unauthenticated calls are rejected with HTTP 401 Unauthorized.
Supply your API token in either of the standard request headers:
x-api-key: pk_live_38bf8c991a04...Authorization: Bearer pk_live_38bf8c991a04...
In accordance with default-deny security principles, API tokens must be created with explicit scopes. Wildcard scopes (*) are strictly prohibited.
| Scope Identifier | Granted Capability | Applicable Routes |
|---|---|---|
wallet:read |
Retrieve balance, held reserves, and available funds | GET /api/v1/wallet |
pan.new:create |
Initiate new PAN card application sessions | POST /api/v1/pan/start |
pan.corr:create |
Initiate PAN change or correction sessions | POST /api/v1/pan/start |
pan.status:read |
Query application statuses, ACK numbers, and allotted PANs | GET /api/v1/transactions/* |
For enterprise security, every API key can be restricted to specific originating IP addresses or CIDR subnets. Requests from unlisted IPs receive HTTP 403 Forbidden.
103.21.244.1192.168.1.0/24 (matches any IP within that /24)2001:db8::12001:db8::/32Manage allowed IPs dynamically in the Retailer Portal under API Settings → Allowed IPs with WhatsApp OTP step-up authentication.
All API keys are governed by a token-bucket rate limiter set to 120 requests per minute. If exceeded, the server returns HTTP 429 Too Many Requests with a Retry-After header in seconds.
Retrieve the current wallet balance, held reserves for in-flight applications, and available funds.
| Field | Type | Description |
|---|---|---|
| retailerIdstring | Your primary c2bspan account identifier (e.g. C2B81738). |
|
| balancenumber (INR) | Total funded balance in Indian Rupees. | |
| heldnumber (INR) | Total funds temporarily locked for pending NSDL application sessions. | |
| availablenumber (INR) | Liquid balance available for new applications (balance - held). |
Requests a fresh, authenticated session on Religare's E-PAN NSDL gateway and generates a one-time launch URL.
| Field | Type | Description |
|---|---|---|
| retailerId string • max 40 optional |
Your internal sub-retailer ID (e.g. SHOP102). Mapped upstream as C2B81738_SHOP102. The fee is charged to your parent wallet.
|
|
| firmName string • max 50 optional | Custom firm or shop title displayed on the NSDL gateway header. Overrides account default. | |
| logoUrl https URL • max 70 optional | HTTPS link to your logo image displayed on the Religare form. Must use HTTPS. | |
| copyright string • max 70 optional | Footer copyright line displayed on the NSDL interface. |
launchUrl is valid for exactly 120 seconds and can be accessed only once. If your retailer closes or refreshes the tab before initiating, call this endpoint again to receive a fresh URL.List historical PAN applications with optional filtering by status and sub-retailer.
| Parameter | Type | Description |
|---|---|---|
| limitinteger • 1–100 | Maximum number of records to return (default: 20). |
|
| statusstring | Filter by state: Held, Pending, Success, Failure, Reversal. |
|
| retailerIdstring | Filter by your custom sub-retailer ID. |
Retrieve full details for a single application by its internal ID, requestId, or txnId. Adding ?refresh=1 instructs the server to perform an active upstream status check with Religare before responding.
Retrieve authoritative PAN card allotment details, 15-digit acknowledgement number, applicant name, and e-PAN status once cleared by NSDL.
| Field | Type | Description |
|---|---|---|
orderId |
string • required |
The unique order identifier returned when initiating the session. |
{ "status": "Success", "orderId": "ORD_1731678901234", "ackNo": "881029384756123", "panNumber": "ABCDE1234F", "applicantName": "KUMAR S", "ePanAvailable": true }
When Religare and NSDL update an application's status, c2bspan dispatches a real-time HTTP POST event to your configured callback_url.
Every webhook includes the X-Signature header. This is a computed HMAC-SHA256 hash of the exact, raw request payload, using your unique callback_secret as the key.
crypto.timingSafeEqual in Node.js) to prevent timing attacks.2xx response within 10 seconds.txnId + status.Multi-tenant architecture allowing corporate aggregators, distributors, and fintech platforms to route user applications for hundreds of sub-agents under a single parent wallet.
Pass your agent's unique ID as retailerId when initiating POST /api/v1/pan/start. c2bspan tags all ledger events, transaction receipts, and Religare logs with your scoped identifier (e.g., C2B81738_SHOP102).
GET /api/v1/pan/transactions?retailerId=SHOP102.Custom branding enables your retail network to present their localized trade identity to users during the NSDL e-KYC handoff.
Provide the firmName field (up to 60 characters) during session creation:
"firmName": "Sri Cyber Express Services"
The applicant sees the registered firm name in the top authorization header of the official e-KYC portal, reinforcing consumer trust.
| Status | Lifecycle Stage | Wallet Impact |
|---|---|---|
Held |
Application started on NSDL; session active. | Fee held in wallet (₹107.00 locked) |
Pending |
NSDL is processing the e-KYC submission. | Fee remains held |
Success |
Application completed. ackNo is issued. |
Held converted to permanent debit |
Failure |
Application rejected or canceled by user. | Fee released back to available balance |
Reversal |
Religare reversed an earlier transaction. | Full refund credited to wallet |
Expired |
Session started but user did not finish form. | Fee released back to available balance |
The API uses standard HTTP status codes combined with explicit, machine-readable error codes and human-friendly remediation guidance.
| HTTP Status | Error Code | Meaning & Action |
|---|---|---|
400 Bad Request |
E_INVALID_PAYLOAD |
Missing or invalid request parameter. Review validation messages. |
401 Unauthorized |
E_UNAUTHORIZED |
Missing or invalid API token. Pass token in x-api-key or Authorization: Bearer. |
403 Forbidden |
E_INSUFFICIENT_SCOPE |
Token lacks required permission (e.g. attempting to create PAN without pan.new:create). |
403 Forbidden |
E_IP_NOT_ALLOWED |
Client IP is not registered in your account allowlist. Add the IP with OTP verification in portal. |
402 Payment Required |
E_INSUFFICIENT_FUNDS |
Available wallet balance is less than application fee (₹107.00). Top up wallet in retailer portal. |
404 Not Found |
E_NOT_FOUND |
Transaction or order ID not found in your account records. |
429 Too Many Requests |
E_RATE_LIMITED |
Request limit (120 req/min) exceeded. Pause and retry using Retry-After header value. |
502 Bad Gateway |
E_RELIGARE_UNAVAILABLE |
Upstream NSDL/Religare server timed out or is temporarily unreachable. Retry with backoff. |