Authentication
Learn how to authenticate requests to Oxylabs Web API endpoints.
The Oxylabs Web API uses the API key as Bearer Token for authentication. Every HTTP request sent to the API must include your API key in the Authorization request header.
Authorization: Bearer YOUR_API_KEYTo verify your credentials, you can submit a minimal search query:
curl https://webapi.oxylabs.io/v1/search \
-H "Authorization: Bearer $OXYLABS_WEB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"query": "oxylabs"}'Getting a key
Log in to the Oxylabs dashboard.
Create a Web API instance.
Generate an API key on that instance.
Export it where your application reads it (e.g. your OS terminal or the CLI terminal of the project workspace):
export OXYLABS_WEB_API_KEY=your_api_key_hereTroubleshooting 401 Unauthorized errors
An authentication failure returns an HTTP 401 status without a JSON response body. The status code itself indicates that the request was rejected.
401 on new integration
Key missing, header misspelled, or trailing whitespace/newlines from copy-pasting.
Re-copy the key from the dashboard. Check for trailing newlines or shell quote mangling (.strip()).
401 with valid key format
Key belongs to a different Oxylabs product.
Confirm the key was generated specifically on a Web API instance in the dashboard.
401 on previously working key
Key has been revoked, replaced, or deleted.
Generate a new key on your active instance.
401 across all requests
The account subscription or instance is disabled.
Contact Oxylabs support to re-enable the account.
Recommended practices for manual integrations
Environment variables
Store keys in environment variables (OXYLABS_WEB_API_KEY) or dedicated secret managers (e.g., AWS Secrets Manager, HashiCorp Vault, etc.). Avoid hardcoding keys in source code.
Key isolation
Use separate Web API instances for development, staging, and production to isolate product credit consumption and allow independent credential rotation.
Last updated
Was this helpful?