If you have an active E-Way Bill session for the same workspace, GSTIN, and NIC server (
x-source), use its access token instead of authenticating again.Prerequisites: If you haven’t created API credentials on the E-Invoice portal (NIC) yet, follow the steps in the Create API Credentials guide first, then return to this recipe.
Authenticate
To begin the GST E-Invoice workflow, your application must first authenticate using the Authenticate endpoint to obtain the Sandbox JWT access token.This endpoint requires your API Key and API Secret, and returns a JWT access token that’s valid for 24 hours. Use this token to authenticate with the e-Invoice API in the next step and to call Generate e-Invoice PDF.
When authentication is successful, you’ll receive the Sandbox JWT access token in the response. Send it in the
cURL Request
cURL Request
authorization header without the Bearer prefix.Authenticate with E-Invoice API
Once you have the Sandbox JWT access token, authenticate with the E-Invoice portal using the E-Invoice Authentication endpoint.You need to provide the username and password that were created on the E-Invoice portal (NIC), along with the taxpayer’s GSTIN (15-character GST Identification Number). The
Authentication returns an access token and an expiry timestamp. Send this token in the
force query parameter should be set to true if you need to refresh the token 10 minutes before expiry.cURL Request
cURL Request
authorization header of later e-Invoice and E-Way Bill requests, except Generate e-Invoice PDF, which uses the Sandbox access token. Send your API key in the x-api-key header on every request.This example uses x-source: primary for NIC1. See NIC1 and NIC2 routing for session and destination selection.