# RideWrench JavaScript SDK

Works in Node.js 18+, serverless functions, edge runtimes with Web Crypto, and modern browsers. Keep API keys on a trusted server.

```js
import { RideWrench } from "@ridewrench/sdk";

const rw = new RideWrench({
  apiKey: process.env.RIDEWRENCH_PROVIDER_API_KEY,
  audience: "provider",
});

for await (const page of rw.provider.workOrders.pages({ limit: 100 })) {
  for (const order of page.data) console.log(order);
}

await rw.provider.workOrders.accept(workOrderId, {
  idempotencyKey: `accept-${workOrderId}`,
});
```

Writes automatically receive a unique idempotency key. Supply a stable key when your workflow may call the same operation again. The SDK never automatically retries a write whose result is unknown.

Provider clients also expose `catalogItems`, `inventoryItems`, and `reconciliationEntries`. Use `webhooks.deliveries(id)` to inspect an endpoint and `webhooks.replay(id, deliveryId)` to replay a failed delivery. Browser embeds live in `../embeds`; give them short-lived OAuth tokens rather than API keys.
