Overview
The Digitzs API uses a two-step authentication process to ensure secure access to your merchant services:- Authentication - Verifying your identity
- Authorization - Granting access to API resources
All API requests require proper authentication headers. Tokens expire after one hour and must be refreshed.
Before You Begin
You will need the following credentials provided during onboarding:API Key
Your unique API key (
x-api-key)Application ID
Your application identifier (
appId)Authentication Flow
1
Generate App Key
Create an app key using your API key and application ID
2
Create App Token
Use the app key to generate a temporary access token
3
Make Authenticated Requests
Include the token in your API requests
Step 1: Generate App Key
Create an app key that will be used to generate access tokens.Endpoint
Request Headers
Request Body
Request Parameters
Response
Response Parameters
Code Examples
Step 2: Create App Token
Generate a temporary access token using your app key. This token is required for all subsequent API calls.Endpoint
Request Headers
Request Body
Request Parameters
Response
Response Parameters
Code Examples
Step 3: Making Authenticated Requests
Once you have an app token, include it in all API requests using the required headers.Required Headers for API Calls
Example Authenticated Request
Token Management
Token Expiration
App tokens expire after one hour from creation. When a token expires, you will receive a401 Unauthorized error.
Refreshing Tokens
To refresh an expired token, simply call the/auth/token endpoint again with your app key. You do not need to regenerate the app key unless you want to invalidate all existing tokens.
Best Practices
Store Securely
Store your API key and app key securely using environment variables or secret management services
Implement Retry Logic
Automatically refresh tokens when you receive a 401 error
Cache Tokens
Cache tokens and reuse them until they expire to reduce API calls
Monitor Expiration
Track token creation time and proactively refresh before expiration
Complete Authentication Example
Here’s a complete example that handles the full authentication flow:Troubleshooting
403 Forbidden Error
403 Forbidden Error
This error indicates:
- Your account is not authorized to access the requested resource
- Your API key has been revoked or suspended
Invalid App Key
Invalid App Key
If you receive an error when creating a token:
- Your app key may have been regenerated
- The app key was not properly stored from Step 1
/auth/key and try again.Missing Headers
Missing Headers
All authenticated requests require three headers:
Authorization: Bearer {token}x-api-key: {your-api-key}appId: {your-app-id}
Security Best Practices
Never Expose Keys
Never commit API keys or tokens to version control or expose them in client-side code
Use Environment Variables
Store credentials in environment variables or secure secret management systems
Rotate Keys Regularly
Periodically regenerate your app keys to maintain security
Use HTTPS Only
Always make requests over HTTPS to encrypt data in transit
Next Steps
Now that you understand authentication, you’re ready to start using the API:Create a Merchant
Set up merchant accounts
Process Payments
Start accepting payments
View Error Codes
Handle errors properly

