Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.
GuideAPIReference

Insights API

Query tenant-scoped wallet events, logs, requests and page views with the Insights API and Kusto Query Language (KQL) for reporting and analytics.

The Insights API gives access to the usage database of The Wallet Crew. Query logs, events, requests, and page views using Kusto Query Language (KQL).

This API is designed for technical teams extracting data programmatically. Use it for custom date ranges, custom groupings, BI ingestion, and automated reports, when the dashboard is not enough.

The Analytics dashboards in the admin console are built on the same event data. Everything they show can also be queried here, with more flexibility on groupings, filters and date ranges. For a no-code view, use Analytics dashboards. For record-level CSV exports, see Export data.

Common use cases

  • Feed installation and uninstall counts into Tableau, Looker, or Power BI.

  • Automate a weekly report of program performance by store or region.

  • Build a custom activation funnel by correlating Pass:Created with Pass:Installed.

  • Query scan events to build a redemption analytics view.

  • Validate campaign delivery by comparing Pass:NotificationSent with install spikes.

Authentication and permissions

  • Send the tenant API key in the X-API-KEY header.

  • Create the key in Settings → Access control → API keys & secrets (see API keys & secrets). It needs the scope tenant.insights:read. A missing or invalid key returns 401. A key without the scope returns 403.

  • Single-tenant scope: a key queries only its own tenant. The platform adds the tenant filter.

Retention and rate limits

  • Logs: retained 45 days

  • Events and page views: retained indefinitely

Rate limit: 60 calls per minute by default. To request a higher limit, open a support ticket.

The API does not cache results. Cache on your side when you poll.

Endpoint

All queries use this operation:

Run an analytics query

post
/api/{tenantId}/insights/query

Reference parameters by name, e.g. {"query": "Events | where Name == eventName | take 100", "parameters": {"eventName": "Pass:Installed"}}.

Required scopes
This endpoint requires the following scopes:
Authorizations
OAuth2implicitRequired
Authorization URL:
Path parameters
tenantIdstringRequired
Body

KQL query to run.

querystringRequired

KQL text. Only analytics-schema tables and columns are accepted, over the tenant's own data; invalid KQL returns 400 with a diagnostic.

Responses
200

Column names and rows.

Query result.

columnsstring[]Optional

Column names, in projection order.

post/api/{tenantId}/insights/query
POST /api/{tenantId}/insights/query HTTP/1.1
Host: api.thewalletcrew.io
Authorization: Bearer YOUR_OAUTH2_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 88

{
  "query": "text",
  "parameters": {
    "ANY_ADDITIONAL_PROPERTY": "text"
  },
  "options": {
    "maxRows": 1
  }
}
{
  "columns": [
    "text"
  ],
  "rows": [
    []
  ]
}

The base URLs of the production and QA environments are in Getting started with the API.

  • {tenantId} = your tenant identifier

  • The request body must contain a query string in KQL.

  • Pass values through parameters (named query parameters) instead of concatenating them into the query. Names start with a letter or _; params_tenantId is reserved.

  • options.maxRows sets the row limit, from 1 to 100,000 (the default). A query that matches more rows, or a value out of range, returns 400: aggregate or narrow the query.

  • 400 also covers an empty or invalid query and an unknown table or column. 504 means the query ran too long.

A first query, which returns the last 50 errors. The host api.thewalletcrew.io is the production base URL:

The response is tabular:

Tables and schema

The Insights database exposes these tables. Table and column names are case-sensitive. There is no Metrics table.

Table
What it contains
Main columns

Events

Business events such as Pass:Created or Customer:Upserted

Timestamp, Name, OperationId, UserId, EventData (dynamic)

Logs

Errors and traces of platform activity, for debugging

Timestamp, SeverityLevel, Message, CategoryName, OperationId, Properties (dynamic)

Requests

API requests

Timestamp, Name, Duration, ResultCode, Success, OperationId

PageViews

Page views of enrolment and download pages

Timestamp, Name, Url, LayoutName, LayoutType, UserAgent

Every table has a TenantId column. Event details sit in EventData, for example EventData.passId.

Common queries

Count customer upserts

Count pass installations

Count API requests per day

Count redirects per day

Count page views per layout

Filter on a structured property

Error rate as a percentage

Everything that touches one pass, in the logs

For the error and trace recipes on Logs, see Retrieve platform logs.

History of one pass, with a parameter

Parameter types and paging

Parameters arrive as strings: cast them in the query, with todatetime() or toint(). Page through large results by numbering and slicing rows:

A query that returns more rows than options.maxRows fails by design instead of returning a trimmed result that looks complete.

Common event names

The Name column of Events holds the event name. Webhooks use the same names. Each event is defined in What The Wallet Crew tracks. Each event answers a different business question:

Event
What it captures
Example question

Pass:Created

A pass record was created.

How many passes were issued this month per store?

Pass:Installed

A pass was added to Apple Wallet or Google Wallet, with its source in registrationSource (medium, tags, origin).

Which email campaign drove the most installs last week?

Pass:Uninstalled

A pass was removed from its last device on one wallet.

What is the uninstall rate by program?

Pass:Updated

Pass data changed.

How many passes were updated after the last campaign?

Pass:UpdateSent

A push update was delivered to a device.

Are updates reaching devices reliably?

Pass:Scanned

A pass barcode was scanned.

How many scans per day happened at each location?

Pass:NotificationSent

A push notification was sent.

How many notifications were sent per program this month?

Pass:LinkOpened

The holder tapped a tracked link of the pass.

Which links of the pass do holders open?

Customer:Upserted

A customer was created or updated.

How many customer profiles were created or updated this week?

Redirect:Redirected

A user opened a minified URL (redirect).

How many scans of the in-store QR code reached the enrolment form?

Filters

Filter an Events query on the date (Timestamp), the event (Name), and the fields of EventData:

  • On Pass:Installed, the installation source is in EventData.registrationSource: medium, tags (an array, read it with mv-expand), origin (the page URL; derive the host with parse_url) and userAgent.

  • Every Pass:* event carries EventData.passType (the pass template), EventData.metadata.<key> (the pass metadata, such as storeId) and EventData.passTypeTags.

To discover the shape of EventData, return one raw event:

Query from an AI assistant (MCP)

An assistant connected over MCP can run the same queries. The MCP connection needs no API key: sign in with admin console credentials (OAuth). See Model Context Protocol (MCP) for the endpoints and set-up.

Tool
Use

twc_insights_schema_get

Confirm available tables, columns and event names, with worked examples.

twc_insights_query

Run KQL and return results.

Prompt patterns for investigations:

Show every error and warning from the last 24 hours, grouped by component. For the three noisiest, explain the component and messages.

Find log lines for pass <PASS_ID> from the last 7 days. Reconstruct what happened and identify failed steps.

Operation <OPERATION_ID> failed. Pull its lines in order and identify where it broke.

Compare this week's error volume with last week. Flag components whose failures more than doubled.

Keep the time range narrow. Each tool call is capped at two minutes, and broad Logs queries can reach that limit.

Troubleshooting

  • 401 Unauthorized

    • Ensure the API key is valid.

  • 403 Forbidden

    • The key lacks tenant.insights:read, or analytics are not enabled for the tenant.

  • 429 Too Many Requests

    • The rate limit was exceeded. Implement retries with exponential backoff, and batch with summarize instead of polling loops.

  • Query takes too long

    • 504 means the query ran too long. Simplify the query or reduce the time window.

    • Avoid unbounded queries on large tables.

  • No rows when rows were expected

    • Check the retention window of the table, then the casing of table and column names.

  • 400 on an apparently correct query

    • A column name is wrong, or a parameter lacks a cast.

  • Unfamiliar numbers

    • Confirm the environment. QA holds test data, not production data.

FAQ

Can I query multiple tenants?

No. A key queries only its own tenant: the platform adds the tenant filter to every query.

Can I export results to CSV/JSON?

Not directly via the API. The response is JSON with columns and rows: convert it locally. The dashboards in the admin console can export CSV.

Can query results contain personal data?

The available fields depend on tenant configuration and integrations. Treat query results as operational data and apply the organization’s access and retention policies.

Can I set up alerts (thresholds, triggers)?

Not at the moment.

Last updated