NSE circular Version 1.1 · 23 Jul 2026
Official title
Update regarding API Facility in NMASS-Margins-CM
Official record
Open source pageSummary
Check the official recordNSE Clearing Limited has updated the technical specifications for its Margin Equities (CM/SLB) Web API. The update mandates specific encryption standards for secure data exchange, requiring members to use AES-256-CBC for payload encryption and RSA (2048-bit) for token response decryption. Members must register their IP addresses, email addresses, and X.509-compliant RSA public key certificates with NCL to obtain API access. The protocol defines mandatory request headers, JSON structures, and rate limits for various endpoints, including margin inquiries and token generation. Members are responsible for ensuring strict adherence to the specified algorithms, padding, and data formats to prevent decryption failures. The update also details error handling, including HTTP status codes and message-based response codes for validation.
What you must do
The NSE Clearing Limited (National Clearing) Exchange Plaza, Plot No. C/1, G Block, Bandra-Kurla Complex, Bandra (E), Mumbai - 400 051
NSE Clearing Confidential
Notice
© Copyright NSE Clearing Ltd (NCL). All rights reserved. Unpublished rights reserved under applicable copyright and trades secret laws.
The contents, ideas and concepts presented herein are proprietary and confidential. Duplication and disclosure to others in whole, or in part is prohibited
AES Algorithm Integration Guide......................................................................................................................3
Algorithm: AES-256-CBC with PKCS5 Padding Encoding: UTF-8 Cipher Text Format: Base64
For secure message exchange between systems, we use AES (Advanced Encryption Standard) with the following configuration:
| Parameter | Value |
|---|---|
| Algorithm | AES |
| Mode | CBC (Cipher Block Chaining) |
| Padding | PKCS5Padding |
| Secret Key Size | 256 bits (32 bytes) |
| IV Size | 128 bits (16 bytes) |
| Text Encoding | UTF-8 |
| Cipher Output | Base64 encoded string |
This document provides reference implementation and rules to ensure interoperability.
Secret Key
Initialization Vector (IV)
Incorrect key or IV length will cause decryption failure
Constants AES = "AES"; AES_TRANSFORMATION = "AES/CBC/PKCS5Padding"; CHARSET_NAME = "UTF-8";
Sample code for encryption
public String encrypt(String plainText, byte[] secretKeyBytes, byte[] ivBytes)
{ try {
if (plainText == null || secretKeyBytes == null || ivBytes == null) {
return null;
}
SecretKeySpec keySpec = new SecretKeySpec(secretKeyBytes, AES);
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
Cipher cipher = Cipher.getInstance(AES_TRANSFORMATION); cipher.init(Cipher.ENCRYPT_MODE,
keySpec, ivSpec);
byte[] encryptedBytes = cipher.doFinal(plainText.getBytes(CHARSET_NAME));
return Base64.getEncoder().encodeToString(encryptedBytes);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Sample code of decryption
public String decrypt(String base64CipherText, byte[] secretKeyBytes, byte[] ivBytes) { try {
if (base64CipherText == null || secretKeyBytes == null || ivBytes == null) {
return null;
}
SecretKeySpec keySpec = new SecretKeySpec(secretKeyBytes, AES); IvParameterSpec
ivSpec = new IvParameterSpec(ivBytes);
Cipher cipher = Cipher.getInstance(AES_TRANSFORMATION); cipher.init(Cipher.DECRYPT_MODE,
keySpec, ivSpec);
byte[] decryptedBytes =
cipher.doFinal(Base64.getDecoder().decode(base64CipherText));
return new String(decryptedBytes, CHARSET_NAME);
} catch (Exception e) {
e.printStackTrace(); return
null;
}
}
Algorithm: RSA Transformation: RSA/ECB/PKCS1Padding Encoding: UTF-8 Cipher Text Format: Base64
RSA (Rivest–Shamir–Adleman) is an asymmetric encryption algorithm commonly used to:
In our integration, RSA is used for decryption on the server side using a private key, while encryption is performed on the client side using the corresponding public key.
RSA encryption is used to securely transfer sensitive information (such as encrypted messages or symmetric keys) from the client to the server.
This document explains how the NCL data is decrypted on our side using RSA.
Transformation Explanation
RSA Key Pair
| Key Type | Usage |
|---|---|
| Public Key | Used by NCL to encrypt data |
| Private Key | Used by Memberss to decrypt data |
Key Size
i. Receive Base64-encoded encrypted data from client ii. Decode Base64 string into byte array iii. Initialize RSA cipher using private key iv. Decrypt encrypted bytes v. Convert decrypted bytes to UTF-8 string
private static final String RSA_TRANSFORMATION = "RSA/ECB/PKCS1Padding";
@Override
public String decrypt(String base64Encrypted, PrivateKey privateKey) { try {
// Initialize RSA cipher
Cipher cipher = Cipher.getInstance(RSA_TRANSFORMATION);
cipher.init(Cipher.DECRYPT_MODE, privateKey);
// Decode Base64 and decrypt
byte[] encryptedBytes = Base64.getDecoder().decode(base64Encrypted);
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
// Return decrypted string
return new String(decryptedBytes, "UTF-8");
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
The client must ensure:
Any mismatch will result in decryption failure.
NOTE: Members must strictly follow the same algorithm, padding, encoding, and data format for successful integration for both the algorithms.
1. What is the minimum key length?
Minimum key length should be 2048 bits
2. What should be the subject/addtext Syntax?
Use the following subject syntax while generating the certificate C= ST= L= O= OU= CN=
3. What should be the certificate format and extension?
Certificate should be X.509 format. PEM encoded with ’.pem’ file extension
4. Whether self-signed certificate is acceptable?
Recommend using CA signed certificate.
5. What should be the maximum expiry period?
Expected expiry period will be one year.
*** End of Document ***
Margin Equities (CM/SLB)
Version 1.1
The NSE Clearing Limited (National Clearing) Exchange Plaza, Plot No. C/1, G Block, Bandra-Kurla Complex, Bandra (E), Mumbai - 400 051
NSE Clearing Confidential
Notice
© Copyright NSE Clearing Ltd (NCL). All rights reserved. Unpublished rights reserved under applicable copyright and trades secret laws.
The contents, ideas and concepts presented herein are proprietary and confidential. Duplication and disclosure to others in whole, or in part is prohibited
| Date | Change Description | Edited By | Version |
|---|---|---|---|
| 22-Jan-2026 | Initial version | 1.0 | |
| 06-Jun-2026 | New endpoints added | 1.1 |
Revision History ......................................................................................................................................2 Introduction ............................................................................................................................................4 General Instructions............................................................................................................................4 HTTP Status Codes..............................................................................................................................4 Common Error Response JSON.......................................................................................................5 Segment Environment Details ............................................................................................................5 CM Segment....................................................................................................................................5 SLB Segment....................................................................................................................................5 API Consumer Registration .................................................................................................................6 API Security .........................................................................................................................................6 Clearing Corporation APIs.......................................................................................................................7 POST //request/token.....................................................................................................7 POST //request/cm-margins...........................................................................................9 POST //request/tm-margins..........................................................................................12 POST //request/cli-margins...........................................................................................16 POST //request/security-margin...................................................................................19 POST //request/settlement-margin..............................................................................24 POST //request/cli-margins/generate-all......................................................................27 POST //request/cli-margins/inquiry..............................................................................29 POST //request/security-margin/generate-all..............................................................31 POST //request/security-margin/inquiry ......................................................................33 POST //request/settlement-margin/generate-all.........................................................35 POST //request/settlement-margin/inquiry .................................................................37 APIs Rate Limit ......................................................................................................................................39 Appendix A - Response Codes...............................................................................................................39 HTTP response code..........................................................................................................................39 Message based response code .........................................................................................................40 Sample example for success or failure code.....................................................................................41
This document provides information on the Web APIs used for programmatic access margin and positions related data between NCL’s MARGINS Platform and its Members. It details the messaging protocols and structures required to develop this interface.
Who is affected
Thresholds
If you do not comply