# Lookalyke documentation ## Get started - [Run Lookalyke locally](https://lookalyke.dev/docs/quickstart/) and make a real HTTP request to the Stripe emulator. - [Connect an app](https://lookalyke.dev/docs/connect-an-app/) with a local base URL, a sandbox key, and the correct SDK settings. - [Check service coverage](https://lookalyke.dev/docs/services/) before you rely on a specific operation in a test. ## Test your app - [Send webhooks and simulate failures](https://lookalyke.dev/docs/webhooks-and-failures/) to check how your app handles declined payments, retries, and slow services. - [Set up sandboxes and CI](https://lookalyke.dev/docs/sandboxes-and-ci/) so each test run starts with its own state. - [Use the CLI](https://lookalyke.dev/docs/cli/) to inspect activity and run the same test scenario from a script. ## Run Lookalyke - [Choose local storage, Docker, or Railway](https://lookalyke.dev/docs/hosting/) for the way your team works. - [Troubleshoot connections](https://lookalyke.dev/docs/troubleshooting/) when requests, keys, or webhook deliveries fail. ## Common questions ### Do I need accounts with the services I’m testing? A Lookalyke sandbox generates its own keys. You can call the emulators without opening a Stripe, Twilio, or OpenAI account. Use the real service’s test environment before shipping an integration that depends on it. ### Where does the data live? The computer or server running Lookalyke stores its state and Activity log. The default local setup uses SQLite in `.lookalyke/`. Use `--memory` for runs that should leave no SQLite data behind. ### Where can I report a gap? Open the service’s **How it behaves** tab to check its supported operations. If the behavior differs from what the docs describe, [open an issue on GitHub](https://github.com/jviars/lookalyke/issues) with the service, endpoint, and a small example using synthetic data. --- # Run Lookalyke locally You’ll start a temporary Lookalyke sandbox, create a Stripe customer over HTTP, and find the same request in the dashboard. You’ll need Git, Node.js 22.14 or later, and pnpm 12. ## Start the demo Run these commands in a terminal. If you already cloned Lookalyke, start inside that checkout and skip the first two lines. ```sh git clone https://github.com/jviars/lookalyke.git cd lookalyke pnpm install --frozen-lockfile pnpm build node packages/server/dist/cli.js --memory --demo ``` Leave that terminal running. Open [127.0.0.1:4100](http://127.0.0.1:4100/) to see **Activity** populated with synthetic requests. The demo includes sample customers, invoices, and webhook attempts. ![Lookalyke Activity showing API calls, failed webhooks, and actions for triggering test events.](https://lookalyke.dev/images/lookalyke-dashboard.png) ## Make your first request Open a second terminal in the checkout. Get the current Lookalyke sandbox key, then use curl to create a Stripe customer. ```sh key=$(node packages/server/dist/cli.js keys --json | node -p 'JSON.parse(require("node:fs").readFileSync(0, "utf8")).secretKey') curl --fail-with-body -u "$key:" \ --data-urlencode "name=Demo Customer" \ --data-urlencode "email=demo@example.com" \ http://127.0.0.1:4100/stripe/v1/customers ``` The response contains a customer ID beginning with `cus_`. In **Activity**, open the new Stripe request to inspect what you sent and what Lookalyke returned. Under **Stripe → Saved data**, you can find the customer you just made. ## Move from the demo to your own tests Press **Ctrl+C** in the first terminal to stop the demo. Start a sandbox with persistent data using the built CLI. ```sh node packages/server/dist/cli.js ``` The first run creates `.lookalyke/` in the current directory. Future runs reuse its contents. For a quick health check, run `curl -fsS http://127.0.0.1:4100/_lookalyke/health`. A healthy server returns JSON with `"ok": true` and its version. [Connect your app](https://lookalyke.dev/docs/connect-an-app/) or learn how to [send your first webhook](https://lookalyke.dev/docs/webhooks-and-failures/). --- # Connect an app For each service you want to test, change the API address and credentials in your development configuration. Lookalyke gives each service a path on a single server, such as `http://127.0.0.1:4100/resend`. ## Get the connection settings 1. Start [Lookalyke locally](https://lookalyke.dev/docs/quickstart/). 2. In the dashboard, open the service and choose **Connect**. If you don’t see the service, turn it on from **Apps**. 3. Copy the base address and sandbox credentials. Store them in your app’s development or test configuration, such as `.env.development`. 4. Set the base URL on the SDK client and restart your app. Check **Activity** for the first request. From the product checkout, you can also print the settings in your terminal. ```sh node packages/server/dist/cli.js env resend node packages/server/dist/cli.js env --all ``` Keep sandbox keys and webhook signing secrets specific to their sandbox. Keep Lookalyke settings out of production and use synthetic data in your tests. ## Example with the OpenAI JavaScript SDK With OpenAI enabled in the sandbox, copy its API key and configure the client in your app. ```js import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, baseURL: process.env.OPENAI_BASE_URL, }); ``` Set `OPENAI_BASE_URL=http://127.0.0.1:4100/openai/v1` and set `OPENAI_API_KEY` to the sandbox key shown in **Connect**. Make a request from your app and look for it under **Activity**. Keep production credentials and URLs in separate configuration. ## Other SDKs | Service | Local URL | What to configure | | --- | --- | --- | | Anthropic | `http://127.0.0.1:4100/anthropic` | Set `baseURL` and the sandbox API key. | | Resend | `http://127.0.0.1:4100/resend` | Set `baseUrl` in the SDK options and use the sandbox API key. | | Quo | `http://127.0.0.1:4100/quo` | Send the sandbox key in `Authorization` without a `Bearer` prefix. | | Stripe | `http://127.0.0.1:4100/stripe` | The Node SDK needs a small HTTP adapter to keep the `/stripe` path. | | Twilio | `http://127.0.0.1:4100/twilio` | The Node SDK needs a custom HTTP client plus the account SID and auth token shown in **Connect**. | The [SDK connection guide in the product repository](https://github.com/jviars/lookalyke/blob/main/docs/connecting-an-app.md) has complete Stripe and Twilio Node examples and additional service settings. ## Verify the connection Run the sample request shown in **Connect**. If that works but the app’s request is missing from **Activity**, check which client instance your app uses, the base URL including its service path, and whether the app reloaded its environment. If the request appears but is refused, check the sandbox key and whether the service is enabled. [Set a webhook destination](https://lookalyke.dev/docs/webhooks-and-failures/) if your application expects callbacks from the service. --- # Supported services Every service shares the address of your Lookalyke instance. The default local address is `http://127.0.0.1:4100`. Add the service path from the table or copy the full URL from **Connect**. ## Built-in services | Area | Service | Path | | --- | --- | --- | | Payments | Stripe | `/stripe` | | Payments | Square | `/square` | | Payments | PayPal | `/paypal` | | Messaging and voice | Twilio | `/twilio` | | Messaging and voice | Quo | `/quo` | | Email | Resend | `/resend` | | Email | Mailgun | `/mailgun` | | AI | OpenAI | `/openai` | | AI | Anthropic | `/anthropic` | | AI | fal | `/fal` | | Google | Sign-in, Calendar, Drive, Gmail, Gemini, Maps | `/google` | | Sign-in | GitHub | `/github` | | Sign-in | Clerk | `/clerk` | | Infrastructure | Cloudflare | `/cloudflare` | | Infrastructure | Vercel | `/vercel` | | Accounting | QuickBooks Online | `/quickbooks` | | Accounting | Zoho Books | `/zoho` | | Social | Meta Graph API | `/meta` | | Print and mail | Lob | `/lob` | | Suppliers | ABC Supply | `/abc-supply` | | Work tools | Linear | `/linear` | These are service prefixes. Your SDK may need a full API path, such as `/openai/v1` or `/cloudflare/client/v4`. Get the example for your service in [Connect an app](https://lookalyke.dev/docs/connect-an-app/). ## Check a service before using it in a test Open the service in the dashboard and choose **How it behaves** for supported operations and known differences. Each emulator covers a subset of its vendor’s API. For example, you can create a Stripe customer and pay an invoice locally. Use the real service’s test environment to check provider-specific details before shipping. The [API conformance report](https://github.com/jviars/lookalyke/blob/main/docs/conformance.md) explains which responses and webhook payloads are compared with published references and lists open coverage gaps. To add a service yourself, see [Writing an app](https://github.com/jviars/lookalyke/blob/main/docs/writing-an-app.md). --- # Send webhooks and simulate failures Use Lookalyke to send a signed event to your app on demand. Webhooks run from the Lookalyke server to your app’s handler. ## Send a Stripe webhook 1. Start the [demo sandbox](https://lookalyke.dev/docs/quickstart/#start-the-demo) so Stripe has sample invoices. Run your app’s webhook handler locally, for example at `http://127.0.0.1:8787/api/webhooks/stripe`. 2. Open **Stripe → Connect** or use **Setup** to set that destination. Set your app’s development `STRIPE_WEBHOOK_SECRET` to the sandbox secret shown there. Keep signature verification on and verify the raw request body. 3. In **Activity**, use **Make something happen → A card payment goes through**. You can also trigger that payment from the checkout. ```sh node packages/server/dist/cli.js trigger stripe payment.succeeded ``` Open the delivery in **Activity**. Check the event type, destination, and your handler’s response. A successful payment can emit multiple events. A handler that only processes one type should still acknowledge events it recognizes but does not act on. ## Test a failure Use **Break things** to slow an API response, return an error, or drop a connection. For example, make Stripe return HTTP 429 and verify that your app responds the way you expect. ```sh node packages/server/dist/cli.js break stripe errors 429 ``` Set Stripe back to normal when the test ends. ```sh node packages/server/dist/cli.js break stripe normal ``` To test the business case where a card is declined, use **A card is declined** in **Make something happen** or run `node packages/server/dist/cli.js trigger stripe payment.declined`. That is a payment outcome your app should handle differently from an unavailable service. ## Inspect and retry a delivery Lookalyke records failed attempts in **Activity**. Open the event to see whether your handler returned an error, Lookalyke could not reach it, or the destination was refused. The default retry schedule is 1 minute, 5 minutes, 30 minutes, and 2 hours. Use **Send again** when you want to try immediately after fixing the handler. A loopback Lookalyke instance can send webhooks to a handler on the same machine. For Docker or Railway, `localhost` means the container. Use the address reachable from Lookalyke and add it to the allowed webhook hosts. [See the hosting guide](https://lookalyke.dev/docs/hosting/). --- # Use sandboxes and run tests in CI Each sandbox has its own keys, service data, and webhook destinations. Use separate sandboxes when several developers or branches share a running instance. Use `--memory` or an in-memory library instance when each test run should start clean. ## Create a sandbox for a branch Use the sandbox menu in the dashboard, or create it with the CLI from a Lookalyke checkout. ```sh node packages/server/dist/cli.js sandbox new feature-x node packages/server/dist/cli.js env stripe --sandbox feature-x ``` Apply the new sandbox’s key and webhook settings to the branch’s development configuration. Before resetting a shared sandbox, check which sandbox is selected. A reset returns its data to its starting state. ## Run an isolated integration test After building Lookalyke, save this as `stripe-smoke.test.mjs` at the root of the **product checkout**. The test starts its own server on a free port, checks a real HTTP response, and stops the server even if the assertion fails. ```js import assert from "node:assert/strict"; import test from "node:test"; import { start } from "./packages/server/dist/index.js"; test("Stripe customers can be listed", async () => { const lk = await start({ memory: true, port: 0, apps: ["stripe"], quiet: true, }); try { const response = await fetch(`${lk.url}/stripe/v1/customers`, { headers: { Authorization: `Bearer ${lk.sandbox.secretKey}` }, }); assert.equal(response.status, 200); assert.equal((await response.json()).object, "list"); } finally { await lk.stop(); } }); ``` Run `node --test stripe-smoke.test.mjs`. To import the same `start` function from `lookalyke` in your own project, [build a package tarball from the product checkout](https://github.com/jviars/lookalyke/blob/main/docs/releasing.md#build-and-verify) and install it in that project. ## Run an existing test suite against the CLI Start the built CLI with `--memory --apps stripe` and choose a free port if multiple jobs share a machine. Wait for `/_lookalyke/health` to return `"ok": true`, then pass the instance URL and sandbox credentials to your test process. Stop the CLI in the job’s cleanup step. If you choose a port other than 4100, pass its URL to CLI commands that talk to the running instance. --- # CLI reference The commands below use the CLI built in a [Lookalyke source checkout](https://lookalyke.dev/docs/quickstart/). Start the server in one terminal, then run commands from a second terminal in the same checkout. ## Inspect a running server ```sh node packages/server/dist/cli.js status node packages/server/dist/cli.js apps node packages/server/dist/cli.js env stripe node packages/server/dist/cli.js activity --limit 20 --app stripe ``` Use `--json` on commands that print data when a script needs to parse the result. For example, `keys --json` prints the current sandbox credentials. Keep keys out of shared logs and CI output. ## Trigger a scenario ```sh node packages/server/dist/cli.js trigger stripe node packages/server/dist/cli.js trigger stripe payment.succeeded node packages/server/dist/cli.js break stripe slow 3s node packages/server/dist/cli.js break stripe normal ``` `trigger stripe` lists available Stripe triggers. For a specific invoice, pass `--invoice` with its ID. Use [a seeded sandbox](https://lookalyke.dev/docs/quickstart/#start-the-demo) or make an open invoice before triggering a Stripe payment. ## Common flags | Flag | Applies when | Behavior | | --- | --- | --- | | `--port 4101` | Starting a server | Listen on that port. Use `0` to choose a free port. | | `--memory` | Starting a server | Keep data in memory for this run. | | `--demo` | Starting a server | Load sample data and demo Activity. | | `--apps stripe,resend` | Starting a server | Enable just those apps in the main sandbox. | | `--url http://127.0.0.1:4101` | Talking to a running server | Target an instance other than the default at port 4100. | | `--sandbox feature-x` | Talking to a running server | Use the named sandbox. | For all options, run `node packages/server/dist/cli.js help` or see the [full running guide](https://github.com/jviars/lookalyke/blob/main/docs/running.md). --- # Run on your laptop, Docker, or Railway Run Lookalyke on your laptop for everyday development. Docker gives a team or CI job a consistent image. Railway gives a team one shared address for its test instance. Keep this instance separate from production and use synthetic data. ## Run from a checkout [Install and build the source](https://lookalyke.dev/docs/quickstart/#start-the-demo), then run the CLI without demo flags. ```sh node packages/server/dist/cli.js ``` The server listens on `127.0.0.1:4100` and keeps SQLite data in `.lookalyke/`. To back it up, stop the server and copy that directory. Use `--memory` for an ephemeral run. ## Run in Docker Build and run the image from the Lookalyke product checkout. ```sh docker build -t lookalyke . docker run -p 127.0.0.1:4100:4100 -v lookalyke:/data lookalyke ``` Open [127.0.0.1:4100](http://127.0.0.1:4100/) and create the owner account. The image listens on a non-loopback address inside the container and turns on sign-in. The named volume keeps the database and admin token between container runs. For a webhook handler on the host using Docker Desktop, use `host.docker.internal` in the destination. Set `LOOKALYKE_ALLOWED_WEBHOOK_HOSTS=host.docker.internal:8787` if the handler is on port 8787. On Linux, Docker may also need `--add-host=host.docker.internal:host-gateway` when you start the container. ## Deploy on Railway 1. Create a Railway service in a dedicated development project from [the Lookalyke GitHub repository](https://github.com/jviars/lookalyke). Railway uses its Dockerfile and existing health-check configuration. 2. Mount a persistent volume at `/data`, then generate a public service domain. 3. Set `LOOKALYKE_PUBLIC_URL=https://${{RAILWAY_PUBLIC_DOMAIN}}` in the Railway service variables. For outbound test webhooks, add specific destinations to `LOOKALYKE_ALLOWED_WEBHOOK_HOSTS`. 4. Deploy and open the address right away. The first visit creates the owner account. Use **Setup** or the service’s **Connect** tab to get development credentials. A Railway instance cannot reach a webhook handler bound only to your laptop’s loopback interface. For local handlers, run Lookalyke on the same machine or use an address reachable from the deployed instance. See the [Railway guide in the product repository](https://github.com/jviars/lookalyke/blob/main/docs/railway.md) for private networking and CLI authentication. --- # Troubleshoot requests and webhooks Start with `curl -fsS http://127.0.0.1:4100/_lookalyke/health` or run the same check on your instance URL. A running server returns `"ok": true` and its version. ## Lookalyke will not start on port 4100 Another process may already have that port. Check whether Lookalyke is running with `node packages/server/dist/cli.js status`. To start a separate copy, use `--port 4101`, then use that port in your dashboard URL, SDK settings, and CLI `--url` flags. ## No requests appear in Activity Run the service’s sample request from **Connect**. If it appears, the emulator is working. Check that your app loaded the development environment and configured the SDK’s base URL, including the service path. Some SDKs need an adapter to preserve the path. See [Connect an app](https://lookalyke.dev/docs/connect-an-app/). ## An API request is refused or unauthorized Read the Activity entry. It may name a disabled service or a key the sandbox does not recognize. Enable the service in **Apps** and copy the key from **Connect** with the intended sandbox selected. For a CLI command against a shared instance, use the instance’s admin token if it asks you to sign in. ## The dashboard returns HTTP 421 The host you used must match the instance configuration. Set `LOOKALYKE_PUBLIC_URL` to the address your team actually uses. If the instance is behind a proxy, make sure it receives the expected host name. See [Hosting](https://lookalyke.dev/docs/hosting/). ## A webhook was never delivered or failed Open the event or delivery attempt in **Activity** and check the destination, status, and error message. Check reachability from the machine or container running Lookalyke. For a shared instance, check the allowed webhook hosts. If the handler rejects the signature, use the sandbox’s per-service webhook secret and verify the raw body. After fixing the issue, choose **Send again** on the delivery. ## Get help [Open a GitHub issue](https://github.com/jviars/lookalyke/issues) with your Lookalyke version, the service, the route, and the status or error. Include a minimal request using synthetic data. Remove keys, tokens, and customer records before sharing it.