Create a mileage entry
POST /mileage
Requires the mileage:write scope and an Idempotency-Key header. Registers one trip for an employee. The trip waits for the company's owner to approve it; nothing is booked and nothing is paid until then. No addresses or vehicle are accepted.
Authentication
Requires a bearer access token with the mileage:write scope.
Idempotency
Send an Idempotency-Key header with every request. See Idempotency. The sample generates one with uuidgen.
Body
JSON. A field that is not listed is refused.
| Name | Required | Description |
|---|---|---|
employee_ref | Yes | The employee, as returned by the shifts or mileage reads. |
date | Yes | The day of the trip, YYYY-MM-DD. Not later than tomorrow and not older than 13 months. |
distance_km | Yes | Distance in km, above 0 and at most 1000. |
purpose | Yes | Why the trip was made, 1 to 120 characters. |
Errors
See Errors for the full list of status codes this endpoint can return.
Samples
curl
curl -X POST "https://app.sparro.dk/api/v2/mileage" \
-H "Authorization: Bearer $SPARRO_ACCESS_TOKEN" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"employee_ref":"emp_Qm9hcmRFeGFtcGxlUmVmZXJlbmNlS2V5Rm9yRG9jc09","date":"2026-10-30","distance_km":42.5,"purpose":"Customer visit"}'