{"openapi":"3.1.0","info":{"title":"InsightValent Ingest API","version":"1.0.0","description":"Implemented /v1 ingestion contract and the query-key analytics query routes (/api/v1). Paths and HMAC signing v1 are stable; additive fields may appear in v1 and breaking changes require /v2. The signing secret must never be placed in browser code or a public API reference. App credentials determine tenant and project scope; clients cannot choose those IDs. See the tracking plan for allowed names and properties."},"servers":[{"url":"/","description":"Same-origin ingest Worker; configure the base URL for your environment."}],"paths":{"/v1/batch":{"post":{"tags":["Ingestion"],"operationId":"ingestEvents","summary":"Queue events","description":"Use HMAC signing for a server app or a public write key and an allowed Origin for a browser app. Accepted events are queued, not immediately queryable. Reuse eventIds on retries; rejected events must be corrected before resending. A request with any signing header never falls back to write-key authentication.","security":[{"signedRequest":[]},{}],"parameters":[{"name":"x-request-id","in":"header","description":"Optional correlation ID; echoed when it matches ^[A-Za-z0-9._:-]{1,128}$.","schema":{"type":"string","maxLength":128}},{"name":"Origin","in":"header","description":"Required for browser-key requests; must match the app's exact origin allowlist.","schema":{"type":"string"}},{"name":"x-insightvalent-app","in":"header","description":"Required together for signed requests; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-key-id","in":"header","description":"Required together for signed requests; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-timestamp","in":"header","description":"Required together for signed requests; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-nonce","in":"header","description":"Required together for signed requests; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-signature","in":"header","description":"Required together for signed requests; see signedRequest.","schema":{"type":"string"}}],"requestBody":{"required":true,"description":"Maximum 524288 bytes. Signed requests require application/json. Unsigned requests also accept JSON encoded as text/plain for sendBeacon.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchRequest"},"examples":{"server":{"value":{"sentAt":"2026-09-26T20:00:00.000Z","batch":[{"eventId":"2c8527ef-db16-5ed7-b8fd-ef2bad14b60a","name":"account_created","timestamp":"2026-09-26T19:59:58.000Z","userId":"5d0c2a52-8f0e-4e0b-9a51-3c1f6b7d2e10","properties":{"signupMethod":"email","signupApp":"finder","country":"CO","locale":"es-CO"}}]}},"browser":{"value":{"writeKey":"ivpk_EXAMPLE_PUBLIC_WRITE_KEY_1234","batch":[{"eventId":"6a85e292-a604-4a49-9475-0a41f311ec1b","name":"onboarding_step_viewed","timestamp":"2026-09-26T20:00:00.000Z","anonymousId":"device-opaque-id","properties":{"flow":"signup","step":"profile"}}]}}}},"text/plain":{"schema":{"$ref":"#/components/schemas/BatchRequest"},"example":{"writeKey":"ivpk_EXAMPLE_PUBLIC_WRITE_KEY_1234","batch":[{"eventId":"6a85e292-a604-4a49-9475-0a41f311ec1b","name":"onboarding_step_viewed","timestamp":"2026-09-26T20:00:00.000Z","anonymousId":"device-opaque-id","properties":{"flow":"signup","step":"profile"}}]}}}},"responses":{"202":{"description":"Accepted events have been queued; per-event rejections are not retried unchanged.","headers":{"x-request-id":{"schema":{"type":"string"},"description":"Request correlation ID."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchResponse"},"example":{"data":{"accepted":1,"rejected":[]}}}}},"400":{"description":"Request failed (400).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"validation_failed":{"value":{"error":{"code":"validation_failed","message":"See the error message for details"}}}}}}},"401":{"description":"Request failed (401).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"unauthorized":{"value":{"error":{"code":"unauthorized","message":"See the error message for details"}}}}}}},"402":{"description":"Request failed (402).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"billing_read_only":{"value":{"error":{"code":"billing_read_only","message":"See the error message for details"}}},"billing_suspended":{"value":{"error":{"code":"billing_suspended","message":"See the error message for details"}}}}}}},"403":{"description":"Request failed (403).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"origin_not_allowed":{"value":{"error":{"code":"origin_not_allowed","message":"See the error message for details"}}},"not_entitled":{"value":{"error":{"code":"not_entitled","message":"See the error message for details"}}}}}}},"413":{"description":"Request failed (413).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"payload_too_large":{"value":{"error":{"code":"payload_too_large","message":"See the error message for details"}}}}}}},"415":{"description":"Request failed (415).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"unsupported_media_type":{"value":{"error":{"code":"unsupported_media_type","message":"See the error message for details"}}}}}}},"429":{"description":"Request failed (429).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"rate_limited":{"value":{"error":{"code":"rate_limited","message":"See the error message for details"}}},"quota_exceeded":{"value":{"error":{"code":"quota_exceeded","message":"See the error message for details"}}}}}},"headers":{"Retry-After":{"description":"Seconds to wait; present for rate limits and temporary queue failures.","schema":{"type":"integer","minimum":0}}}},"500":{"description":"Request failed (500).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"internal":{"value":{"error":{"code":"internal","message":"See the error message for details"}}}}}}},"503":{"description":"Request failed (503).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"unavailable":{"value":{"error":{"code":"unavailable","message":"See the error message for details"}}}}}},"headers":{"Retry-After":{"description":"Seconds to wait; present for rate limits and temporary queue failures.","schema":{"type":"integer","minimum":0}}}}}}},"/v1/import":{"post":{"tags":["Ingestion"],"operationId":"importEvents","summary":"Import historical events","description":"Server-signed requests only. Historical events as early as 2015-01-01 are allowed. The body must not contain writeKey.","security":[{"signedRequest":[]}],"parameters":[{"name":"x-request-id","in":"header","description":"Optional correlation ID; echoed when it matches ^[A-Za-z0-9._:-]{1,128}$.","schema":{"type":"string","maxLength":128}},{"name":"Origin","in":"header","description":"Required for browser-key requests; must match the app's exact origin allowlist.","schema":{"type":"string"}},{"name":"x-insightvalent-app","in":"header","description":"Required together for signed requests; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-key-id","in":"header","description":"Required together for signed requests; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-timestamp","in":"header","description":"Required together for signed requests; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-nonce","in":"header","description":"Required together for signed requests; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-signature","in":"header","description":"Required together for signed requests; see signedRequest.","schema":{"type":"string"}}],"requestBody":{"required":true,"description":"Maximum 524288 bytes. Signed requests require application/json. Unsigned requests also accept JSON encoded as text/plain for sendBeacon.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchRequest"},"examples":{"server":{"value":{"sentAt":"2026-09-26T20:00:00.000Z","batch":[{"eventId":"2c8527ef-db16-5ed7-b8fd-ef2bad14b60a","name":"account_created","timestamp":"2026-09-26T19:59:58.000Z","userId":"5d0c2a52-8f0e-4e0b-9a51-3c1f6b7d2e10","properties":{"signupMethod":"email","signupApp":"finder","country":"CO","locale":"es-CO"}}]}}}}}},"responses":{"202":{"description":"Accepted events have been queued; per-event rejections are not retried unchanged.","headers":{"x-request-id":{"schema":{"type":"string"},"description":"Request correlation ID."}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchResponse"},"example":{"data":{"accepted":1,"rejected":[]}}}}},"400":{"description":"Request failed (400).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"validation_failed":{"value":{"error":{"code":"validation_failed","message":"See the error message for details"}}}}}}},"401":{"description":"Request failed (401).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"unauthorized":{"value":{"error":{"code":"unauthorized","message":"See the error message for details"}}}}}}},"402":{"description":"Request failed (402).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"billing_read_only":{"value":{"error":{"code":"billing_read_only","message":"See the error message for details"}}},"billing_suspended":{"value":{"error":{"code":"billing_suspended","message":"See the error message for details"}}}}}}},"403":{"description":"Request failed (403).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"origin_not_allowed":{"value":{"error":{"code":"origin_not_allowed","message":"See the error message for details"}}},"not_entitled":{"value":{"error":{"code":"not_entitled","message":"See the error message for details"}}}}}}},"413":{"description":"Request failed (413).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"payload_too_large":{"value":{"error":{"code":"payload_too_large","message":"See the error message for details"}}}}}}},"415":{"description":"Request failed (415).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"unsupported_media_type":{"value":{"error":{"code":"unsupported_media_type","message":"See the error message for details"}}}}}}},"429":{"description":"Request failed (429).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"rate_limited":{"value":{"error":{"code":"rate_limited","message":"See the error message for details"}}},"quota_exceeded":{"value":{"error":{"code":"quota_exceeded","message":"See the error message for details"}}}}}},"headers":{"Retry-After":{"description":"Seconds to wait; present for rate limits and temporary queue failures.","schema":{"type":"integer","minimum":0}}}},"500":{"description":"Request failed (500).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"internal":{"value":{"error":{"code":"internal","message":"See the error message for details"}}}}}}},"503":{"description":"Request failed (503).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"unavailable":{"value":{"error":{"code":"unavailable","message":"See the error message for details"}}}}}},"headers":{"Retry-After":{"description":"Seconds to wait; present for rate limits and temporary queue failures.","schema":{"type":"integer","minimum":0}}}}}}},"/api/v1/projects/{project}/trends/query":{"post":{"tags":["Analytics queries"],"operationId":"queryTrends","summary":"Run a trend query","description":"Series per time bucket in the project time zone, validated against the tenant's active tracking plan. Query keys are limited to 60 query requests per minute and 20 per 10 seconds per key, plus 4 concurrent queries per key; over a limit the API answers 429 rate_limited with Retry-After. Each statement times out after 20 s (503 unavailable).","security":[{"queryKey":[]}],"parameters":[{"name":"project","in":"path","required":true,"description":"Project id or tenant-local project key.","schema":{"type":"string"}}],"requestBody":{"required":true,"description":"See docs/query.md for the full query schema.","content":{"application/json":{"schema":{"type":"object"},"example":{"series":[{"event":"listing_engagement"}],"filters":[{"property":"listingId","op":"eq","value":"lst_123"}],"breakdown":{"by":"property","property":"kind","limit":5},"from":"2026-01-10T00:00:00-05:00","to":"2026-10-15T00:00:00-05:00","granularity":"month"}}}},"responses":{"200":{"description":"Query result. Identical query-key requests are served from a short result cache (60 s by default) per Cloudflare location.","headers":{"x-request-id":{"schema":{"type":"string"},"description":"Request correlation ID."},"x-iv-cache":{"description":"hit or miss for query keys; bypass when caching is off.","schema":{"type":"string","enum":["hit","miss","bypass"]}},"Cache-Control":{"description":"private, max-age=<cache TTL> for cacheable results.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{}}}}}},"400":{"description":"invalid_request: the query does not validate.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"401":{"description":"unauthorized: missing or invalid query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"403":{"description":"forbidden: the route is not readable with a query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"404":{"description":"not_found: unknown project.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"429":{"description":"rate_limited: a per-key rate, burst or concurrency limit was hit. Errors are never cached.","headers":{"Retry-After":{"description":"Seconds to wait: 60 (per-minute limit), 10 (burst) or 1 (concurrency).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"503":{"description":"unavailable: the event store is down or the query timed out.","headers":{"Retry-After":{"description":"Seconds to wait (30).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}}}}},"/api/v1/projects/{project}/funnels/query":{"post":{"tags":["Analytics queries"],"operationId":"queryFunnel","summary":"Run a funnel query","description":"Ordered conversion funnel (aggregates only). Query keys are limited to 60 query requests per minute and 20 per 10 seconds per key, plus 4 concurrent queries per key; over a limit the API answers 429 rate_limited with Retry-After. Each statement times out after 20 s (503 unavailable).","security":[{"queryKey":[]}],"parameters":[{"name":"project","in":"path","required":true,"description":"Project id or tenant-local project key.","schema":{"type":"string"}}],"requestBody":{"required":true,"description":"See docs/query.md for the full query schema.","content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Query result. Identical query-key requests are served from a short result cache (60 s by default) per Cloudflare location.","headers":{"x-request-id":{"schema":{"type":"string"},"description":"Request correlation ID."},"x-iv-cache":{"description":"hit or miss for query keys; bypass when caching is off.","schema":{"type":"string","enum":["hit","miss","bypass"]}},"Cache-Control":{"description":"private, max-age=<cache TTL> for cacheable results.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{}}}}}},"400":{"description":"invalid_request: the query does not validate.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"401":{"description":"unauthorized: missing or invalid query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"403":{"description":"forbidden: the route is not readable with a query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"404":{"description":"not_found: unknown project.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"429":{"description":"rate_limited: a per-key rate, burst or concurrency limit was hit. Errors are never cached.","headers":{"Retry-After":{"description":"Seconds to wait: 60 (per-minute limit), 10 (burst) or 1 (concurrency).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"503":{"description":"unavailable: the event store is down or the query timed out.","headers":{"Retry-After":{"description":"Seconds to wait (30).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}}}}},"/api/v1/projects/{project}/commerce/query":{"post":{"tags":["Analytics queries"],"operationId":"queryCommerce","summary":"Store metrics","description":"Sales, conversion, checkout funnel and top products in one call, from the ecommerce tracking-plan template events (aggregates only). Charged one rate-limit unit per sub-query (at most 4). Query keys are limited to 60 query requests per minute and 20 per 10 seconds per key, plus 4 concurrent queries per key; over a limit the API answers 429 rate_limited with Retry-After. Each statement times out after 20 s (503 unavailable).","security":[{"queryKey":[]}],"parameters":[{"name":"project","in":"path","required":true,"description":"Project id or tenant-local project key.","schema":{"type":"string"}}],"requestBody":{"required":true,"description":"See docs/query.md for the full query schema.","content":{"application/json":{"schema":{"type":"object"},"example":{"lastDays":30,"currency":"COP","topProducts":{"limit":10,"rankBy":"revenue"}}}}},"responses":{"200":{"description":"Query result. Identical query-key requests are served from a short result cache (60 s by default) per Cloudflare location.","headers":{"x-request-id":{"schema":{"type":"string"},"description":"Request correlation ID."},"x-iv-cache":{"description":"hit or miss for query keys; bypass when caching is off.","schema":{"type":"string","enum":["hit","miss","bypass"]}},"Cache-Control":{"description":"private, max-age=<cache TTL> for cacheable results.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{}}}}}},"400":{"description":"invalid_request: the query does not validate.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"401":{"description":"unauthorized: missing or invalid query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"403":{"description":"forbidden: the route is not readable with a query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"404":{"description":"not_found: unknown project.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"429":{"description":"rate_limited: a per-key rate, burst or concurrency limit was hit. Errors are never cached.","headers":{"Retry-After":{"description":"Seconds to wait: 60 (per-minute limit), 10 (burst) or 1 (concurrency).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"503":{"description":"unavailable: the event store is down or the query timed out.","headers":{"Retry-After":{"description":"Seconds to wait (30).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}}}}},"/api/v1/projects/{project}/events/query":{"post":{"tags":["Analytics queries"],"operationId":"queryEvents","summary":"List raw events","description":"Event explorer, newest first with a keyset cursor. Includes user ids and properties. Query keys are limited to 60 query requests per minute and 20 per 10 seconds per key, plus 4 concurrent queries per key; over a limit the API answers 429 rate_limited with Retry-After. Each statement times out after 20 s (503 unavailable).","security":[{"queryKey":[]}],"parameters":[{"name":"project","in":"path","required":true,"description":"Project id or tenant-local project key.","schema":{"type":"string"}}],"requestBody":{"required":true,"description":"See docs/query.md for the full query schema.","content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Query result. Identical query-key requests are served from a short result cache (60 s by default) per Cloudflare location.","headers":{"x-request-id":{"schema":{"type":"string"},"description":"Request correlation ID."},"x-iv-cache":{"description":"hit or miss for query keys; bypass when caching is off.","schema":{"type":"string","enum":["hit","miss","bypass"]}},"Cache-Control":{"description":"private, max-age=<cache TTL> for cacheable results.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{}}}}}},"400":{"description":"invalid_request: the query does not validate.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"401":{"description":"unauthorized: missing or invalid query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"403":{"description":"forbidden: the route is not readable with a query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"404":{"description":"not_found: unknown project.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"429":{"description":"rate_limited: a per-key rate, burst or concurrency limit was hit. Errors are never cached.","headers":{"Retry-After":{"description":"Seconds to wait: 60 (per-minute limit), 10 (burst) or 1 (concurrency).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"503":{"description":"unavailable: the event store is down or the query timed out.","headers":{"Retry-After":{"description":"Seconds to wait (30).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}}}}},"/api/v1/projects/{project}/events/volume/query":{"post":{"tags":["Analytics queries"],"operationId":"queryEventVolume","summary":"Event volume","description":"Events and distinct persons per event name in a range. Query keys are limited to 60 query requests per minute and 20 per 10 seconds per key, plus 4 concurrent queries per key; over a limit the API answers 429 rate_limited with Retry-After. Each statement times out after 20 s (503 unavailable).","security":[{"queryKey":[]}],"parameters":[{"name":"project","in":"path","required":true,"description":"Project id or tenant-local project key.","schema":{"type":"string"}}],"requestBody":{"required":true,"description":"See docs/query.md for the full query schema.","content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Query result. Identical query-key requests are served from a short result cache (60 s by default) per Cloudflare location.","headers":{"x-request-id":{"schema":{"type":"string"},"description":"Request correlation ID."},"x-iv-cache":{"description":"hit or miss for query keys; bypass when caching is off.","schema":{"type":"string","enum":["hit","miss","bypass"]}},"Cache-Control":{"description":"private, max-age=<cache TTL> for cacheable results.","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{}}}}}},"400":{"description":"invalid_request: the query does not validate.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"401":{"description":"unauthorized: missing or invalid query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"403":{"description":"forbidden: the route is not readable with a query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"404":{"description":"not_found: unknown project.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"429":{"description":"rate_limited: a per-key rate, burst or concurrency limit was hit. Errors are never cached.","headers":{"Retry-After":{"description":"Seconds to wait: 60 (per-minute limit), 10 (burst) or 1 (concurrency).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"503":{"description":"unavailable: the event store is down or the query timed out.","headers":{"Retry-After":{"description":"Seconds to wait (30).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}}}}},"/api/v1/projects/{project}/insights/{insight}/query":{"post":{"tags":["Analytics queries"],"operationId":"querySavedInsight","summary":"Run a saved insight","description":"Runs the saved definition ({ dateRange?, version? }); not cached. A definition saved with a rolling range ({ lastDays: N }) resolves at run time to the last N whole days in the project time zone, today included; dateRange ({ from, to } or { lastDays }) overrides the saved range for this run. Query keys are limited to 60 query requests per minute and 20 per 10 seconds per key, plus 4 concurrent queries per key; over a limit the API answers 429 rate_limited with Retry-After. Each statement times out after 20 s (503 unavailable).","security":[{"queryKey":[]}],"parameters":[{"name":"project","in":"path","required":true,"description":"Project id or tenant-local project key.","schema":{"type":"string"}},{"name":"insight","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"description":"See docs/query.md for the full query schema.","content":{"application/json":{"schema":{"type":"object"},"example":{"dateRange":{"lastDays":7}}}}},"responses":{"200":{"description":"Query result.","headers":{"x-request-id":{"schema":{"type":"string"},"description":"Request correlation ID."}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{}}}}}},"400":{"description":"invalid_request: the query does not validate.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"401":{"description":"unauthorized: missing or invalid query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"403":{"description":"forbidden: the route is not readable with a query key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"404":{"description":"not_found: unknown project.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"429":{"description":"rate_limited: a per-key rate, burst or concurrency limit was hit. Errors are never cached.","headers":{"Retry-After":{"description":"Seconds to wait: 60 (per-minute limit), 10 (burst) or 1 (concurrency).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}},"503":{"description":"unavailable: the event store is down or the query timed out.","headers":{"Retry-After":{"description":"Seconds to wait (30).","schema":{"type":"integer","minimum":0}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContractErrorResponse"}}}}}}},"/v1/erasures":{"post":{"tags":["Privacy"],"operationId":"requestErasure","summary":"Erase a user (right to erasure)","description":"Server-signed requests only (browser write keys get 401). Deletes the user's events, the anonymous events of every anonymousId linked to it and the identity links in the signing key's project, then suppresses those ids so later events are dropped. Idempotent per userId: a repeat returns 200 with the original receipt. The userId is never stored, logged or returned. The raw R2 buffer (≤30 days) is purged by its lifecycle rule or by staff; see docs/privacy.md.","security":[{"signedRequest":[]}],"parameters":[{"name":"x-request-id","in":"header","description":"Optional correlation ID; echoed when it matches ^[A-Za-z0-9._:-]{1,128}$.","schema":{"type":"string","maxLength":128}},{"name":"x-insightvalent-app","in":"header","required":true,"description":"Required; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-key-id","in":"header","required":true,"description":"Required; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-timestamp","in":"header","required":true,"description":"Required; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-nonce","in":"header","required":true,"description":"Required; see signedRequest.","schema":{"type":"string"}},{"name":"x-insightvalent-signature","in":"header","required":true,"description":"Required; see signedRequest.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErasureRequest"},"example":{"userId":"5d0c2a52-8f0e-4e0b-9a51-3c1f6b7d2e10"}}}},"responses":{"200":{"description":"The user was already erased; the original receipt.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErasureResponse"},"example":{"data":{"erasure":{"id":"0b7d9f5e-3c1a-4e9b-8f00-6a2d4c1e9b11","projectId":"nestifine","eventsDeleted":42,"identitiesDeleted":1,"anonymousIds":1,"completedAt":"2026-09-26T20:00:00.000Z","extendedAt":null},"created":false}}}}},"201":{"description":"The user was erased now.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErasureResponse"},"example":{"data":{"erasure":{"id":"0b7d9f5e-3c1a-4e9b-8f00-6a2d4c1e9b11","projectId":"nestifine","eventsDeleted":42,"identitiesDeleted":1,"anonymousIds":1,"completedAt":"2026-09-26T20:00:00.000Z","extendedAt":null},"created":true}}}}},"400":{"description":"Request failed (400).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"validation_failed":{"value":{"error":{"code":"validation_failed","message":"See the error message for details"}}}}}}},"401":{"description":"Request failed (401).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"unauthorized":{"value":{"error":{"code":"unauthorized","message":"See the error message for details"}}}}}}},"402":{"description":"Request failed (402).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"billing_read_only":{"value":{"error":{"code":"billing_read_only","message":"See the error message for details"}}},"billing_suspended":{"value":{"error":{"code":"billing_suspended","message":"See the error message for details"}}}}}}},"403":{"description":"Request failed (403).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"origin_not_allowed":{"value":{"error":{"code":"origin_not_allowed","message":"See the error message for details"}}},"not_entitled":{"value":{"error":{"code":"not_entitled","message":"See the error message for details"}}}}}}},"413":{"description":"Request failed (413).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"payload_too_large":{"value":{"error":{"code":"payload_too_large","message":"See the error message for details"}}}}}}},"415":{"description":"Request failed (415).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"unsupported_media_type":{"value":{"error":{"code":"unsupported_media_type","message":"See the error message for details"}}}}}}},"429":{"description":"Request failed (429).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"rate_limited":{"value":{"error":{"code":"rate_limited","message":"See the error message for details"}}},"quota_exceeded":{"value":{"error":{"code":"quota_exceeded","message":"See the error message for details"}}}}}},"headers":{"Retry-After":{"description":"Seconds to wait; present for rate limits and temporary queue failures.","schema":{"type":"integer","minimum":0}}}},"500":{"description":"Request failed (500).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"internal":{"value":{"error":{"code":"internal","message":"See the error message for details"}}}}}}},"503":{"description":"Request failed (503).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"unavailable":{"value":{"error":{"code":"unavailable","message":"See the error message for details"}}}}}},"headers":{"Retry-After":{"description":"Seconds to wait; present for rate limits and temporary queue failures.","schema":{"type":"integer","minimum":0}}}}}}}},"components":{"securitySchemes":{"queryKey":{"type":"http","scheme":"bearer","description":"Tenant secret key (iv_sk_…, created in ValentConsole) or legacy query key (ivq_live_… / ivq_test_…). Read-only analytics; keep it server-side."},"signedRequest":{"type":"apiKey","in":"header","name":"x-insightvalent-signature","description":"Server apps only. Supply all five x-insightvalent-* headers. Signature is v1=<lowercase hex HMAC-SHA256> over insightvalent-v1\\nappId\\nkeyId\\nunixSeconds\\nnonce\\nUPPERCASE_METHOD\\npathname+search\\nsha256(rawBody) hex. Timestamp skew ±300 s; nonce unique for 600 s. Use the server SDK to sign raw bytes. Never enter a signing secret in this page."}},"schemas":{"ContractErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","description":"invalid_request, unauthorized, forbidden, not_found, rate_limited, unavailable, internal_error, …"},"message":{"type":"string"},"requestId":{"type":"string"},"issues":{"type":"array","items":{"type":"object","properties":{"path":{"type":"array","items":{"type":["string","integer"]}},"message":{"type":"string"}}}}}}}},"BatchRequest":{"type":"object","required":["batch"],"properties":{"writeKey":{"type":"string","pattern":"^ivpk_[A-Za-z0-9_-]{16,64}$","description":"Public browser key; required unsigned, forbidden signed."},"sentAt":{"type":"string","format":"date-time","description":"Optional client clock for live-event skew correction."},"batch":{"type":"array","minItems":1,"maxItems":500,"items":{"$ref":"#/components/schemas/Event"},"description":"Individual events are validated separately; invalid events are reported in rejected[]."}}},"Event":{"type":"object","required":["eventId","name","timestamp"],"description":"At least one of userId/anonymousId is required, except for tenant tracking-plan events declared identity \"none\" (server-only, identifier-free aggregates), which must carry neither; during the transition a legacy anonymousId prefixed \"agg_\" is dropped from them instead of rejected. Unknown envelope/context fields are stripped. Tracking-plan properties are strict. Server-only funnel events require userId; identify requires both IDs. One event must be at most 16 KB.","properties":{"eventId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$","description":"Idempotency key. Browser: random UUIDv4 or v7. Server: UUIDv7 or canonical UUIDv5."},"name":{"type":"string","enum":["account_created","property_created","listing_created","listing_published","listing_approved","onboarding_step_viewed","onboarding_step_completed","identify"],"description":"Closed tracking plan. See EventPropertiesByName."},"timestamp":{"type":"string","format":"date-time"},"userId":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,128}$","description":"Opaque, never PII."},"anonymousId":{"type":"string","pattern":"^[A-Za-z0-9._:-]{8,128}$","description":"Opaque device ID."},"properties":{"$ref":"#/components/schemas/EventPropertiesByName"},"context":{"$ref":"#/components/schemas/EventContext"}},"example":{"eventId":"2c8527ef-db16-5ed7-b8fd-ef2bad14b60a","name":"account_created","timestamp":"2026-09-26T19:59:58.000Z","userId":"5d0c2a52-8f0e-4e0b-9a51-3c1f6b7d2e10","properties":{"signupMethod":"email","signupApp":"finder","country":"CO","locale":"es-CO"}}},"EventPropertiesByName":{"anyOf":[{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"signupMethod":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_-]*$"},"signupApp":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_-]*$"},"country":{"type":"string","pattern":"^[A-Z]{2}$"},"locale":{"type":"string","maxLength":35,"pattern":"^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,8})*$"},"source":{"type":"string","minLength":1,"maxLength":64}},"additionalProperties":false,"description":"A user account was created (nestX User row). Funnel anchor. Emitters: server. userId is required.","title":"account_created"},{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"propertyId":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,128}$"},"propertyType":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_-]*$"},"isFirst":{"type":"boolean"}},"required":["propertyId"],"additionalProperties":false,"description":"A property was provisioned for the user. Emitters: server. userId is required.","title":"property_created"},{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"listingId":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,128}$"},"propertyId":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,128}$"},"buildingId":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,128}$"},"listingType":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_-]*$"},"isFirst":{"type":"boolean"}},"required":["listingId"],"additionalProperties":false,"anyOf":[{"required":["propertyId"]},{"required":["buildingId"]}],"description":"A listing (draft) was created for a property or a building. Requires propertyId, buildingId or both. Emitters: server. userId is required.","title":"listing_created"},{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"listingId":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,128}$"},"listingType":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_-]*$"},"isFirstPublish":{"type":"boolean"}},"required":["listingId","isFirstPublish"],"additionalProperties":false,"description":"A listing moved to PUBLISHED status. Emitters: server. userId is required.","title":"listing_published"},{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"listingId":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,128}$"},"isFirstApproval":{"type":"boolean"}},"required":["listingId","isFirstApproval"],"additionalProperties":false,"description":"A listing passed moderation and is visible on Finder. Emitters: server. userId is required.","title":"listing_approved"},{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"flow":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_-]*$"},"step":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_-]*$"},"stepIndex":{"type":"integer","minimum":0,"maximum":100}},"required":["flow","step"],"additionalProperties":false,"description":"An onboarding screen was shown. Emitters: browser, server. At least one of userId and anonymousId is required.","title":"onboarding_step_viewed"},{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"flow":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_-]*$"},"step":{"type":"string","maxLength":64,"pattern":"^[a-z][a-z0-9_-]*$"},"stepIndex":{"type":"integer","minimum":0,"maximum":100}},"required":["flow","step"],"additionalProperties":false,"description":"An onboarding screen was completed. Emitters: browser, server. At least one of userId and anonymousId is required.","title":"onboarding_step_completed"},{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{},"additionalProperties":false,"description":"Links an anonymousId to a userId. First identify wins. Emitters: browser, server. Both userId and anonymousId are required.","title":"identify"}],"description":"The branch must match the event's name. Only declared properties are accepted; PII in keys or values is rejected."},"EventContext":{"type":"object","properties":{"app":{"type":"object","properties":{"version":{"type":"string","minLength":1,"maxLength":128},"build":{"type":"string","minLength":1,"maxLength":128}}},"library":{"type":"object","required":["name","version"],"properties":{"name":{"type":"string","minLength":1,"maxLength":128},"version":{"type":"string","minLength":1,"maxLength":128}}},"locale":{"type":"string","maxLength":35},"timezone":{"type":"string","maxLength":64},"page":{"type":"object","properties":{"path":{"type":"string","pattern":"^/[^?#\\s]*$","maxLength":512},"referrerHost":{"type":"string","pattern":"^[a-z0-9.-]+$","maxLength":253}}},"campaign":{"type":"object","properties":{"source":{"type":"string","minLength":1,"maxLength":128},"medium":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string","minLength":1,"maxLength":128},"term":{"type":"string","minLength":1,"maxLength":128},"content":{"type":"string","minLength":1,"maxLength":128}}}}},"ErasureRequest":{"type":"object","required":["userId"],"additionalProperties":false,"properties":{"userId":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,128}$","description":"The opaque userId used in events. Never echoed back."}}},"ErasureResponse":{"type":"object","required":["data"],"properties":{"data":{"type":"object","required":["erasure","created"],"properties":{"created":{"type":"boolean","description":"false when the user had already been erased (200)."},"erasure":{"type":"object","required":["id","projectId","eventsDeleted","identitiesDeleted","anonymousIds","completedAt","extendedAt"],"properties":{"id":{"type":"string","format":"uuid"},"projectId":{"type":"string"},"eventsDeleted":{"type":"integer","minimum":0},"identitiesDeleted":{"type":"integer","minimum":0},"anonymousIds":{"type":"integer","minimum":0},"completedAt":{"type":"string","format":"date-time"},"extendedAt":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}]}}}}}}},"BatchResponse":{"type":"object","required":["data"],"properties":{"data":{"type":"object","required":["accepted","rejected"],"properties":{"accepted":{"type":"integer","minimum":0},"rejected":{"type":"array","items":{"type":"object","required":["index","code","message"],"properties":{"index":{"type":"integer","minimum":0},"eventId":{"type":"string"},"code":{"type":"string","enum":["invalid_event","unknown_event","invalid_properties","event_not_allowed","pii_detected","too_old"]},"message":{"type":"string"}}}}}}}},"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","enum":["validation_failed","unauthorized","billing_read_only","billing_suspended","origin_not_allowed","not_entitled","not_found","conflict","payload_too_large","unsupported_media_type","rate_limited","quota_exceeded","internal","unavailable"]},"message":{"type":"string"},"details":{"description":"Optional validation details; treat unknown codes as internal."}}}}}}}}