API Authentication
How to authenticate requests against the Polimake API using API keys and Authorization headers.
On this page
The Polimake API uses bearer token authentication in the Authorization header.
Status: preview contract. Self-serve API key management may vary depending on the rollout status of the public API.
Required Header
Authorization: Bearer YOUR_API_KEY
You must also send Content-Type: application/json on requests with a JSON body.
Content-Type: application/json
Example with curl
curl https://api.polimake.com/v1/media/search \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project_id": "brand-assets",
"query": "fotografia de equipo en oficina",
"top_k": 5
}'
Example with JavaScript
const response = await fetch("https://api.polimake.com/v1/media/search", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.POLIMAKE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
project_id: "brand-assets",
query: "fotografia de equipo en oficina",
top_k: 5,
}),
});
if (!response.ok) {
throw new Error(`Polimake API error: ${response.status}`);
}
const result = await response.json();
Example with Python
import os
import requests
response = requests.post(
"https://api.polimake.com/v1/media/search",
headers={
"Authorization": f"Bearer {os.environ['POLIMAKE_API_KEY']}",
"Content-Type": "application/json",
},
json={
"project_id": "brand-assets",
"query": "fotografia de equipo en oficina",
"top_k": 5,
},
timeout=30,
)
response.raise_for_status()
result = response.json()
Security Recommendations
- Store the API key in environment variables or a secrets manager.
- Don't include keys in frontend apps, repositories, shared notebooks, or screenshots.
- Use separate keys per environment: development, staging, and production.
- Rotate keys if you suspect exposure.
- Limit permissions per project when scopes are available.
Common Errors
401 Unauthorized
The key is missing, malformed, or invalid.
{
"error": {
"type": "authentication_error",
"message": "Missing or invalid API key"
}
}
403 Forbidden
The key exists, but it doesn't have access to the requested project or resource.
{
"error": {
"type": "permission_error",
"message": "The API key cannot access this project"
}
}
Frequently asked questions
How do you authenticate a request to the Polimake API?
Send the API key as a bearer token in the Authorization: Bearer YOUR_API_KEY header. For requests with a JSON body, also add Content-Type: application/json.
What's the difference between a 401 and a 403 error?
A 401 means the key is missing, malformed or invalid. A 403 means the key is valid but doesn't have access to the requested project or resource.
Where should I store the API key?
In environment variables or a secrets manager, never in frontend apps, repositories, shared notebooks or screenshots. Use separate keys for development, staging and production, and rotate them if you suspect they've been exposed.
Is API key management available yet?
Authentication is documented as a preview contract: self-serve API key management may vary depending on the rollout status of the public API.
Continue with Build: integrate Polimake.