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

# Build with Replit

> Ship a Lumx-powered app from Replit Agent: customer onboarding, on-ramp deposits, and transactions with Replit Secrets and a copy-paste prompt.

Replit Agent builds and runs full-stack apps in a hosted environment. Paste the prompt below to scaffold a Lumx integration — server routes, helper, and a starter UI — with your API key stored as a Replit Secret so it never touches the client.

## Prerequisites

* A [Lumx](https://dashboard.lumx.io) account with a Sandbox API key
* A [Replit](https://replit.com) account with Agent access
* A new or existing Repl that runs a server (Node, Python, Bun, etc.)

## Step 1 — Get your Lumx credentials

From the [Lumx Dashboard](https://dashboard.lumx.io), open **Developers → API Keys** and copy a Sandbox key. See [Authentication](/get-started/authentication). Keys are only shown once.

## Step 2 — Store the key in Replit Secrets

In your Repl, open the **Secrets** tool (lock icon in the left rail) and add:

| Key            | Value                                                   |
| -------------- | ------------------------------------------------------- |
| `LUMX_API_KEY` | Your Sandbox key from Step 1                            |
| `LUMX_ENV`     | `sandbox` while building, `production` when you go live |

Replit Secrets are injected into `process.env` (or `os.environ`) at runtime and never appear in the file tree or the public Repl URL.

<Warning>
  Don't paste your API key into the Agent chat. Add it as a Secret and reference it by name only.
</Warning>

## Step 3 — Paste the prompt

In the Agent chat, paste:

<Info>
  Replit Agent doesn't support MCP servers directly. Once you clone the Repl down locally and open it in Cursor or Claude Code, connect them to Lumx's [docs MCP](/developer/mcp-server) so the agent can pull endpoint shapes and field definitions on demand.
</Info>

```text Lumx integration prompt theme={null}
Build a stablecoin payments app that uses the Lumx API. Lumx
connects local banking rails to stablecoins so I can collect, hold,
convert, and pay out money in either form.

Rules
- Read LUMX_API_KEY from Replit Secrets (process.env on Node, os.environ
  on Python). Never expose it in client-side code — call Lumx from a
  server route only.
- Pick the base URL from LUMX_ENV. Default to
  https://api-sandbox.lumx.io. Use https://api.lumx.io when
  LUMX_ENV === "production".
- Send every request with the headers:
    Authorization: Bearer ${LUMX_API_KEY}
    Content-Type: application/json
- On non-2xx responses, surface the Lumx error body and HTTP status.
  Do not retry 4xx.

Server routes to build
1. POST /api/customers — calls Lumx POST /customers. Body: type
   ("INDIVIDUAL" or "BUSINESS"), name, taxId, country (ISO-3), email.
   Returns the Lumx customer record including verification.link.
2. POST /api/on-ramp — calls Lumx POST /transactions/on-ramp. Body:
   customerId, currency (ISO-3), amount (string). Returns the
   rail-specific deposit instructions.
3. GET /api/transactions/:id — calls Lumx GET /transactions/:id and
   returns the transaction's current status and timeline.

UI to build
- Customer onboarding screen: form that calls POST /api/customers,
  then renders verification.link as a button.
- On-ramp deposit screen: form that picks a customer, sets a
  currency and amount, calls POST /api/on-ramp, then renders the
  returned deposit instructions.

Reference: https://docs.lumx.io
```

## Step 4 — Run the Repl

Agent will write the files, install dependencies, and start the server. Open the webview, create a sandbox customer, open the verification link, and try an on-ramp. Every transaction in Sandbox is simulated — no real money moves.

## Example: a server-side Lumx helper

The prompt aims for this shape. Drop it in directly if you'd rather wire the helper by hand.

```ts server/lumx.ts theme={null}
const LUMX_BASE =
  process.env.LUMX_ENV === "production"
    ? "https://api.lumx.io"
    : "https://api-sandbox.lumx.io";

async function lumx(path: string, init?: RequestInit) {
  const res = await fetch(`${LUMX_BASE}${path}`, {
    ...init,
    headers: {
      Authorization: `Bearer ${process.env.LUMX_API_KEY}`,
      "Content-Type": "application/json",
      ...init?.headers,
    },
  });
  if (!res.ok) {
    throw new Error(`Lumx ${res.status}: ${await res.text()}`);
  }
  return res.json();
}

export const createCustomer = (input: {
  type: "INDIVIDUAL" | "BUSINESS";
  name: string;
  taxId: string;
  country: string;
  email: string;
}) => lumx("/customers", { method: "POST", body: JSON.stringify(input) });

export const createOnRamp = (input: {
  customerId: string;
  currency: string;
  amount: string;
}) =>
  lumx("/transactions/on-ramp", {
    method: "POST",
    body: JSON.stringify(input),
  });

export const getTransaction = (id: string) => lumx(`/transactions/${id}`);
```

## FAQ

<AccordionGroup>
  <Accordion title="Are Replit Secrets visible to forks of my Repl?">
    No. Secrets stay with the Repl owner and are not copied when someone forks. The forker has to add their own. That's also why the prompt asks Agent to read from `process.env`, not from a file in the tree.
  </Accordion>

  <Accordion title="Can I deploy this as a Replit Deployment?">
    Yes. Replit Deployments inherit the Repl's secrets. The same `LUMX_API_KEY` and `LUMX_ENV` apply — flip `LUMX_ENV` to `production` and swap the key when you're ready.
  </Accordion>

  <Accordion title="How do I switch from Sandbox to Production?">
    Update the two Secrets — set `LUMX_ENV=production` and replace `LUMX_API_KEY` with a Production key. Production access requires a call with the Lumx team — see [Environments](/get-started/environments).
  </Accordion>

  <Accordion title="Agent wants to print the key in a log to debug. Should I let it?">
    No. Logs in Replit can be shared with viewers of the Repl. Ask Agent to redact the key and only log the response status and request path.
  </Accordion>
</AccordionGroup>

## Next steps

* [Create a customer](/guides/create-a-customer) — full reference for the customer payload
* [Webhooks](/developer/webhooks) — subscribe to status changes instead of polling
* [Use cases](/guides/use-cases/global-accounts) — patterns for global accounts, payroll, treasury, and more
