API Playbooks
These playbooks describe how to combine API calls, local persistence, webhook handling and error handling into stable integration flows. For the first technical walkthrough, start with the Quickstart.
Recommended implementation order
Section titled “Recommended implementation order”flowchart TD
auth[Authentication] --> customer[Customer context]
customer --> car[Car lifecycle]
car --> user[Anonymous user lifecycle]
user --> assignment[Assignment lifecycle]
assignment --> webhook[Webhook handling]
webhook --> errors[Error handling]
errors --> hardening[Production hardening]
Customer context
Section titled “Customer context”All API operations run within a specific customer context. The Customer represents your organization or tenant — not the end customer or driver.
Steps:
- Retrieve an access token (see Authentication).
- Call
GET /customerswithout aCustomer-IDheader. - Confirm that your intended Customer-ID is in the response.
- Store the Customer-ID in your backend configuration.
- Use it for all subsequent customer-scoped API calls.
Car lifecycle
Section titled “Car lifecycle”For developers, the flinkey BLE Box is abstracted behind the Car concept. Your backend works with cars, not directly with boxes.
Mapping: Partner vehicle → flinkey Car
Steps:
- Determine the partner vehicle object.
- Check whether a flinkey car mapping already exists locally.
- If yes, use the stored flinkey
carId. - If no, resolve or create the car through the API.
- Persist the mapping between partner vehicle and flinkey car.
- Use the flinkey
carIdfor assignments.
Recommended local persistence:
| Field | Description |
|---|---|
partner_vehicle_id |
Your internal vehicle identifier |
flinkey_customer_id |
Customer context |
flinkey_car_id |
flinkey car identifier |
environment |
UAT or PROD |
status |
Current state |
Anonymous user lifecycle
Section titled “Anonymous user lifecycle”In the default full partner integration, the partner system remains the source of truth for customer identity. Anonymous flinkey users are created for access purposes.
Mapping: Partner customer / driver → anonymous flinkey User
Steps:
- Determine the partner customer or driver context.
- Check whether a flinkey user mapping already exists locally.
- If yes, use the stored flinkey
userId. - If no, create an anonymous user through the API.
- Persist the mapping.
- Use the flinkey
userIdfor assignments.
Design decision: Should one partner customer map to one anonymous flinkey user, or should each booking create a separate user?
Recommended default: One partner customer or driver maps to one anonymous flinkey user per environment.
Assignment lifecycle
Section titled “Assignment lifecycle”An Assignment grants a user access to a car. It is the central access-control object in the integration.
Mapping: Partner booking / rental / access context → flinkey Assignment
Creating an assignment
Section titled “Creating an assignment”- Resolve the partner vehicle to a flinkey
carId. - Resolve the partner customer/driver to a flinkey
userId. - Validate assignment start and end time (use UTC).
- Create the assignment through the API.
- Store the local assignment as pending.
- Wait for the assignment webhook.
- Update local state based on the webhook result.
Assignment state model
Section titled “Assignment state model”stateDiagram-v2
[*] --> Draft
Draft --> Requested
Requested --> PendingWebhook
PendingWebhook --> Active: operation succeeded
PendingWebhook --> Failed: operation failed
Active --> UpdateRequested
UpdateRequested --> PendingWebhook
Active --> DeleteRequested
DeleteRequested --> Deleted: operation succeeded
DeleteRequested --> DeleteFailed: operation failed
Failed --> Requested: retry after reconciliation
Deleted --> [*]
Recommended local persistence
Section titled “Recommended local persistence”| Field | Description |
|---|---|
partner_access_context_id |
Your booking / rental ID |
flinkey_user_id |
Assigned user |
flinkey_car_id |
Target vehicle |
flinkey_assignment_id |
Assignment ID (from webhook) |
assignment_status |
Local state (Draft → Active → Deleted) |
assignment_start / assignment_end |
Access time window |
last_webhook_received_at |
When the last webhook arrived |
last_error_message |
Error detail if operation failed |
Error handling
Section titled “Error handling”Categorize errors consistently across your integration:
| Category | Typical cause | Action |
|---|---|---|
| ConfigurationError | Missing env var or wrong environment | Fail fast, notify integration owner |
| AuthenticationError | Invalid API Manager credentials | Stop retrying, fix credentials |
| ValidationError | Invalid request payload | Fix implementation or input |
| NotFoundError | Missing car, user or assignment | Reconcile local mapping |
| ConflictError | Duplicate or inconsistent state | Reconcile before retry |
| RateLimitError | Too many requests | Retry with backoff |
| RemoteServiceError | API unavailable | Retry with backoff, monitor |
| WebhookValidationError | Invalid webhook secret | Reject and investigate |
| AsyncOperationFailed | Webhook reports failure | Mark local state failed, escalate |
| TimeoutError | No webhook received | Keep pending, monitor, reconcile |
Logging rules
Section titled “Logging rules”Never log: API keys, API Manager credentials, bearer tokens, webhook secrets, SDK Keys.
Safe to log: Environment, partner object IDs, flinkey object IDs, operation type, error category, correlation ID, timestamp.
Retry rules
Section titled “Retry rules”- Retry transient network errors with exponential backoff.
- Retry token refresh once after token expiry.
- Never retry invalid credentials.
- Never blindly retry assignment creation if the first request may have succeeded.
- Reconcile state before retrying operations that create remote objects.
- Treat webhook timeout as pending — not automatically failed.
Production hardening
Section titled “Production hardening”Before going to PROD, add:
- Monitoring and alerting
- Credential rotation process
- Strict UAT/PROD separation
- Webhook retry visibility
- Operational dashboards
- Support runbooks
