API Calls & Voorbeelden
De Routix API is een versioned REST API toegankelijk via de API proxy. Alle requests vereisen een geldig OAuth-token.
Base URL
https://api.routix.nl/functions/v1/api/{versie}/{publiekVestigingId}/{resource}| Segment | Beschrijving | Voorbeeld |
|---|---|---|
{versie} | API versie | v1 of v2 |
{publiekVestigingId} | 8-teken publiek vestiging-ID | RS2RDH3B |
{resource} | Resource naam | accounts |
Volledig voorbeeld:
GET https://api.routix.nl/functions/v1/api/v1/RS2RDH3B/accountsAuthenticatie
Voeg het OAuth access token toe aan elk request:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...Alleen OAuth-tokens worden geaccepteerd. Reguliere Routix-gebruikerstokens worden geweigerd door de API proxy.
Beschikbare Resources
| Resource | Vereiste Scope | Status |
|---|---|---|
accounts | routix:accounts:read | ✅ Live |
orders | routix:orders:read | 🔜 Gepland |
vehicles | routix:vehicles:read | 🔜 Gepland |
Accounts
Accounts Ophalen
GET /functions/v1/api/v1/{vestigingId}/accountsQuery parameters:
| Parameter | Type | Standaard | Max | Beschrijving |
|---|---|---|---|---|
limit | integer | 50 | 1000 | Aantal records per pagina |
offset | integer | 0 | — | Paginatie offset |
Voorbeeld request:
curl -X GET "https://api.routix.nl/functions/v1/api/v1/RS2RDH3B/accounts?limit=10&offset=0" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."Voorbeeld response (v1):
{
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"company_name": "Acme Transport B.V.",
"email": "info@acmetransport.nl",
"phone": "+31 20 123 4567",
"account_type": "customer",
"status": "active"
},
{
"id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"company_name": "FastFreight Logistics",
"email": "contact@fastfreight.nl",
"phone": "+31 30 987 6543",
"account_type": "carrier",
"status": "active"
}
],
"pagination": {
"limit": 10,
"offset": 0,
"total": 2
},
"version": "v1"
}Velden Per Versie
v1 Velden (Accounts)
De v1 response bevat een stabiele, onveranderlijke set van 6 velden:
| Veld | Type | Beschrijving |
|---|---|---|
id | uuid | Uniek identifier |
company_name | string | Bedrijfsnaam |
email | string | Primair e-mailadres |
phone | string | Telefoonnummer |
account_type | string | customer, vendor of carrier |
status | string | Accountstatus |
v2 Velden (Accounts)
v2 retourneert alle v1 velden plus extra detailvelden:
| Extra Veld | Type | Beschrijving |
|---|---|---|
website | string | Bedrijfswebsite |
industry | string | Branche |
lead_source | string | Hoe het account is verkregen |
visit_address_street | string | Bezoekadres — straat |
visit_address_number | string | Bezoekadres — nummer |
visit_address_addition | string | Bezoekadres — toevoeging |
visit_address_zipcode | string | Bezoekadres — postcode |
visit_address_city | string | Bezoekadres — stad |
shipping_address_street | string | Verzendadres — straat |
shipping_address_number | string | Verzendadres — nummer |
shipping_address_addition | string | Verzendadres — toevoeging |
shipping_address_zipcode | string | Verzendadres — postcode |
shipping_address_city | string | Verzendadres — stad |
billing_address_street | string | Factuuradres — straat |
billing_address_number | string | Factuuradres — nummer |
billing_address_addition | string | Factuuradres — toevoeging |
billing_address_zipcode | string | Factuuradres — postcode |
billing_address_city | string | Factuuradres — stad |
invoice_email | string | Apart factuur-e-mailadres |
vat_number | string | BTW-nummer |
chamber_of_commerce_number | string | KvK-nummer |
iban | string | Bankrekening (IBAN) |
bic | string | Bank BIC/SWIFT-code |
payment_terms | string | Betalingsvoorwaarden |
credit_limit | number | Kredietlimiet |
comment | string | Interne opmerkingen |
registration_date | timestamp | Registratiedatum |
created_at | timestamp | Aanmaakdatum record |
last_updated_at | timestamp | Laatste wijzigingsdatum |
Aanbeveling: Gebruik
v1voor stabiele productie-integraties. Gebruikv2als je de extra details nodig hebt en om kunt gaan met veldtoevoegingen.
Response Formaat
Succes — Lijst
{
"data": [ ... ],
"pagination": {
"limit": 50,
"offset": 0,
"total": 123
},
"version": "v1"
}Fout
{
"error": "insufficient_scope",
"error_description": "Token does not contain the required scope: routix:accounts:read"
}HTTP Statuscodes
| Code | Betekenis |
|---|---|
200 | Succes |
400 | Ongeldig verzoek — ongeldige parameters |
401 | Niet geautoriseerd — token ontbreekt of verlopen |
403 | Verboden — onvoldoende scopes of vestigingstoegang |
404 | Niet gevonden — ongeldig vestiging-ID of resource |
405 | Methode niet toegestaan — alleen GET wordt ondersteund |
429 | Rate limit bereikt |
500 | Interne serverfout |
Rate Limits
| Endpoint | Limiet |
|---|---|
| REST API | 1000 requests/min per organisatie |
| Edge Functions | 100 requests/min per gebruiker |
| Token endpoint | 30 requests/min per client |
Bij rate limiting ontvang je een 429 response. Implementeer exponential backoff met jitter.
Codevoorbeelden
JavaScript / Node.js
const ROUTIX_URL = 'https://api.routix.nl';
// Stap 1: Token ophalen (Client Credentials)
async function getToken(clientId, clientSecret) {
const res = await fetch(`${ROUTIX_URL}/functions/v1/oauth-token`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret,
}),
});
if (!res.ok) {
const err = await res.json();
throw new Error(`Auth mislukt: ${err.error_description}`);
}
const data = await res.json();
return data.access_token;
}
// Stap 2: Accounts ophalen
async function getAccounts(token, branchId, { limit = 50, offset = 0 } = {}) {
const url = `${ROUTIX_URL}/functions/v1/api/v1/${branchId}/accounts?limit=${limit}&offset=${offset}`;
const res = await fetch(url, {
headers: { Authorization: `Bearer ${token}` },
});
if (!res.ok) {
const err = await res.json();
throw new Error(`API fout: ${err.error_description}`);
}
return res.json();
}
// Gebruik
const token = await getToken('your-client-id', 'routix_a1b2c3d4...');
const result = await getAccounts(token, 'RS2RDH3B', { limit: 10 });
console.log(`${result.pagination.total} accounts gevonden`);
result.data.forEach(a => console.log(`${a.company_name} (${a.account_type})`));Python
import requests
ROUTIX_URL = "https://api.routix.nl"
def get_token(client_id: str, client_secret: str) -> str:
"""Haal een OAuth access token op via Client Credentials."""
response = requests.post(
f"{ROUTIX_URL}/functions/v1/oauth-token",
json={
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": client_secret,
},
)
response.raise_for_status()
return response.json()["access_token"]
def get_accounts(token: str, branch_id: str, limit: int = 50, offset: int = 0) -> dict:
"""Haal accounts op van een specifieke vestiging."""
response = requests.get(
f"{ROUTIX_URL}/functions/v1/api/v1/{branch_id}/accounts",
headers={"Authorization": f"Bearer {token}"},
params={"limit": limit, "offset": offset},
)
response.raise_for_status()
return response.json()
# Gebruik
token = get_token("your-client-id", "routix_a1b2c3d4...")
result = get_accounts(token, "RS2RDH3B", limit=10)
print(f"{result['pagination']['total']} accounts gevonden")
for account in result["data"]:
print(f" {account['company_name']} ({account['account_type']})")PHP
<?php
$routixUrl = 'https://api.routix.nl';
// Stap 1: Token ophalen
function getToken(string $clientId, string $clientSecret): string {
global $routixUrl;
$ch = curl_init("$routixUrl/functions/v1/oauth-token");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'grant_type' => 'client_credentials',
'client_id' => $clientId,
'client_secret' => $clientSecret,
]),
]);
$response = json_decode(curl_exec($ch), true);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200) {
throw new Exception("Auth mislukt: " . ($response['error_description'] ?? 'Onbekende fout'));
}
return $response['access_token'];
}
// Stap 2: Accounts ophalen
function getAccounts(string $token, string $branchId, int $limit = 50, int $offset = 0): array {
global $routixUrl;
$url = "$routixUrl/functions/v1/api/v1/$branchId/accounts?" . http_build_query([
'limit' => $limit,
'offset' => $offset,
]);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer $token"],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
return $response;
}
// Gebruik
$token = getToken('your-client-id', 'routix_a1b2c3d4...');
$result = getAccounts($token, 'RS2RDH3B', 10);
echo "{$result['pagination']['total']} accounts gevonden\n";
foreach ($result['data'] as $account) {
echo " {$account['company_name']} ({$account['account_type']})\n";
}C# / .NET
using System.Net.Http.Json;
var routixUrl = "https://api.routix.nl";
var httpClient = new HttpClient();
// Token ophalen
var tokenResponse = await httpClient.PostAsJsonAsync(
$"{routixUrl}/functions/v1/oauth-token",
new {
grant_type = "client_credentials",
client_id = "your-client-id",
client_secret = "routix_a1b2c3d4..."
});
var tokenData = await tokenResponse.Content.ReadFromJsonAsync<Dictionary<string, object>>();
var token = tokenData["access_token"].ToString();
// Accounts ophalen
httpClient.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
var accounts = await httpClient.GetFromJsonAsync<JsonElement>(
$"{routixUrl}/functions/v1/api/v1/RS2RDH3B/accounts?limit=10");
Console.WriteLine($"{accounts.GetProperty("pagination").GetProperty("total")} accounts gevonden");Last updated on