
# Docs for AI agents

Every page of these docs is written for people and for coding agents alike. Agents get the same
content as plain Markdown, without navigation or styling.

| URL | What it is |
|---|---|
| [`/llms.txt`](https://kerdly.com/llms.txt) | An index of every docs page with a one-line summary, in the [llms.txt](https://llmstxt.org) format. Start here. |
| [`/llms-full.txt`](https://kerdly.com/llms-full.txt) | Every docs page in one Markdown file, for agents that prefer to read everything at once. |
| `/docs/<page>.md` | Any single page as Markdown: add `.md` to its address, for example [`/docs/sdks/web.md`](https://kerdly.com/docs/sdks/web.md). |

Each page also has a **Copy as Markdown** button, so you can paste it into a chat.

## Hand the integration to your agent

Copy one of these prompts into Claude Code, Codex or another coding agent, from the root of your
repository. Replace the keys first, or tell the agent where your environment variables live. Each
app's **Settings → SDK** has the same prompt with its key filled in (**Copy prompt for your
agent**). An agent connected to Kerdly gets it from `kerdly_get_install_instructions`, so it doesn't
need you to copy anything (see [below](#set-up-kerdly-with-your-agent)).

Each prompt points at an SDK page. Add the guide for how you sell, so the agent knows which events
come from the client, which from your server, and how they are deduplicated:

| You sell | Add to the prompt |
|---|---|
| On your website (Stripe, Paddle) | `https://kerdly.com/docs/guides/web-checkout.md` |
| In the app, through the App Store and Google Play | `https://kerdly.com/docs/guides/store-app.md` |
| In the app, with web payments (Stripe, RevenueCat Web Billing) | `https://kerdly.com/docs/guides/app-web-payments.md` |
| A landing page that sends people to the app | `https://kerdly.com/docs/guides/web-to-app.md` |

Every guide ends with a checklist the agent can work through.

### Web or landing page

```text
Add the Kerdly web SDK to this site. Read https://kerdly.com/docs/sdks/web.md,
https://kerdly.com/docs/guides/web-checkout.md and
https://kerdly.com/docs/guides/events-and-dedupe.md first and follow them.
- Web key: wk_live_REPLACE_ME (public; it may go in client code).
- Use the npm package if the site has a build step, otherwise the kerdly.js snippet.
- Record a visit on every route change if this is a single-page app.
- Mark every link to the App Store or Google Play with data-kerdly-link.
- If the site has sign-in, call kerdly.identify(userId) with the same user id the server uses.
- If the site sells through Paddle or Stripe and Kerdly reads it (the Web app's Settings ›
  Connections), put that user id on every checkout: Paddle's custom data or Stripe's metadata,
  under the User id field shown there (kerdly_user_id unless changed). Guest checkouts also pass
  kerdly_visitor_id from kerdly.visitorId(). Don't send those charges from the server as well.
- Otherwise, if the server takes payments, send each trial, first charge, renewal, purchase and
  refund to POST https://app.kerdly.com/api/v1/s2s/events (the mapping is in web-checkout.md), with the server key
  from the KERDLY_SERVER_KEY environment variable. Never put the server key in client code.
When done, list the files you changed and how to check it works.
```

### Expo or React Native app

```text
Add the Kerdly Expo SDK to this app. Read https://kerdly.com/docs/sdks/expo.md,
https://kerdly.com/docs/guides/store-app.md and
https://kerdly.com/docs/guides/events-and-dedupe.md first and follow them.
- iOS app key: pk_live_REPLACE_ME_IOS. Android app key: pk_live_REPLACE_ME_ANDROID.
  Put them in EXPO_PUBLIC_KERDLY_IOS_KEY and EXPO_PUBLIC_KERDLY_ANDROID_KEY and pick one with
  Platform.select.
- Add the @kerdly/expo config plugin to the app config.
- Call Kerdly.configure once at module scope of the root layout.
- Call Kerdly.setUserId after sign-in and with null on sign-out.
- Send trackRegistration on sign-up, and trackStartTrial, trackSubscribe or trackPurchase from the
  purchase flow, with productId, value, currency and transactionId.
- Link store purchases with setAppAccountToken and notifyPurchase as the docs show.
Don't remove existing analytics or attribution SDKs. When done, list the files you changed, and
remind me that the app needs a new development build (Expo Go doesn't run the SDK).
```

### Native iOS app

```text
Add the Kerdly iOS SDK to this app. Read https://kerdly.com/docs/sdks/ios.md,
https://kerdly.com/docs/guides/store-app.md and
https://kerdly.com/docs/guides/events-and-dedupe.md first and follow them.
- iOS app key: pk_live_REPLACE_ME (public; it may go in the app).
- Add KerdlySDK with Swift Package Manager, up to the next minor version from 0.1.0.
- Call Kerdly.configure once at launch (the App initializer or didFinishLaunching).
- Call Kerdly.setUserId after sign-in and with nil on sign-out.
- Send trackRegistration on sign-up, and trackStartTrial, trackSubscribe or trackPurchase from the
  purchase flow, with productId, value, currency and transactionId.
- Link App Store purchases with setAppAccountToken and notifyPurchase as the docs show.
- Pass every URL the app opens with to Kerdly.handleUrl.
Don't remove existing analytics or attribution SDKs. When done, list the files you changed.
```

### Native Android app

```text
Add the Kerdly Android SDK to this app. Read https://kerdly.com/docs/sdks/android.md,
https://kerdly.com/docs/guides/store-app.md and
https://kerdly.com/docs/guides/events-and-dedupe.md first and follow them.
- Android app key: pk_live_REPLACE_ME (public; it may go in the app).
- Add com.kerdly:kerdly-sdk:0.1.0 to the app module's dependencies.
- Call Kerdly.configure once in Application.onCreate; add metaAppId if the app runs Meta ads.
- Call Kerdly.setUserId after sign-in and with null on sign-out.
- Send trackRegistration on sign-up, and trackStartTrial, trackSubscribe or trackPurchase from the
  purchase flow, with productId, value, currency and transactionId.
- Link Google Play purchases with setAppAccountToken and notifyPurchase as the docs show.
- Pass every URL the app opens with to Kerdly.handleUrl, in onCreate and onNewIntent.
Don't remove existing analytics or attribution SDKs. When done, list the files you changed.
```

## Rules for agents

These hold for every integration. They are repeated on the SDK pages.

- **Keys**: `pk_` (apps) and `wk_` (web pages) are public and may be committed to client code.
  `sk_` keys are secret: server-side only, read from an environment variable, never logged.
- **One key per platform**: an Expo app has two app keys, one for iOS and one for Android.
- **Endpoint**: `https://app.kerdly.com/api`. Leave the SDK default unless told otherwise.
- **Configure once**, as early as possible, outside UI components.
- **Event names** and prop keys match `^[a-z][a-z0-9_]{0,39}$`. Money is `value` plus a three-letter
  `currency`.
- **Nothing throws.** Don't wrap SDK calls in `try`/`catch` or add retries; the SDK queues and
  retries on its own.
- **The funnel**: click and visit (web SDK), identify (`identify` / `setUserId`), install (app SDK),
  trial / subscribe / purchase (app SDK, or server events on the web), renewal / cancel / refund
  (the stores in apps; server events on the web). Same user id everywhere.
- **One sender per event.** A store charge comes from the store; a web charge from Paddle or Stripe
  (when connected), RevenueCat or your server, never two of them. Reuse the charge's id as
  `event_id`, so retries are dropped as duplicates.
- **Name the buyer on web checkouts.** With Paddle or Stripe connected, every checkout carries the
  same user id the site passes to `identify`, under the Web app's **User id field**. Without it a
  charge counts but isn't credited to any ad.
- **Never invent API calls.** If a page doesn't document a function, it doesn't exist.
- **Expo Go doesn't run the native SDK.** Verify on a development build.

## Set up Kerdly with your agent

Connect your assistant to the [Kerdly MCP server](https://kerdly.com/docs/guides/connect-ai-assistant.md) and it can do
the dashboard side of onboarding too: create the project and its apps, fetch each app's key and
install prompt, connect revenue, and check the Onboarding steps, all from the same chat where it
edits your code. Tick **project**, **SDK**, **settings** and **connections** when you connect, so it
may make those changes.

Everything it creates is real: your project, apps and keys, in your organization. A good agent
says what it is about to create and waits for your yes; ask yours to.

### The order an agent follows

1. **`kerdly_whoami`**: the organization, its projects and your role. If the product already has a
   project, use it instead of making another.
2. **`kerdly_create_project`** with the product's name. A project is one product and holds at most
   one app per platform.
3. **The website**, if there is one: `kerdly_update_project` with `web`, its name and `https`
   addresses. The project's web key (`wk_live_…`) belongs to the project.
4. **`kerdly_create_app`** once per platform: `ios` (with the App Store ID), `android` (with the
   package name), `web`. Each app's install key is made with it.
5. **`kerdly_get_install_instructions`** for each app: the key, the snippet and the prompt above with
   the key filled in. The agent then follows that prompt in your code.
6. **Revenue**:
   - iOS: `kerdly_set_app_store_credentials` with an App Store Connect API key
     ([Connect App Store Connect](https://kerdly.com/docs/get-started/app-store.md)).
   - Android: you invite the project's service account in Play Console from the app's
     **Onboarding** page ([Connect Google Play](https://kerdly.com/docs/get-started/google-play.md)).
   - A website on Paddle or Stripe: `kerdly_set_revenue_source_credentials` with
     `PADDLE_USER_ID_FIELD` (or `STRIPE_USER_ID_FIELD`) first, then the read-only API key, which
     loads the history. The field is wherever your checkout already puts your user id, for example
     `orgId`; `kerdly_user_id` if you add one.
   - What a website sells: `kerdly_update_app_settings` with `MONETIZATION` set to
     `subscriptions`, `purchases` or `both`. A website counts purchases unless told otherwise;
     **subscriptions** or **both** turn on its Retention page and the Dashboard's expected return.
7. **Ad networks**: `kerdly_start_oauth_connection` for Meta or TikTok returns a link you open to
   sign in; then `kerdly_discover_ad_accounts` and `kerdly_attach_ad_account`.
8. **`kerdly_get_onboarding_status`** for each app: every step's status, what it waits on, and
   `next`, the step to do now, with links to the dashboard pages.

### A prompt for the whole setup

Connect your agent first: in Claude Code,
`claude mcp add --transport http kerdly https://app.kerdly.com/api/mcp`; in Claude, ChatGPT or
Cursor, add `https://app.kerdly.com/api/mcp` as a custom connector
([how](https://kerdly.com/docs/guides/connect-ai-assistant.md)). Then paste this from your product's repository. The
dashboard shows the same prompt on the **Add your product** step of sign-up.

```text
Set up Kerdly for this product with the Kerdly MCP server, then add the Kerdly SDK to this
repository. Read https://kerdly.com/docs/agents.md first and follow it.
- From this repository, find the product's name, where it runs (iOS App Store ID, Android package
  name, website address) and how it takes payments (App Store, Google Play, Paddle, Stripe,
  RevenueCat or our own server). Ask me for anything you can't find.
- Call kerdly_whoami first, and reuse a project if one already exists for this product.
- Before you create a project or app, or save a key, tell me what you will do and wait for my yes.
- Create the project, its website and one app per platform. Then, for each app, follow the prompt
  from kerdly_get_install_instructions in this repository.
- If the site sells through Paddle or Stripe, find where the checkout already puts our user id
  (custom data or metadata) and set that field as the User id field before you connect the
  provider's read-only API key.
- When done, show kerdly_get_onboarding_status for each app and tell me which steps are left for me.
```

**Kept for you:** Google Play's invite, signing in to Meta and TikTok, plans and payment, and
deleting a project happen in the dashboard, with you there.

---

Source: https://kerdly.com/docs/agents. Index of all docs: https://kerdly.com/llms.txt
