Authentication
Make an API key, swap it for a 15-minute access token, and send the token on each request.
A script signs in with a personal API key. You don't send the key on every request. Instead you exchange it for an access token that lasts 15 minutes, and send that token. When it runs out, exchange the key again.
1. Make an API key
- Sign in to Vox Pop and open Settings → Account & security.
- Under API keys, give the key a name you'll recognise later, like "Export script on my laptop".
- Copy the key straight away. It's shown once. Vox Pop stores only a hash of it.
Keys start with vpk_. You can have up to 10 active keys, and you can revoke one from the same screen at any time. A revoked key can't be exchanged again, and any token already made from it runs out within 15 minutes.
Treat a key like a password. Keep it in an environment variable or a secrets manager, not in source control. The examples below read it from VOXPOP_API_KEY.
2. Exchange it for an access token
Send the key to POST /api/v1/auth/token. This is the only endpoint that takes the key itself, and it needs no Authorization header.
curl -X POST https://api.voxpop.audio/api/v1/auth/token \
-H "Content-Type: application/json" \
-d '{"apiKey": "'"$VOXPOP_API_KEY"'"}'The token is in data.accessToken:
{
"success": true,
"data": {
"accessToken": "eyJhbGciOi...",
"tokenType": "Bearer",
"expiresAt": "2026-10-16T18:15:00.000Z"
}
}expiresAt is 15 minutes after the exchange. A key you've revoked, or one that doesn't exist, gets a 401. The exchange is limited to 5 calls a minute, so cache the token rather than exchanging the key before every request.
3. Send the token
Put the token in the Authorization header as a Bearer token:
curl https://api.voxpop.audio/api/v1/exports/replies \
-H "Authorization: Bearer $ACCESS_TOKEN"When the token has expired you get a 401. Exchange the key again and retry the request.
A token helper
A small function that exchanges the key once and reuses the token until it's close to expiring:
// Node 18+ or any runtime with fetch.
let cached = null;
async function getAccessToken() {
// Reuse the token until a minute before it expires.
if (cached && Date.parse(cached.expiresAt) - Date.now() > 60_000) {
return cached.accessToken;
}
const res = await fetch('https://api.voxpop.audio/api/v1/auth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ apiKey: process.env.VOXPOP_API_KEY }),
});
const body = await res.json();
if (!body.success) {
throw new Error(`Token exchange failed (${res.status}): ${body.error.message}`);
}
cached = body.data;
return cached.accessToken;
}What a token can do
An access token made from an API key works only on the endpoints the API reference lists as needing one. Today that's the reply export. The reference's other endpoints take no credential, and ignore a token if you send one. Endpoints outside the reference that need a sign-in answer 403 to a token, and a token can never be used to make or revoke API keys.