Installatiehandleiding
Deze handleiding begeleidt je bij het maken van je eerste API-koppeling met Routix — van het registreren van een OAuth-app tot het maken van je eerste API-call.
Vereisten
- Een Routix-account met admin of eigenaar toegang
- Minimaal één vestiging aangemaakt in je organisatie
- Een server of applicatie die de API gaat consumeren
Stap 1: Registreer een OAuth App
Optie A: Via het Routix Dashboard
- Log in bij Routix op app.routix.nl
- Ga naar Instellingen → OAuth Apps
- Klik op App Aanmaken
- Vul het formulier in:
| Veld | Verplicht | Beschrijving | Voorbeeld |
|---|---|---|---|
| Naam | Ja | Beschrijvende naam voor je integratie | Mijn ERP Sync |
| Beschrijving | Nee | Wat de integratie doet | Synchroniseert accounts van Routix naar ons ERP |
| Homepage URL | Nee | Website van je applicatie | https://mijn-erp.nl |
| Redirect URIs | Ja | Callback URLs (voor Auth Code flow) | https://mijn-erp.nl/callback |
| Scopes | Ja | Permissies die je app nodig heeft | routix:accounts:read |
| Vestigingbeperkingen | Nee | Beperk toegang tot specifieke vestigingen | Laat leeg voor alle vestigingen |
- Klik op Opslaan
- Kopieer het client secret direct — het wordt maar één keer getoond!
Optie B: Via de API
curl -X POST https://api.routix.nl/functions/v1/register-oauth-app \
-H "Content-Type: application/json" \
-H "Authorization: Bearer JOUW_GEBRUIKERS_TOKEN" \
-d '{
"name": "Mijn ERP Sync",
"description": "Synchroniseert accounts van Routix naar ons ERP",
"redirect_uris": ["https://mijn-erp.nl/callback"],
"allowed_scopes": ["routix:accounts:read", "routix:accounts:write"],
"allowed_branch_ids": []
}'Response:
{
"success": true,
"app": {
"id": "a1b2c3d4-...",
"name": "Mijn ERP Sync",
"client_id": "e5f6g7h8-...",
"client_secret": "routix_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0",
"redirect_uris": ["https://mijn-erp.nl/callback"],
"allowed_scopes": ["routix:accounts:read", "routix:accounts:write"],
"allowed_branch_ids": [],
"status": "active",
"created_at": "2026-02-10T12:00:00Z"
},
"warning": "Bewaar het client_secret veilig — het wordt niet opnieuw getoond."
}Belangrijk: Het
client_secretheeft het formaatroutix_<40 hex tekens>(47 tekens totaal). Bewaar het in een secrets manager. Bij verlies moet je het secret roteren.
Stap 2: Zoek je Vestiging-ID
Elke API-call vereist een publiek vestiging-ID (8-teken code).
- Ga naar Instellingen → Vestigingen in Routix
- Elke vestiging toont haar Publiek ID (bijv.
RS2RDH3B) - Dit korte ID wordt gebruikt in de API URL in plaats van de interne UUID
Stap 3: Haal een Access Token op
Voor backend-integraties (Client Credentials)
curl -X POST https://api.routix.nl/functions/v1/oauth-token \
-H "Content-Type: application/json" \
-d '{
"grant_type": "client_credentials",
"client_id": "JOUW_CLIENT_ID",
"client_secret": "routix_a1b2c3d4..."
}'Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"token_type": "bearer",
"expires_in": 3600,
"scope": "routix:accounts:read routix:accounts:write",
"organization_id": "org-uuid",
"branch_ids": ["branch-uuid"]
}Voor gebruikersgerichte apps (Authorization Code + PKCE)
Zie de volledige OAuth Flow documentatie.
Stap 4: Maak je Eerste API-Call
Met je token en vestiging-ID, maak een request:
curl -X GET "https://api.routix.nl/functions/v1/api/v1/RS2RDH3B/accounts?limit=5" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."Verwachte response:
{
"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"
}
],
"pagination": {
"limit": 5,
"offset": 0,
"total": 1
},
"version": "v1"
}🎉 Gefeliciteerd — je API-koppeling werkt!
Stap 5: Secrets Roteren
Als je client secret gecompromitteerd is, of als onderdeel van reguliere beveiligingshygiëne:
Via het Dashboard
- Ga naar Instellingen → OAuth Apps → Jouw App
- Klik op Secret Roteren
- Kopieer het nieuwe secret direct
- Werk je applicatieconfiguratie bij
- Het oude secret wordt direct ongeldig
Via de API
curl -X POST https://api.routix.nl/functions/v1/rotate-oauth-secret \
-H "Content-Type: application/json" \
-H "Authorization: Bearer JOUW_GEBRUIKERS_TOKEN" \
-d '{
"oauth_app_id": "JOUW_APP_UUID"
}'Response:
{
"success": true,
"client_secret": "routix_nieuw_secret_hier...",
"client_secret_last4": "s9t0",
"warning": "Bewaar het client_secret veilig — het wordt niet opnieuw getoond."
}Let op: Bestaande tokens blijven geldig tot ze verlopen (max 1 uur). Alleen nieuwe tokenverzoeken hebben het nieuwe secret nodig.
Stap 6: App Intrekken of Heractiveren
Intrekken
Om direct te blokkeren dat een app nieuwe tokens aanvraagt:
- In het dashboard: OAuth Apps → Jouw App → Intrekken
- Via API: Update
statusnaar"revoked"op deoauth_appsresource
Intrekken van een app:
- Voorkomt nieuwe tokenverzoeken
- Bestaande tokens blijven geldig tot expiry (max 1 uur)
- De API proxy controleert app-status bij elk request
Heractiveren
Om een ingetrokken app weer in te schakelen:
- In het dashboard: OAuth Apps → Jouw App → Activeren
- Via API: Update
statusnaar"active"
Probleemoplossing
| Fout | Oorzaak | Oplossing |
|---|---|---|
401 — invalid_token | Token verlopen of ongeldig | Vraag een nieuw token aan |
403 — invalid_token_type | Regulier gebruikerstoken i.p.v. OAuth | Gebruik het /oauth-token endpoint voor een OAuth-token |
403 — insufficient_scope | Ontbrekende vereiste scope | Controleer de allowed_scopes van je app |
404 — branch_not_found | Ongeldig publiek vestiging-ID | Verifieer het 8-teken vestiging-ID in Instellingen → Vestigingen |
403 — branch access denied | App is beperkt tot andere vestigingen | Werk allowed_branch_ids bij, of gebruik een toegestane vestiging |
invalid_client | Verkeerde client_id of secret | Controleer credentials; roteer secret indien nodig |
Beschikbare Scopes Referentie
| Scope | Beschrijving |
|---|---|
routix:accounts:read | Lees accounts (klanten, leveranciers, vervoerders) |
routix:accounts:write | Maak accounts aan of werk ze bij |
routix:orders:read | Lees orders |
routix:orders:write | Maak orders aan of werk ze bij |
routix:vehicles:read | Lees voertuigen |
routix:vehicles:write | Maak voertuigen aan of werk ze bij |
routix:staff:read | Lees medewerkers |
routix:equipment:read | Lees materieel |
routix:planning:read | Lees planning/routedata |
routix:invoices:read | Lees facturen |
routix:invoices:write | Maak facturen aan of werk ze bij |
Checklist
- Registreer een OAuth-app in Routix (dashboard of API)
- Bewaar
client_idenclient_secretveilig - Implementeer token-verkrijging (Client Credentials of Authorization Code + PKCE)
- Handel token-expiry en vernieuwing af
- Gebruik het juiste 8-teken publiek vestiging-ID in API URLs
- Vraag alleen de scopes aan die je app nodig heeft
- Handel foutresponses af (401, 403, 404, 429)
- Plan een schema voor secret-rotatie
- Test met
v1voor stabiele veldcontracten