Secure your API requests with scoped API keys.
All API requests must include your API key in the Authorization header using the Bearer scheme:
Authorization: Bearer dh_live_abc123def456...Requests without a valid key receive a 401 Unauthorized response.
DocuHub API keys follow a predictable format that makes them easy to identify in logs and secret scanners:
dh_live_<random>
Examples:
dh_live_sk7Gx2mP9qRtW4nB8vJ6yZ
dh_live_aB3cD5eF7gH9iJ1kL3mNpQThe dh_live_ prefix indicates a production key. Keys are 32 characters long including the prefix.
Each key is created with a scope that limits which endpoints it can access. Use the narrowest scope that satisfies your needs.
| Scope | Description | Allowed Endpoints |
|---|---|---|
| FULL | Unrestricted access to all API endpoints. | All |
| CONVERT_ONLY | Can only call conversion endpoints. | /v1/convert, /v1/jobs/* |
| PDF_ONLY | Can only call PDF operation endpoints. | /v1/pdf/*, /v1/jobs/* |
| READ_ONLY | Can only read job statuses and download files. | /v1/jobs/*, /v1/files/* |
If a key attempts to access an endpoint outside its scope, the API returns a 403 insufficient_scope error.
For additional security, you can restrict each API key to a set of IP addresses or CIDR ranges. Requests from unlisted IPs receive a 403 ip_not_allowed error.
Configure allowed IPs when creating or editing a key in your Developer Settings. Supported formats:
Single IP: 203.0.113.42
CIDR range: 10.0.0.0/24
IPv6: 2001:db8::1We recommend rotating your keys periodically. DocuHub supports a seamless rotation workflow:
Both keys remain valid simultaneously, so there is zero downtime during the rotation window.
Add .env to your .gitignore. If a key is accidentally committed, revoke it immediately and create a new one.
Store keys in environment variables or a secrets manager, never hard-code them.
# .env (never commit this file)
DOCUHUB_API_KEY=dh_live_sk7Gx2mP9qRtW4nB8vJ6
# In your code
const apiKey = process.env.DOCUHUB_API_KEY;We recommend rotating keys every 90 days, and immediately after any team member with access leaves your organization.
If a service only converts files, use CONVERT_ONLYinstead of FULL. This limits the blast radius if a key is compromised.