# Venon agent guide

> How to connect an AI agent to Venon's MCP server, find the tools a credential may use, stay within limits and reproduce dashboard numbers. Every endpoint, parameter and response field is in the [full reference](https://developerdocs.venon.io/llms-full.txt).

## Start here

- Order profit: use list_orders (GET /v1/orders) to find numeric Shopify IDs, then get_order_cost_breakdown (GET /v1/orders/{id}) for line costs and CM1/CM2, or list_order_cost_breakdowns (GET /v1/orders/cost-breakdowns) for a keyset export. These are order costs, not attributed channel profit.
- Channel-credited order identities: use get_attributed_orders (GET /v1/attribution/orders), keeping attribution_model and attribution_window fixed. Returned amounts are full gross order totals, not fractional attributed revenue; use channel performance for credited totals.
- Period shop profit: use get_profit_loss (GET /v1/analytics/profit-loss) for the period statement; get_analytics_summary for headline metrics and get_metrics_timeseries for trends. Summing order rows does not reconstruct the period statement. Do not sum statement subtotals.
- SKU lookup: use lookup_products (GET /v1/products/catalog) with exact sku for catalog identity independent of sales. For sales by SKU, get_product_performance (GET /v1/products) needs level=variant and a date window. A SKU can match several variants. Check search_truncated on fuzzy q searches.
- Saved-filter comparisons: consult the support matrix below. On supported reports, keep filter_mode and filter_ids, dates and attribution settings identical. Read effective data_filters and warnings before comparing. Unsupported reports do not become filtered by sending these parameters. Discover tools/list first; only granted tools may be called.

## Which report answers which question?

| Question                              | Report/tool                                | Meaning and reconciliation limit                                                                                                            |
| ------------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| Headline shop revenue/profit?         | summary / get_analytics_summary            | Shop totals; displayed refunds follow refund date, stored profit follows order date.                                                        |
| Period costs and contribution margin? | profit-loss / get_profit_loss              | P&L Returns follows order date; this statement ends at CM3, before custom expenses. Operating profit is not returned. Do not sum subtotals. |
| Which channel or ad gets credit?      | channels / get_channel_performance         | Weighted orders/gross revenue; model, spend scope and all_clicks can prevent reconciliation with summary.                                   |
| Which exact orders were matched?      | attribution/orders / get_attributed_orders | Distinct identities with full order totals, not fractional credited amounts.                                                                |

## Saved-filter support matrix

| MCP tool                        | REST endpoint                 | filter_mode / filter_ids |
| ------------------------------- | ----------------------------- | ------------------------ |
| get_channel_performance         | GET /v1/analytics/channels    | Yes                      |
| get_campaign_performance        | GET /v1/analytics/campaigns   | Yes                      |
| get_ad_set_performance          | GET /v1/analytics/ad-sets     | Yes                      |
| get_ad_performance              | GET /v1/analytics/ads         | Yes                      |
| get_analytics_summary           | GET /v1/analytics/summary     | Yes                      |
| get_metrics_timeseries          | GET /v1/analytics/timeseries  | Yes                      |
| get_attributed_orders           | GET /v1/attribution/orders    | Yes                      |
| get_attributed_products         | GET /v1/attribution/products  | Yes                      |
| get_non_ad_campaign_performance | GET /v1/attribution/campaigns | Yes                      |

No saved-filter selection: list_orders, get_order_cost_breakdown, list_order_cost_breakdowns (GET /v1/orders and its breakdown routes); get_product_performance and lookup_products (GET /v1/products and /v1/products/catalog); get_profit_loss, get_cohorts, get_retention and get_product_relationships (their /v1/analytics routes). Their other named filters are separate features. Do not assume unsupported reports reproduce a filtered dashboard comparison.

## Field semantics

- Gross revenue is Shopify total_price after discounts; includes VAT and customer-paid shipping, before refunds or costs. Shop reports declare shop currency. Ingestion attempts shop-money normalization; unresolved currency conversion can leave recorded amounts unconverted, so the currency label is not proof of complete conversion.
- Summary/timeseries refunds are issued in the window by refund date, including refunds of older orders. Stored net revenue, contribution margins and P&L Returns use refunds of orders selected by order date. Do not subtract displayed summary refunds again from stored net revenue or profit.
- tax is the raw order tax total even for VAT-ignoring shops. The current ignore_vat setting controls effective deducted tax, not raw tax; null settings are treated as false by calculations. Current settings do not certify stored economics were recomputed.
- shipping_fees is merchant shipping cost resolved from shipping profiles, not customer-paid shipping revenue. Zero can mean unresolved, free or zero-priced shipping; partial resolution can retain positive fees from priced groups.
- Tax deducted by the profit engine; zero when the shop ignores VAT.
- Order net_revenue = gross total − effective_tax − raw refund amount. Recovered VAT is added back in CM1, not in this field; a negative refund amount increases net revenue.
- CM1 = net_revenue + recovered_vat − total_cogs + recovered_cogs, equivalently (gross − refunds) − (effective_tax − recovered_vat) − (total_cogs − recovered_cogs).
- CM2 = CM1 − payment fees − shipping fees.
- Period CM3 = CM2 − ad spend; CM3 is unavailable per order.
- Period Operating Profit = CM3 − custom expenses.
- Order-level prorated COGS recovery when the global returns-COGS flag is enabled, capped at original COGS for nonnegative costs. This uses refund share, not evidence of restocking, and applies when the stored order is recomputed.
- Order-level VAT recovery prorated by nonnegative refunds / gross, with a zero-gross guard; zero when the shop ignores VAT. This is a CM1 add-back.
- Missing COGS, payment fees and shipping fees commonly default to zero. A zero does not prove all costs were configured; preserve null as a distinct unavailable value. Partial shipping resolution can retain positive fees from priced groups.
- Per-unit live resolved COGS: variant rule > product rule > current Shopify variant cost > current global fallback. Unresolved live line cost is null, while stored order COGS can default to zero. Venon rule periods use the order’s shop-local date; Shopify/global fallback values also apply to older orders. Multiply by quantity for line cost.
- Catalog and live line detail reflect their read sources; stored enriched summaries require recomputation, so sum(line cost × quantity) can differ from total_cogs. The current model’s default three-day CDC arrival lookback is not an order-age cutoff: older edits can trigger rebuilds; out-of-window cases use the existing cost-settings backfill path. No freshness SLA is implied. metadata.timestamp is response time, not source freshness.
- Read each amount with its field-specific currency: an object’s currency or \*\_currency field can override shop currency. For example, budget_currency is the ad account's currency. shipping_profile_currency describes a representative profile, not every priced group in a combined shipping fee. Do not assume unlike currencies were converted or can be added.
- Units are field-specific. Retention pct_repeat_purchasers and contribution_margin_pct are fractions: 0.5 means 50%. Non-ad profit_margin_pct, P&L percent and cohort active_customers_percentage are percentage points: 50 means 50%. Order net_margin is CM2 / net_revenue × 100; product margin_pct is margin / gross line revenue × 100. P&L Returns uses gross revenue; other percentage-bearing rows and waterfall pct use net revenue. Read each field’s base.
- Reporting dates and Venon rule periods use shop-local calendar days. Order-detail timestamps are UTC YYYY-MM-DD HH:MM:SS.ffffff, with six fractional digits and no Z suffix. Attributed-order order_timestamp is instead shop-local wall-clock time without an offset; do not parse it as UTC.
- Worked order: gross 120, effective tax 20, refund 30, COGS 40, recovered COGS 10, recovered VAT 5, payment fees 4 and shipping fees 6 give net revenue 70, CM1 45, CM2 35, net margin 50% and break-even ROAS 2. Returns 30/120 = 25%; CM1 45/70 ≈ 64.2857%, using different bases. If 50 is also refunded now for an older order, summary shows refund-date refunds 80, but this window’s order net revenue remains 70, not 120−20−80.
- attributed_orders = SUM(attribution_weight), so credit can be fractional. attributed_revenue weights full gross order totals before refunds. Channel/ad net_profit = attributed CM2 − entity spend; non-ad net_profit = attributed CM2. Neither is shop operating profit. Channel/ad ROAS is zero without spend, while summary ratios can be null. Totals sum rows and recompute ratios; all_clicks can count one order in several channels.
- Spend buckets use shop-local time and explicit conversion to shop currency. Recent spend can change as sources refetch; today is partial. Meta/Google hourly ingestion is bounded by source-specific rolling lookbacks (currently up to seven dates), not a universal freshness or rebuild SLA.
- Reports read synced orders; universal inclusion or exclusion of cancelled/test orders is not guaranteed. Order staging filters usable timestamps and shops; ingestion paths differ, so do not infer these exclusions from a report total.
  Use the period profit-and-loss statement for shop profit; summing order rows does not reconstruct it.

## Connection

- MCP server (Streamable HTTP): https://developer.venon.io/mcp
- REST API: https://developer.venon.io/v1
- Each connection is bound to one shop. To connect a second shop in a client that keys connectors by URL, add https://developer.venon.io/mcp/connections/2 (up to /connections/10) as another connector; it is the same server.

Two kinds of credentials work:

- **OAuth** (interactive clients). The client finds the authorization server at https://developer.venon.io/.well-known/oauth-protected-resource. You sign in to Venon, choose the shop and the permissions to grant; your role decides which permissions you can grant. Access tokens refresh automatically, and you can revoke the connection in Venon's settings. When an admin changes your role to viewer, your existing connections for that shop stop working; connect again to get the permissions your new role allows.
- **API key** (servers and scripts). Create one in the Venon dashboard with only the scopes the job needs and send it as `Authorization: Bearer vnon_...`. The MCP server reads only the `Authorization` header; REST also accepts `X-API-Key`. Keep the key in an environment variable or secret store.

## Client setup

The commands below follow each client's documented remote-server support; menus and flags change between versions, so check your client's MCP documentation if one differs.

**Claude Code**: add the server, then run `/mcp` inside Claude Code to sign in with OAuth:

```sh
claude mcp add --transport http venon https://developer.venon.io/mcp
```

With an API key instead:

```sh
claude mcp add --transport http venon https://developer.venon.io/mcp --header "Authorization: Bearer $VENON_API_KEY"
```

**Codex** (CLI and IDE extension share `~/.codex/config.toml`). Sign in with `codex mcp login venon`, or set `bearer_token_env_var` to use an API key. Older releases need `experimental_use_rmcp_client = true` for HTTP servers.

```toml
[mcp_servers.venon]
url = "https://developer.venon.io/mcp"
bearer_token_env_var = "VENON_API_KEY"
```

**Cursor** (`~/.cursor/mcp.json`, or `.cursor/mcp.json` in a project). Cursor offers the OAuth sign-in when the server asks for it. For an API key, add `"headers": { "Authorization": "Bearer ${env:VENON_API_KEY}" }` in versions that support environment interpolation.

```json
{ "mcpServers": { "venon": { "url": "https://developer.venon.io/mcp" } } }
```

**Claude.ai, ChatGPT and other connector UIs**: add a custom connector with https://developer.venon.io/mcp and complete the Venon sign-in.

### Raw Streamable HTTP with an API key

The server is stateless: it issues no session ID, and every request is one POST answered with JSON. Initialize first:

```sh
curl -sS https://developer.venon.io/mcp \
  -H "Authorization: Bearer $VENON_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"example-agent","version":"1.0.0"}}}'
```

`result.protocolVersion` in the answer is the negotiated version. Send it as the `MCP-Protocol-Version` header on every later request, then confirm initialization (answered with HTTP 202 and no body) and list the tools:

```sh
PROTOCOL_VERSION=2025-06-18  # the negotiated version
curl -sS https://developer.venon.io/mcp \
  -H "Authorization: Bearer $VENON_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "MCP-Protocol-Version: $PROTOCOL_VERSION" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'
curl -sS https://developer.venon.io/mcp \
  -H "Authorization: Bearer $VENON_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "MCP-Protocol-Version: $PROTOCOL_VERSION" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
```

Call a tool with `tools/call` and `params: { "name": "...", "arguments": { ... } }`, using the tool's `inputSchema`.

## Tools

`tools/list` returns only the tools the credential's scopes allow. Some tools need an extra scope: individual order records need `orders:read` next to `analytics:read`. A missing tool means a missing scope; ask for a credential with that scope rather than working around it. Each tool carries a title and `readOnlyHint`, `destructiveHint` and `openWorldHint` annotations. They describe the effect; scopes and the user's role enforce access.

Current tools by required scopes:

### `analytics:read`

- `get_channel_performance`: Get channel performance (read-only)
- `get_campaign_performance`: Get campaign performance (read-only)
- `get_ad_set_performance`: Get ad set performance (read-only)
- `get_ad_performance`: Get ad performance (read-only)
- `get_analytics_summary`: Get analytics summary (read-only)
- `get_metrics_timeseries`: Get metrics time series (read-only)
- `get_profit_loss`: Get profit and loss (read-only)
- `get_product_performance`: Get product performance (read-only)
- `lookup_products`: Look up products (read-only)
- `get_cohorts`: Get customer cohorts (read-only)
- `get_retention`: Get customer retention (read-only)
- `get_product_relationships`: Get product relationships (read-only)
- `get_attributed_products`: Get attributed products (read-only)
- `get_non_ad_campaign_performance`: Get non-ad campaign performance (read-only)

### `analytics:read` + `orders:read`

- `get_attributed_orders`: Get attributed orders (read-only)

### `orders:read`

- `list_orders`: List orders (read-only)
- `get_order_cost_breakdown`: Get order cost breakdown (read-only)
- `list_order_cost_breakdowns`: List order cost breakdowns (read-only)

### `cost:read`

- `read_cogs_rules_bulk`: Read selected COGS rules (read-only)
- `get_cogs_global`: Get global COGS settings (read-only)
- `list_cogs_rules`: List COGS rules (read-only)
- `get_cogs_rule`: Get COGS rule (read-only)
- `list_payment_gateways`: List payment gateways (read-only)
- `list_shipping_profiles`: List shipping profiles (read-only)
- `get_shipping_profile`: Get shipping profile (read-only)
- `list_shipping_methods`: List shipping methods (read-only)

### `cost:write`

- `apply_cogs_history_ops`: Edit COGS history periods (changes Venon settings)
- `apply_payment_gateway_ops`: Edit payment fee periods (changes Venon settings)
- `delete_shipping_profile`: Delete shipping profile (changes Venon settings)
- `upsert_cogs_global`: Set global COGS fallback (changes Venon settings)
- `create_cogs_rule`: Create COGS rule (changes Venon settings)
- `upsert_payment_gateway`: Update payment gateway fees (changes Venon settings)
- `upsert_shipping_profile`: Create or update shipping profile (changes Venon settings)
- `set_shipping_tiers`: Set shipping tiers (changes Venon settings)
- `update_shipping_costs`: Update shipping costs (changes Venon settings)
- `set_cogs_history`: Replace COGS history (changes Venon settings)
- `set_payment_fee_history`: Replace payment fee history (changes Venon settings)
- `set_shipping_fee_history`: Replace shipping fee history (changes Venon settings)
- `set_shipping_bucket_history`: Replace shipping bucket history (changes Venon settings)
- `write_cogs_rules_bulk`: Write selected COGS rules (changes Venon settings)
- `set_product_cogs`: Set COGS for many products (changes Venon settings)
- `set_payment_fees`: Update fees for many payment gateways (changes Venon settings)
- `preview_cost_changes`: Preview COGS changes (read-only)

### `ads:write`

- `update_campaign_status`: Pause or activate campaign (changes the ad platform immediately)
- `update_ad_set_status`: Pause or activate ad set (changes the ad platform immediately)
- `update_ad_status`: Pause or activate ad (changes the ad platform immediately)
- `update_campaign_budget`: Set campaign daily budget (changes the ad platform immediately)
- `update_ad_set_budget`: Set ad set daily budget (changes the ad platform immediately)

### `filters:read`

- `list_data_filters`: List data filters (read-only)
- `list_data_filter_values`: List data filter values (read-only)

### `filters:write`

- `create_data_filter`: Create data filter (changes Venon settings)
- `update_data_filter`: Update data filter (changes Venon settings)
- `delete_data_filter`: Delete data filter (changes Venon settings)

Successful results carry `structuredContent.data`. Tools that apply saved data filters report them beside the data.

## Instructions for AI agents

- Discover tools with `tools/list` at the start of a session and follow each tool's input schema; do not assume tools from earlier sessions or other credentials.
- Work within the granted scopes and ask the user before requesting broader access.
- Before any tool that is not read-only, show the user the exact change and wait for their confirmation. Tools that change the ad platform take effect on live campaigns immediately. Prefer a dry run or preview where one exists.
- Never print, store or repeat API keys, tokens or authorization headers in answers, files or logs.
- MCP tool failures return isError: true with structuredContent.error.code/message and structuredContent.request_id, even when HTTP succeeds. Advertised outputSchema uses oneOf: either the unchanged success envelope with data, or an error envelope with error and request_id (optional retry_after_seconds); the two cannot be mixed. Check isError before reading data. Safe validation details and shop_context remain readable; unexpected internal and output-validation details are masked. Ad-write tool limits also carry retry_after_seconds; wait that delay before retrying. Keep request_id when reporting a failure. JSON-RPC protocol errors and HTTP authentication, origin and endpoint rate-limit failures are separate protocols with their existing error shapes. On HTTP 401, sign in again or check the key; on a missing scope, tell the user which scope is needed. REST errors carry `metadata.request_id`.
- When comparing numbers, keep the dates, attribution model and window, and saved data filters identical across calls.

## Rate limits

- MCP: 60 requests per minute per API key or OAuth token. REST: 60 per minute per API key. Ad-platform writes: 10 per minute per credential on REST, with the same cap on the MCP tools that change the ad platform.
- Requests without credentials and repeated failed authentication (401) are limited per IP address, as are the OAuth sign-in and token endpoints.
- Responses carry `RateLimit-Policy`, `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`; `RateLimit-Reset` is the number of seconds until the window resets. A limited request gets HTTP 429 with `Retry-After` in seconds; MCP also puts `retry_after_seconds` in the error, and an ad-write limit inside a tool call comes back as a tool error with `retry_after_seconds`.

## Reproducing dashboard numbers

Without attribution parameters, every endpoint and tool uses `last_paid_click` with a `lifetime` window. The dashboard opens on `all_clicks` with a `lifetime` window and remembers each user's choice, so pass `attribution_model: "all_clicks"` and `attribution_window: "lifetime"` (or whatever the dashboard shows). On reports in the support matrix, use the same shop-local dates and the same saved data filters (`filter_mode` and `filter_ids`).

### Attribution models

- linear_paid: equal credit per paid channel, split equally across that channel’s grouped ad identities; non-paid channels get 0. An order without paid touchpoints falls back to linear_all.
- linear_all: equal credit per channel (paid or not), split equally across that channel’s grouped ad identities.
- first_click: full credit to the grouped ad identity with the earliest eligible tracked visit.
- last_click: full credit to the grouped ad identity with the latest eligible tracked visit.
- last_paid_click: full credit to the latest paid grouped ad identity. An order without paid touchpoints falls back to last_click.
- all_clicks: credit 1 per touched channel, split across that channel’s grouped ad identities, so one order can count in several channels and channel totals can exceed shop revenue.

Touchpoints are eligible tracked visits with a source inside the attribution window; there is no view-through credit from ad impressions. Eligibility uses raw UTC event time at or before purchase time plus the configured post-purchase tolerance. With the current default of 300 seconds, inclusive, a sourced visit at +300 seconds is eligible; at +301 seconds is ineligible. The attribution window still applies; lifetime removes only the lookback limit, not this cutoff. An order with eligible tracked visits but no eligible source in the window is credited to direct. An order with no eligible tracked visit is non_attributed when no visits are linked or all linked visits are resolved and after the cutoff. Missing or pending visit evidence can remain direct. Both direct and non_attributed keep full credit. Example: three distinct Meta ad tuples and one Google tuple under linear_all give 50% per channel, 1/6 per Meta tuple and 1/2 for Google. Under all_clicks each channel gets 1, so summing channels gives 2 orders of credit for that one order.
