> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trylath.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Every Lath operation is POST https://platform.trylath.com/<operation name with dots replaced by slashes>, with a JSON body and `Authorization: Bearer <key>`. `email.send` is POST /email/send.
> Branch on `error.code`, never on `error.message`. Every refusal also carries `error.fix`, which names the next step.
> Send an `Idempotency-Key` header on any operation that is not retry-safe, so a retry cannot run it twice.
> A `lath_test_` key emails only the account's own members and sends no SMS; a `lath_live_` key reaches real recipients and is billed.
> The OpenAPI document, generated from the same registry as the routes, is at https://platform.trylath.com/openapi.json.

# Hono, Workers and Bun

> The client is fetch and nothing else, so it runs wherever fetch does — Cloudflare Workers, Deno, Bun, Vercel Edge. One import needs Node, and it is worth knowing which before you deploy.

<Steps>
  <Step title="Protect routes">
    `lathHono` puts the verified user on the context under `lath`. Token verification uses `jose`, which is WebCrypto — no Node built-in, so this works unchanged on every edge runtime.

    ```ts theme={null}
    import { Hono } from "hono";
    import { lathHono } from "@trylath/sdk";

    const app = new Hono();
    app.use("/api/*", lathHono({ environmentId: Bun.env.LATH_ENV_ID! }));

    app.get("/api/me", (c) => c.json(c.get("lath")));
    ```
  </Step>

  <Step title="The one Node dependency">
    `verifyWebhook` imports `node:crypto` for its HMAC and its constant-time compare. Everything else in the SDK — the client, `verifyAccessToken`, the middleware — is `fetch` and `jose`.

    So on Cloudflare Workers a webhook route needs `nodejs_compat`; Deno and Bun provide `node:crypto` already. If you would rather not enable it, the webhooks guide has a dependency-free verification you can paste, and WebCrypto's `crypto.subtle` covers the same ground.

    ```toml theme={null}
    # wrangler.toml
    compatibility_flags = ["nodejs_compat"]
    ```
  </Step>

  <Step title="Keys in a Worker">
    A Worker has no `process.env`. Bind the secret and read it off the environment argument, so the key is never inlined into the script.

    ```ts theme={null}
    import { createLath } from "@trylath/sdk";

    export default {
      async fetch(req: Request, env: { LATH_API_KEY: string }) {
        const lath = createLath({ key: env.LATH_API_KEY });
        await lath.email.send({ to: "you@example.com", subject: "Hi", text: "From the edge." });
        return new Response("sent");
      },
    };
    ```
  </Step>
</Steps>
