Required Headers
All requests must include the following headers:X-Esim-Story-Access-Key: Your partner access keyX-Esim-Story-Signature: HMAC-SHA256 signature of the requestX-Esim-Story-Timestamp: Unix timestamp in seconds (UTC)
Signature Generation
The signature is generated using HMAC-SHA256 with your Base64-encoded secret key. Follow these steps:- Decode your secret key from Base64
- Construct the raw string using newline characters (
\n): - Generate HMAC-SHA256 signature using the decoded secret key
- Convert to hexadecimal string (lowercase)
- Use the exact HTTP method in uppercase (e.g.,
POST,GET) - Use the exact request path (e.g.,
/api/v1/api_partner/orders) - do not include query parameters or domain - Timestamp must be Unix timestamp in seconds (not milliseconds)
- All components must be joined with newline characters (
\n)
Example
Authentication Flow
The authentication process follows these steps:- Extract headers - Server reads
X-Esim-Story-Access-Key,X-Esim-Story-Signature, andX-Esim-Story-Timestamp - Validate headers - All three headers must be present
- Validate timestamp - Timestamp must be within 5 minutes of current UTC time
- Find partner - Look up partner by access key
- Verify secret key - Ensure partner has a valid secret key
- Generate expected signature - Recreate signature using the same algorithm
- Compare signatures - Use constant-time comparison to prevent timing attacks
Security Requirements
- Timestamp Validation: The timestamp must be within 5 minutes of the current UTC time to prevent replay attacks
- Secret Key: Your secret key is stored Base64-encoded and must be decoded before use in signature generation
- Path: Use the exact request path (e.g.,
/api/v1/api_partner/orders) - do not include:- Query parameters
- Domain name
- Protocol
- Method: Use the exact HTTP method in uppercase (e.g.,
POST,GET) - Newline Characters: The raw string must use actual newline characters (
\n), not literal\nstrings
Error Responses
If authentication fails, you’ll receive a401 Unauthorized response:
"Missing required authentication headers."- One or more required headers (X-Esim-Story-Access-Key,X-Esim-Story-Signature,X-Esim-Story-Timestamp) are missing"Request timestamp is too old or invalid."- Timestamp is outside the 5-minute window or invalid format"Invalid or missing access key. Please provide a valid X-Esim-Story-Access-Key header."- Access key is incorrect or partner not found"Missing secret key in partner record."- Partner exists but has no secret key configured"Invalid signature."- Signature verification failed (most common cause: incorrect raw string construction or secret key)