> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.suby.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Org-wide analytics

> KPIs, revenue trend, product mix, and method/status breakdowns for the whole org.



## OpenAPI

````yaml /v3-beta/api-reference/openapi.yaml get /v3/analytics
openapi: 3.1.0
info:
  title: Suby.fi Merchant API
  version: 3.0.0-beta
  description: >
    The **v3** public merchant API for Suby.fi. RESTful (plural,
    resource-oriented

    endpoints under the `/v3` prefix). Authenticate every request

    with your secret API key in the `X-Suby-Api-Key` header.


    - `sk_live_…` keys operate in **production** (real funds).

    - `sk_sandbox_…` keys operate in a fully simulated **sandbox** (test cards,
      Base Sepolia crypto, no real money). The environment is derived from the
      key prefix.

    All monetary amounts are **integer cents** (except `priceCents` on some

    read shapes, which is a string) — token amounts are strings in the smallest

    unit (sats / lamports / wei). Fees are basis points.
  contact:
    email: dev@suby.fi
    url: https://suby.fi
servers:
  - url: https://api.beta.suby.fi
    description: Production + sandbox (environment selected by API key prefix)
security:
  - ApiKeyAuth: []
tags:
  - name: Products
    description: Manage your product catalog (one-time and recurring).
  - name: Checkout
    description: >-
      Hosted checkout — signed session tokens (`cs_…`) plus branding and
      appearance settings.
  - name: Payments
    description: >-
      Create, capture, void, and retrieve one-time & off-session payments (card,
      APM, and crypto).
  - name: Subscriptions
    description: Start and cancel recurring subscriptions.
  - name: Customers
    description: First-class customer records with billing address.
  - name: Payment Methods
    description: >-
      Save a payment method to a customer and manage saved instruments for
      off-session charges.
  - name: Webhook Endpoints
    description: Register outbound webhook destinations and rotate signing secrets.
  - name: Analytics
    description: Org-wide revenue analytics.
  - name: Health
    description: Unauthenticated liveness probe.
paths:
  /v3/analytics:
    get:
      tags:
        - Analytics
      summary: Org-wide analytics
      description: >-
        KPIs, revenue trend, product mix, and method/status breakdowns for the
        whole org.
      operationId: getMerchantAnalytics
      parameters:
        - $ref: '#/components/parameters/StartDate'
        - $ref: '#/components/parameters/EndDate'
      responses:
        '200':
          description: Merchant analytics
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - properties:
                      data:
                        $ref: '#/components/schemas/MerchantAnalytics'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  parameters:
    StartDate:
      name: startDate
      in: query
      description: Window start, epoch milliseconds.
      schema:
        type: integer
        minimum: 0
    EndDate:
      name: endDate
      in: query
      description: Window end, epoch milliseconds.
      schema:
        type: integer
        minimum: 0
  schemas:
    SuccessEnvelope:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
        data:
          description: Endpoint-specific payload.
    MerchantAnalytics:
      type: object
      properties:
        startDate:
          type: integer
        endDate:
          type: integer
        range:
          type: object
          properties:
            since:
              type: string
            until:
              type: string
            spanDays:
              type: integer
        prevLabel:
          type: string
        currency:
          type: string
          description: >-
            Currency the money aggregates are expressed in. "USD" (the base)
            whenever FX conversion ran (rates.eurToUsdScaled1e8 set); otherwise
            the first payment's currency (legacy naive fallback).
        rates:
          type: object
          description: >-
            Display FX rates so the client can render totals in the merchant's
            chosen currency. Aggregates are in the USD base; apply
            eurToUsdScaled1e8 to convert.
          properties:
            base:
              type: string
              enum:
                - USD
            eurToUsdScaled1e8:
              type: string
              nullable: true
              description: >-
                USD per 1 EUR, scaled 1e8. null when unavailable (render at
                1:1).
            asOf:
              type: integer
              nullable: true
              description: When the rate was resolved (epoch ms).
        hasCrypto:
          type: boolean
        series:
          type: array
          items:
            type: object
            properties:
              date:
                type: string
              full:
                type: string
              unit:
                type: string
                enum:
                  - day
                  - week
                  - month
              fiatCents:
                type: integer
              cryptoCents:
                type: integer
              refundCents:
                type: integer
              subscriptionCents:
                type: integer
              oneTimeCents:
                type: integer
        overview:
          type: object
          properties:
            revenueCents:
              type: integer
            revenueDelta:
              type: number
              nullable: true
            subscriptionCents:
              type: integer
            oneTimeCents:
              type: integer
            orders:
              type: integer
            ordersDelta:
              type: number
              nullable: true
            avgOrderCents:
              type: integer
            newCustomers:
              type: integer
            newCustomersDelta:
              type: number
              nullable: true
        subscription:
          type: object
          properties:
            mrrCents:
              type: integer
            arrCents:
              type: integer
            activeSubscriptions:
              type: integer
            inactiveSubscriptions:
              type: integer
        oneTime:
          type: object
          properties:
            revenueCents:
              type: integer
            orders:
              type: integer
            avgOrderCents:
              type: integer
            repeatCustomerRate:
              type: number
        payments:
          type: object
          properties:
            attempts:
              type: integer
              description: completed + failed + declined (successRate denominator).
            success:
              type: integer
            failed:
              type: integer
              description: Technical / processing failures.
            declined:
              type: integer
              description: Real issuer/bank declines.
            refunded:
              type: integer
            successRate:
              type: number
        productMix:
          type: array
          items:
            type: object
            properties:
              productId:
                type: string
              name:
                type: string
              revenueCents:
                type: integer
                description: >-
                  Completed gross in the product's OWN currency (never
                  FX-converted).
              currency:
                type: string
                description: ISO 4217 the product's revenueCents is expressed in.
              share:
                type: number
        customerMix:
          type: array
          description: >-
            Top customers by completed gross (desc, response base currency),
            share of customer revenue.
          items:
            type: object
            properties:
              customerId:
                type: string
              label:
                type: string
                description: 'Display label: full name → email.'
              revenueCents:
                type: integer
              share:
                type: number
        countryBreakdown:
          type: array
          description: >-
            Revenue by billing country (completed gross, desc). Every country is
            returned; payments with no known country fall into an UNKNOWN
            bucket. Shares sum to 1.
          items:
            type: object
            properties:
              countryCode:
                type: string
                description: >-
                  ISO 3166-1 alpha-2, or "UNKNOWN" when no billing country is
                  known.
              countryName:
                type: string
                description: English region name, or "Unknown".
              revenueCents:
                type: integer
              share:
                type: number
        customerSeries:
          type: array
          description: New customers per bucket, aligned 1:1 to `series`.
          items:
            type: object
            properties:
              date:
                type: string
              full:
                type: string
              unit:
                type: string
                enum:
                  - day
                  - week
                  - month
              customers:
                type: integer
        customerCountryBreakdown:
          type: array
          description: >-
            Distinct paying customers (a completed payment in the window) by
            billing country, desc; UNKNOWN bucket for the rest; shares sum to 1.
          items:
            type: object
            properties:
              countryCode:
                type: string
              countryName:
                type: string
              customers:
                type: integer
              share:
                type: number
        customers:
          type: object
          description: Customer totals + one-time vs subscription split (point-in-time).
          properties:
            total:
              type: integer
              description: All customers of the org.
            paying:
              type: integer
              description: Distinct customers with a completed payment in the window.
            subscription:
              type: integer
              description: Customers with at least one subscription.
            oneTime:
              type: integer
              description: Customers with no subscription (total − subscription).
        methodBreakdown:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
                enum:
                  - card
                  - crypto
              count:
                type: integer
              grossCents:
                type: integer
        statusBreakdown:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
                enum:
                  - completed
                  - pending
                  - failed
                  - declined
                  - refunded
              count:
                type: integer
    Error:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          description: Machine-readable error code.
          example: NOT_FOUND
        message:
          type: string
          example: Resource not found
        data:
          description: Optional error detail.
  responses:
    Unauthorized:
      description: Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: UNAUTHORIZED
            message: Invalid or missing API key
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Suby-Api-Key
      description: Secret API key. `sk_live_…` (production) or `sk_sandbox_…` (sandbox).

````