---
name: cowliss
description: Add Cowliss to an app and work in a Cowliss project. Use when the user wants to track users and events, send transactional email, or write, test and ship segments and automations with the cow CLI, the @cowliss/sdk client or the Cowliss MCP server.
---

# Cowliss

Cowliss is a dev-facing customer data platform: send identify and track from your apps, compute segments on write, and run durable per-user automations, written as JSON definitions, that send email and webhooks.

## Read before you write

The docs are published for agents. Fetch these instead of guessing:

- https://docs.cowliss.com/llms.txt: the site map, every page with a summary and a markdown link.
- https://docs.cowliss.com/sdk/index.md: the SDK client, its options and error handling.
- https://docs.cowliss.com/automations/index.md: triggers, the seven step types, rules and full examples.
- https://docs.cowliss.com/schemas/automation.json: the JSON Schema an automation definition must pass.
- https://docs.cowliss.com/openapi.json: every API route, for calling the API directly.

Any docs page is markdown when you append `index.md` to its URL.

## Add Cowliss to an app

1. Install `@cowliss/sdk` and create one `Cow` client, reading the API key from
   `COW_KEY` and the source id from `COW_SOURCE_ID`, with an `onError` that logs.
2. Call `cow.identify` when a user signs up or signs in, with their `userId` as the
   identifier and their email as a trait:

   ```ts
   // Not awaited on a request path: the client's onError reports a failure.
   cow.identify({
     identifiers: { userId: user.id },
     traits: { email: user.email },
   });
   ```

3. Call `cow.track` for the events this app already records (sign-up, purchase,
   and the like). Keep the event names this app already uses.
4. Send transactional email (receipts, password resets) with `cow.emails.send`
   instead of the current mail provider, from an address on the organization's
   verified domain.

Do not await tracking calls on the request path.

An app already on the Resend SDK can switch with two variables and no code change:
`RESEND_BASE_URL=https://api.cowliss.com/resend/<appId>` and
`RESEND_API_KEY=<the Cowliss API key>`.

## Work in a Cowliss project

Automations, email templates and segments live as files in `.cowliss/` in the
repo, written by `npx cow init`. `cow.json` there names the organization and the
one app the repo pushes to.

```sh
npx cow login        # browser sign-in, once
npx cow init         # writes .cowliss/ with cow.json and an example
npx cow add blueprint <name>  # copy a whole program (ecommerce, saas-trial, mobile-game) into the project
npx cow test         # run every scenario on a virtual clock, nothing sent
npx cow plan         # show what a push would change, and any conflicts
npx cow push         # file a new version of whatever changed
npx cow enable <key> # turn an automation on; a pushed automation starts off
```

Every command prints JSON and exits non-zero on an error. `npx cow --help` and
`npx cow <command> --help` list the rest.

## MCP

The hosted server is `https://api.cowliss.com/mcp` (OAuth sign-in, the everyday
tools). `npx -y @cowliss/cli mcp` runs every tool locally over stdio, signed in
through `cow login`. Tool names are the API's operation ids with underscores.

## Upgrading

Follow "Upgrading" at the top of https://docs.cowliss.com/changelog/index.md.

## Rules

- Run `cow test` before every `cow push`. Write a scenario for each automation
  you add, under `scenarios/<automation>.<case>.json`; a failing scenario means
  do not push.
- Run `cow plan` before a push into an app whose resources may have been edited in
  the dashboard. A conflict there means someone changed it outside the repo:
  show it to the user, offer `cow pull`, and push with `--force` only when they
  say so.
- Never send marketing mail without a purpose and consent. Name the purpose on the
  template (the push declares it; `cow.json` `purposes` only relabels it), and record consent on
  `identify` (`consent: { "<purpose key>": true }`) only when the person said yes.
- Identify people by the app's own user id as `userId`, and put the email in
  `traits`.
- `from` must be an address on a verified sending domain. Verification waits on
  DNS; `cow test` works meanwhile.
- Never invent ids. Read `appId` and `sourceId` with `npx cow apps list` and
  `npx cow apps sources list <appId>`.
