NSE circular · 23 Jul 2026
Official title
Update regarding API Facility in NMASS-Margins-CD
Official record
Open source pageSummary
Check the official recordNSE Clearing Limited (NCL) has outlined the technical requirements for members to access Margin and Position data via Web APIs. Members must register by providing their IP address, email, and an RSA-compliant X.509 public key certificate. Access is managed via OAuth 2.0, where bearer tokens are issued and payloads are secured using AES-256-CBC encryption. The documentation specifies mandatory headers, rate limits, and error handling protocols. Members are responsible for ensuring their systems strictly adhere to the defined encryption algorithms, padding, and data formats to prevent integration failures. The API supports various margin and position inquiry endpoints, with specific requirements for message IDs and client lists.
What you must do
Who is affected
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
© 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
2 | P a g e
AES Algorithm Integration Guide......................................................................................................................3
3 | P a g e
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
4 | P a g e
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;
}
}
5 | P a g e
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;
}
}
6 | P a g e
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
7 | P a g e
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
8 | P a g e
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:
9 | P a g e
NOTE: Members must strictly follow the same algorithm, padding, encoding, and data format for successful integration for both the algorithms.
*** End of Document ***
10 | P a g e
Margin Derivatives (FO/CD/CO)
Version 1.2
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
© 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
11 | P a g e
| Date | Change Description | Edited By | Version |
|---|---|---|---|
| 20-Jan-2026 | Initial version | 1.0 | |
| 05-Jun-2026 | New endpoints added | 1.1 | |
| 22-July-2026 | New Error Code | 1.2 |
12 | P a g e
Revision History ......................................................................................................................................2 Introduction ............................................................................................................................................4 General Instructions............................................................................................................................4 HTTP Status Codes..............................................................................................................................4 Common Error Response JSON.......................................................................................................5 Segment Environment Details ............................................................................................................5 FO Segment.....................................................................................................................................5 CD Segment.....................................................................................................................................5 CO Segment.....................................................................................................................................6 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/positions..............................................................................................20 POST //request/moi......................................................................................................23 POST //request/mwpl ...................................................................................................26 POST //request/cli-margins/generate-all......................................................................29 POST //request/cli-margins/inquiry..............................................................................31 POST //request/positions/generate-all ........................................................................33 POST //request/positions/inquiry.................................................................................35 APIs Rate Limit ......................................................................................................................................37 Appendix A - Response Codes...............................................................................................................37 HTTP response code..........................................................................................................................37 Message based response code .........................................................................................................38 Sample example for success or failure code.....................................................................................39
Thresholds
If you do not comply