API Authentication
Learn how to authenticate your E-Sign API requests to Penvio.
API access requires a Business plan or higher.
Overview
The Penvio E-Sign API uses API key authentication. You’ll need to include your API key in the Authorization header of every request.
Obtaining an API Key
Sign in to Penvio
Go to penvio.io and sign in with your account.
Navigate to API Keys
Go to Organization Settings → API Keys.
Create a new key
Click Create API Key and enter a name for your key (e.g., “Production Backend”).
Copy the key
Copy the key immediately - it won’t be shown again.
Keep your API key secret!
- Never commit it to version control
- Never expose it in client-side code
- Use environment variables to store it
API Key Format
API keys follow the format:
pk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxpk_prefix identifies it as a Penvio API keylive_indicates a production key (vstest_for sandbox)- The remaining characters are a unique identifier
Using the API Key
Include your key in the Authorization header as a Bearer token:
Authorization: Bearer pk_live_xxxxxxxxxxxxxExamples
cURL
curl -X GET https://penvio.io/api/v1/esign/templates \
-H "Authorization: Bearer pk_live_xxxxxxxxxxxxx" \
-H "Content-Type: application/json"API Key Management
Viewing Keys
View all API keys in Organization Settings → API Keys. You’ll see:
- Key name
- Creation date
- Last used date
- Key prefix (for identification)
Revoking Keys
To revoke a compromised or unused key:
- Go to Organization Settings → API Keys
- Click Revoke on the key
- Confirm the action
Revoking a key immediately invalidates it. All applications using it will receive 401 Unauthorized responses.
Multiple Keys
Create separate keys for different environments and purposes:
| Key Name | Environment | Purpose |
|---|---|---|
prod-backend | Production | Main application |
staging-backend | Staging | Testing |
ci-testing | CI/CD | Automated tests |
This way, if one key is compromised, you only need to revoke that specific key.
Error Responses
401 Unauthorized
{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}
}This means:
- No API key was provided
- The API key is invalid or revoked
- The Authorization header format is incorrect
403 Forbidden
{
"error": {
"code": "FORBIDDEN",
"message": "Enterprise subscription required"
}
}This means:
- Your organization doesn’t have an Enterprise subscription
- BYOB storage is not configured
- The API key doesn’t have permission for the requested resource
Best Practices
-
Use environment variables
export PENVIO_API_KEY="pk_live_xxxxxxxxxxxxx" -
Create a wrapper function
async function penvioFetch(path, options = {}) { const response = await fetch(`https://penvio.io/api/v1${path}`, { ...options, headers: { 'Authorization': `Bearer ${process.env.PENVIO_API_KEY}`, 'Content-Type': 'application/json', ...options.headers, }, }); if (!response.ok) { const error = await response.json(); throw new Error(error.error?.message || 'API request failed'); } return response.json(); } -
Handle errors gracefully
- Monitor for 401 responses and alert on auth failures
- Implement retry logic for transient errors
- Log API errors for debugging
-
Audit regularly
- Review API key usage in the organization dashboard
- Rotate keys periodically (recommended: every 90 days)
- Remove unused keys promptly
-
Use the principle of least privilege
- Create separate keys for different services
- Revoke keys when no longer needed
Next Steps
- API Endpoints - Explore available API endpoints
- Rate Limits - Understand API usage limits
- Error Handling - Handle API errors gracefully
- Getting Started - Set up your Penvio account