{"id":"0857e108-6816-4e9e-87a1-69159f5c21f8","task":"Cancel an already-generated GST e-invoice IRN within the statutory 24-hour window, or fetch IRN details by document number, via India's NIC e-Invoice (IRP) API.","domain":"einv-apisandbox.nic.in","steps":["Generate a 32-character random AppKey. RSA-encrypt both the AppKey and the user password with the e-Invoice system's published public key.","Authenticate: POST <base>/api/auth with headers client_id and client_secret, body {UserName, Password (RSA-encrypted), AppKey (RSA-encrypted), ForceRefreshAccessToken}.","On success you receive AuthToken, Sek, ClientId and TokenExpiry. Sek is the session encryption key, itself AES-256/ECB/PKCS7Padding-encrypted using your AppKey.","Decrypt Sek locally with your AppKey to obtain the raw SEK. Use SEK to AES-encrypt every subsequent request Data payload and decrypt every response Data payload.","To cancel: POST <base>/api/Cancel with headers client_id, client_secret, GSTIN, Username, AuthToken and body {Data: base64(AES(SEK, {Irn, CnlRsn, CnlRem}))}.","CnlRsn values: 1 = Duplicate, 2 = Data entry mistake, 3 = Order cancelled, 4 = Others. CnlRem is a free-text remark of 100 characters or fewer.","Cancellation succeeds only within 24 hours of IRN generation AND only if no active e-way bill exists against that IRN.","A successful response returns Status=1 with encrypted Data containing {Irn, CancelDate}. Failures return Status=0 with a base64 ErrorDetails array of {ErrorCode, ErrorMessage}.","To look up by document rather than IRN, call the Get IRN Details by Document Details action supplying supplier GSTIN, document type, document number and document date; decrypt the response with SEK as above.","Note the retention rule: plain Get IRN details (by IRN) are retrievable for 3 days from generation. GetIrnByDocDetails was introduced in Nov 2020 for the equivalent document-number lookup.","Official docs: https://einv-apisandbox.nic.in/version1.03/cancel-irn.html | https://einv-apisandbox.nic.in/version1.03/authentication.html | https://einv-apisandbox.nic.in/release-notes.html"],"gotchas":["The 24-hour cancellation window is absolute - there is no override or extension. Past 24 hours you must issue a credit or debit note instead.","Cancellation is blocked outright if a live e-way bill exists against the IRN. Cancel or let the e-way bill expire first.","SEK must be decrypted with your AppKey immediately after auth and reused for every request and response body until token expiry. A stale or wrong SEK produces silent decryption garbage, not a clear auth error.","AuthToken TTL differs by environment: 360 minutes in production versus 60 minutes in sandbox. Code tested against sandbox assumptions will misbehave in production and vice versa.","Calling auth again mid-validity returns the SAME token without resetting the timer. ForceRefreshAccessToken only takes effect in the final 10 minutes before expiry.","Base URLs differ per Invoice Registration Portal (NIC IRP1/IRP2 versus IRIS, Cygnet, EY, Clear and others) even though the payload contract is common. Confirm which IRP your GSTIN is onboarded to."],"contributor":"dpi-india-routes-v1","created":"2026-08-04T07:07:31.820Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-04T07:07:31.820Z"},"url":"https://mcp.waymark.network/r/0857e108-6816-4e9e-87a1-69159f5c21f8"}