Getting started with the Cafetariaplan API
Use the Cafetariaplan API to let employees spend their cafetaria budget on Coolblue products. This guide takes you through the first calls in Acceptance.
Before you start
- An agreement with Coolblue to offer products through your cafetariaplan.
- The company ID of each employer, which Coolblue sends you after onboarding the employer.
- Acceptance credentials for the Cafetariaplan API. See Authentication.
1. Get an access token
TOKEN=$(curl -s -X POST "https://auth.business.coolblue-acceptance.eu/oauth2/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=$CLIENT_ID" \
-d "client_secret=$CLIENT_SECRET" | jq -r .access_token)
2. Register the employee
curl -X POST "https://cafetariaplan.business.coolblue-acceptance.eu/accounts" \
-H "Authorization: Bearer $TOKEN" \
-H "User-Agent: Coolblue-YourCompanyName" \
-H "Content-Type: application/json" \
-d '{
"email": "employee@example.com",
"firstName": "Jane",
"lastName": "Doe",
"isoLanguageCode": "nl",
"companyId": "00000000-0000-0000-0000-000000000000"
}'
The response contains the employee's customerId.
3. Send the employee to Coolblue
Call POST /login with the customerId to get a short-lived, one-time login link, and redirect the employee to it.
The employee lands on their company's closed community, logged in.
4. Handle draft orders
When the employee checks out, Coolblue stores a draft order and redirects the employee back to you.
GET /customers/{customerId}/draftOrdersreturns the employee's pending draft orders.- Check the order against the employee's budget.
PUT /draftOrders/{draftOrderId}/statusconverts the draft order into a real order, or rejects it. Do this before the draft order expires (24 hours by default).
Common pitfalls
- Using Production company or customer IDs in Acceptance, or the other way around.
- Converting a draft order after it expired.
- Forgetting the
User-Agentheader.