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.
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:CreatedwithPass:Installed.Query scan events to build a redemption analytics view.
Validate campaign delivery by comparing
Pass:NotificationSentwith install spikes.
Authentication and permissions
Send the tenant API key in the
X-API-KEYheader.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 returns401. A key without the scope returns403.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:
Reference parameters by name, e.g. {"query": "Events | where Name == eventName | take 100", "parameters": {"eventName": "Pass:Installed"}}.
KQL query to run.
KQL text. Only analytics-schema tables and columns are accepted, over the tenant's own data; invalid KQL returns 400 with a diagnostic.
Column names and rows.
Query result.
Column names, in projection order.
Empty or invalid query, unknown table or column, invalid or reserved parameter name, maxRows out of range, or more rows than maxRows.
The caller is not authenticated.
The caller lacks the tenant.insights:read scope, or the endpoint is not enabled for the tenant.
The tenant does not exist.
Over 60 requests per minute to this endpoint for the tenant (default limit); retry after Retry-After.
Query ran too long; aggregate or narrow it.
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 identifierThe request body must contain a
querystring in KQL.Pass values through
parameters(named query parameters) instead of concatenating them into the query. Names start with a letter or_;params_tenantIdis reserved.options.maxRowssets the row limit, from 1 to 100,000 (the default). A query that matches more rows, or a value out of range, returns400: aggregate or narrow the query.400also covers an empty or invalid query and an unknown table or column.504means 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.
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:
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 inEventData.registrationSource:medium,tags(an array, read it withmv-expand),origin(the page URL; derive the host withparse_url) anduserAgent.Every
Pass:*event carriesEventData.passType(the pass template),EventData.metadata.<key>(the pass metadata, such asstoreId) andEventData.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.
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.
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
summarizeinstead of polling loops.
Query takes too long
504means 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.
400on an apparently correct queryA column name is wrong, or a parameter lacks a cast.
Unfamiliar numbers
Confirm the environment. QA holds test data, not production data.
FAQ
Last updated

