Skip to main content
Recommendations for building a robust, reliable, and maintainable integration with the CleanLife Partner API.

Retry Strategy

What to Retry

Only retry idempotent operations or those with transient failures:

Exponential Backoff


Timeouts

Set a reasonable timeout on all HTTP requests. The CleanLife API is not expected to take more than a few seconds, but network conditions vary. Recommended timeout: 30 seconds per request

Idempotency (Booking Creation)

Although the Idempotency-Key header is currently disabled, you can achieve safe retries using externalReference:
  1. Before calling POST /partners/bookings, generate a unique reference (e.g., UUID or your internal order ID).
  2. Store this reference in your database with status PENDING.
  3. Call the API with externalReference set to this value.
  4. If the request fails with a network error or timeout:
    • If you receive 409 DUPLICATE_EXTERNAL_REFERENCE, the booking was created successfully — use the bookingId you stored from the original response, or treat the conflict as confirmation that creation succeeded.
    • If you receive 422 BOOKING_CREATION_FAILED, the booking failed — retry with the same externalReference.
    • If you receive no response, retry only if you have not yet received a 409; otherwise poll GET /partners/bookings/:bookingId/status using a stored bookingId.

Logging

Log the following for every API call to enable debugging and auditing:

Error Handling

Build a structured error handler that distinguishes between error categories:

Security

  1. Store API Key as a secret, not in code. Use environment variables or a secrets manager (e.g., AWS Secrets Manager, HashiCorp Vault, Azure Key Vault).
  2. Use HTTPS for all API calls.
  3. Restrict your API Key to a specific IP range if possible. Contact CleanLife to configure an IP allowlist.
  4. Rotate your API key periodically.

Performance

Cache the Service Catalog

Services change infrequently. Cache this response:

Do Not Cache Timeslots

Available timeslots change in real time as bookings are created. Always query fresh.

Pagination

Use limit=100 (the maximum) when fetching paginated catalog lists to minimize the number of API calls.

Testing

  1. Use a distinct externalReference prefix for test bookings (e.g., TEST-) to identify them in production logs.
  2. Test cancellation and payment confirmation flows end-to-end before going live.