Skip to main content
The @tybrite-labs/tldp-sdk package is a fully typed TypeScript client for the TLDP (Tybrite Logistics Developer Platform) API. It provides strongly typed service classes for every resource — orders, shipments, rates, tracking, returns, webhooks, proof of delivery, and system — so you can build African logistics workflows with confidence and minimal boilerplate.

Installation

Install the SDK using your preferred package manager.

Initialize the Client

Import the TLDP class and create a client instance with your API key. Keep your secret key out of client-side bundles — initialize the client in a server-side or backend context only.
The constructor accepts a Partial<OpenAPIConfig> object with the following options:

Available Services

Once you have a client instance, access each resource through its dedicated service property.

Error Handling

Every service method throws an ApiError when the API returns a non-2xx response. Import ApiError alongside TLDP and wrap calls in a try/catch block to handle errors gracefully.
ApiError exposes the following fields:

Cancellation

Every service method returns a CancelablePromise. Call .cancel() on the returned promise to abort the in-flight request — useful for debounced search inputs, timeout logic, or component unmount cleanup.
CancelablePromise supports the full Promise interface — .then(), .catch(), .finally() — plus the .cancel() method.

Retry Behavior

The SDK retries failed requests automatically so transient network errors and brief API unavailability do not require manual handling in your code. Retries are triggered on the following HTTP status codes: 429, 500, 502, 503, 504. The SDK uses exponential backoff with jitter between attempts and respects the Retry-After header on 429 Too Many Requests responses. Configure retry behavior in the constructor:
Set MAX_RETRIES: 0 to disable automatic retries entirely — for example, when you are managing retry logic yourself or running integration tests.

Idempotency

For mutation requests such as fulfilOrder or createShipment, pass an idempotencyKey argument directly on the method call to safely retry without creating duplicate resources. Both methods accept idempotencyKey as a top-level parameter alongside requestBody.
Generate idempotency keys from a UUID v4 or a hash of the request parameters. Reuse the same key when retrying the exact same request; use a fresh key for logically different requests.

Explore the Services

Orders

Create, fulfil, and manage orders through the full order lifecycle.

Shipments

Create and manage shipments directly, bypassing the order layer.

Rates

Fetch competitive courier quotes and list delivery zones.

Tracking

Track shipments in real time — public or detailed event history.

Returns

Request and manage the full returns and exchanges lifecycle.

Webhooks

Subscribe to order, shipment, payment, and return events.

Proof of Delivery

Retrieve photo, OTP, or signature proof for delivered shipments.