API authentication
How to authenticate requests against the Polimake API using API keys and Authorization headers.
Coming soon This feature is not available yet. The guide describes how it will work; endpoints and fields may change before launch.
On this page
The Polimake API authenticates with a bearer token 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, never in frontend apps, repositories, shared notebooks or screenshots. Use a separate key for development, staging and production, and rotate it if you suspect it's been exposed. When scopes are available, limit each key's permissions per project.
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 is valid, but it doesn't have access to the requested project or resource.
{
"error": {
"type": "permission_error",
"message": "The API key cannot access this project"
}
}
Continue with Build: integrate Polimake.