Request a bearer token

Exchange your Voyced API key and API secret for a temporary bearer token.

POST/v1/auth/token
Required authentication: API key and API secretCreates a temporary token
Start with Sandbox
Every example on this page uses https://sandbox.voycedconnect.eu/v1. After Voyced enables Live access, change the base URL to https://api.voycedconnect.eu/v1, use the separate Live API key and secret, request a new Live bearer token, then run GET /v1/test and GET /v1/capabilities again. Sandbox credentials and tokens never work in Live. See the complete go-live steps.

Example request

cURL
curl --request POST \
  --url 'https://sandbox.voycedconnect.eu/v1/auth/token' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
    "api_key": "YOUR_SANDBOX_API_KEY",
    "api_secret": "YOUR_SANDBOX_API_SECRET"
  }'
PHP
<?php
$apiKey = (string) getenv('VOYCED_API_KEY');
$apiSecret = (string) getenv('VOYCED_API_SECRET');
if ($apiKey === '' || $apiSecret === '') {
    throw new RuntimeException('Set VOYCED_API_KEY and VOYCED_API_SECRET.');
}
$curl = curl_init('https://sandbox.voycedconnect.eu/v1/auth/token');
curl_setopt_array($curl, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_CONNECTTIMEOUT => 5,
    CURLOPT_TIMEOUT => 20,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_HTTPHEADER => ['Accept: application/json', 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => json_encode(['api_key' => $apiKey, 'api_secret' => $apiSecret], JSON_THROW_ON_ERROR),
]);
$response = curl_exec($curl);
$status = (int) curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
if ($response === false) {
    $error = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException($error);
}
curl_close($curl);
$data = json_decode($response, true, 512, JSON_THROW_ON_ERROR);
if ($status !== 200 || empty($data['data']['access_token'])) {
    throw new RuntimeException($data['error']['message'] ?? 'Token request failed.');
}
echo 'Token received. Expires at ' . ($data['data']['expires_at'] ?? 'the reported expiry time') . PHP_EOL;
Node.js
const apiKey = process.env.VOYCED_API_KEY;
const apiSecret = process.env.VOYCED_API_SECRET;
if (!apiKey || !apiSecret) throw new Error('Set VOYCED_API_KEY and VOYCED_API_SECRET.');
const response = await fetch('https://sandbox.voycedconnect.eu/v1/auth/token', {
  method: 'POST',
  headers: {Accept: 'application/json', 'Content-Type': 'application/json'},
  body: JSON.stringify({api_key: apiKey, api_secret: apiSecret}),
  redirect: 'error',
  signal: AbortSignal.timeout(20_000),
});
const result = await response.json();
if (!response.ok || !result.data?.access_token) {
  throw new Error(result.error?.message || `Voyced API HTTP ${response.status}`);
}
console.log(`Token received. Expires at ${result.data.expires_at}`);
Python
import os
import requests

response = requests.post(
    "https://sandbox.voycedconnect.eu/v1/auth/token",
    json={"api_key": os.environ["VOYCED_API_KEY"], "api_secret": os.environ["VOYCED_API_SECRET"]},
    headers={"Accept": "application/json"},
    timeout=20,
    allow_redirects=False,
)
response.raise_for_status()
result = response.json()
if not result.get("data", {}).get("access_token"):
    raise RuntimeError("The response did not contain a bearer token.")
print(f"Token received. Expires at {result['data'].get('expires_at', 'the reported expiry time')}")

Request body

FieldDescription
api_keyThe API key supplied by Voyced for this environment.
api_secretThe matching API secret. Treat it like a password.

Example response

200 JSON
{
  "success": true,
  "request_id": "req_example1234567890",
  "data": {
    "access_token": "TEMPORARY_BEARER_TOKEN",
    "token_type": "Bearer",
    "expires_in": 3600,
    "expires_at": "2026-07-21T11:00:00+00:00"
  }
}

Response fields

FieldDescription
access_tokenTemporary token used in the Authorization header.
token_typeAlways Bearer.
expires_inNumber of seconds until expiry.
expires_atExpiry time in UTC.
Why there is no browser test button
This documentation site never asks you to enter an API secret. Test the token request in your terminal, server code, Postman, Make, Zapier or n8n.

Common errors

HTTPCodeMeaning
400missing_credentialsThe API key or API secret is missing.
401invalid_credentialsThe supplied credentials are not valid for this environment.
500server_errorVoyced could not issue the token.