Create Authentication Token
API to create Bearer token for authenticating subsequent API calls. Token is valid for 24 hours.
API Endpoint
POST
https://einvoice-api-sandbox.sepay.vn/v1/tokenAuthentication
This API uses Basic Authentication with the following credentials:
- Username:
client_id(provided upon registration) - Password:
client_secret(provided upon registration)
Authorizationheaderrequired
Basic Authentication: `Basic base64(client_id:client_secret)`
Note
- Send the request with an empty body (no request body required)
- Token is valid for 86400 seconds (24 hours)
- Use this token in the
Authorization: Bearer {access_token}header for subsequent API calls
API Response
Response 200 - Token created successfully
{
"success": true,
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 86400
}
}successboolean
dataobject
Error Handling
400Bad RequestMissing or invalid parameters.
401UnauthorizedInvalid client_id or client_secret.
Response 401 - Unauthorized
{
"success": false,
"error": {
"code": "BAD_REQUEST",
"message": "Thiếu hoặc sai định dạng trường bắt buộc."
}
}Code Examples
>
>
>
curl --request POST \--url https://einvoice-api-sandbox.sepay.vn/v1/token \--header 'Authorization: Basic REPLACE_BASIC_AUTH'
Using the Token
After obtaining the access_token, use it in the header of other eInvoice APIs:
JSUsing Bearer Token
1
2
3
4
5
6
7
8
9
10
11
// Add token to Authorization headerconst headers = {'Authorization': 'Bearer ' + access_token,'Content-Type': 'application/json'};// Call other eInvoice APIconst response = await fetch('https://einvoice-api.sepay.vn/v1/invoices', {method: 'GET',headers: headers});
Next Steps
After obtaining the access token, you can:
- List Provider Accounts - Get the list of eInvoice provider accounts to select which account to use
- Check Usage Quota - View remaining invoice issuance quota in your service plan
- Create eInvoice - Start creating your first eInvoice