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

# Verify dataset query billing against Stripe invoices



## OpenAPI

````yaml /api-reference/openapi.json post /v2/billing/verification
openapi: 3.1.0
info:
  title: Base39 API
  description: Base39 API
  version: 1.0.0
  contact:
    name: Base39 Team
    url: https://base39.com.br
    email: suporte@base39.com.br
  termsOfService: https://base39.com.br/termos
  license:
    name: Proprietary
    url: https://base39.com.br/termos
servers:
  - url: http://localhost:3000
    description: Local
  - url: https://api.dev.base39.cloud
    description: Development
  - url: https://api.base39.com.br
    description: Production
security:
  - OAuth2: []
tags:
  - name: pages
    description: Profiles and reports pages
  - name: pipelines
    description: Pipeline boards (kanban) of pages
  - name: blocks
    description: Blocks operations
  - name: search
    description: Search across content
  - name: targets
    description: Lookup targets via datasets
  - name: CognitoTriggers
    description: Cognito triggers
paths:
  /v2/billing/verification:
    post:
      tags:
        - billing
      summary: Verify dataset query billing against Stripe invoices
      operationId: billing_verify
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BillingVerificationInput'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingVerificationOutput'
components:
  schemas:
    BillingVerificationInput:
      type: object
      properties:
        start:
          type: string
          description: Inclusive period start for dataset query usage
          format: date-time
        end:
          type: string
          description: Exclusive period end for dataset query usage
          format: date-time
        org:
          type: string
          description: Org id, slug, or Stripe customer id
        dataset:
          type: string
          description: Dataset id or slug
        includeUpcoming:
          type: boolean
          description: Include Stripe upcoming invoice previews
          default: true
        toleranceCents:
          type: number
          description: Allowed amount delta in cents
          default: 0
          minimum: 0
        maxOrgs:
          type: number
          description: Maximum orgs to compare with Stripe; 0 means all
          default: 50
          minimum: 0
          maximum: 500
      required:
        - start
        - end
    BillingVerificationOutput:
      type: object
      properties:
        object:
          type: string
          enum:
            - billing_verification
          example: billing_verification
        start:
          type: string
          format: date-time
        end:
          type: string
          format: date-time
        summary:
          $ref: '#/components/schemas/BillingVerificationSummaryOutput'
        rows:
          type: array
          items:
            $ref: '#/components/schemas/BillingVerificationRowOutput'
        missingSamples:
          type: array
          items:
            $ref: '#/components/schemas/BillingVerificationMissingSampleOutput'
        invoiceLines:
          type: array
          items:
            $ref: '#/components/schemas/BillingVerificationInvoiceLineOutput'
      required:
        - object
        - start
        - end
        - summary
        - rows
        - missingSamples
        - invoiceLines
    BillingVerificationSummaryOutput:
      type: object
      properties:
        orgs:
          type: number
          example: 12
        meters:
          type: number
          example: 8
        expectedEvents:
          type: number
          example: 120
        expectedValue:
          type: number
          example: 425000
        usageRows:
          type: number
          example: 118
        sentRows:
          type: number
          example: 117
        sentValue:
          type: number
          example: 420000
        missingUsageRows:
          type: number
          example: 2
        missingStripeRows:
          type: number
          example: 3
        missingSamples:
          type: number
          example: 5
        databaseAmountCents:
          type: number
          example: 425000
        stripeInvoiceAmountCents:
          type: number
          example: 420000
        deltaCents:
          type: number
          example: 5000
        upcomingAmountCents:
          type: number
          example: 110000
        invoices:
          type: number
          example: 2
        invoiceLines:
          type: number
          example: 14
        diffs:
          type: number
          example: 4
        errors:
          type: number
          example: 0
      required:
        - orgs
        - meters
        - expectedEvents
        - expectedValue
        - usageRows
        - sentRows
        - sentValue
        - missingUsageRows
        - missingStripeRows
        - missingSamples
        - databaseAmountCents
        - stripeInvoiceAmountCents
        - deltaCents
        - upcomingAmountCents
        - invoices
        - invoiceLines
        - diffs
        - errors
    BillingVerificationRowOutput:
      type: object
      properties:
        orgId:
          type: string
          example: o_abc123
        orgSlug:
          type: string
          example: acme
        orgName:
          type: string
          example: Acme Ltda
        stripeCustomerId:
          type: object
          example: cus_abc123
          nullable: true
        stripeSubscriptionId:
          type: object
          example: sub_abc123
          nullable: true
        meterEventName:
          type: string
          example: dataset_query.executed
        expectedEvents:
          type: number
          example: 40
        expectedValue:
          type: number
          example: 40000
        usageRows:
          type: number
          example: 40
        sentRows:
          type: number
          example: 40
        missingUsageRows:
          type: number
          example: 0
        missingStripeRows:
          type: number
          example: 0
        sentValue:
          type: number
          example: 40000
        databaseAmountCents:
          type: object
          example: 40000
          nullable: true
        stripeInvoiceAmountCents:
          type: number
          example: 40000
        stripeUpcomingAmountCents:
          type: number
          example: 40000
        deltaCents:
          type: object
          example: 0
          nullable: true
        status:
          type: string
          example: ok
          enum:
            - ok
            - diff
            - missing_usage
            - missing_stripe
            - stripe_only
            - error
        detail:
          type: object
          example: No Stripe customer on org
          nullable: true
        firstQueryAt:
          type: object
          format: date-time
          nullable: true
        lastQueryAt:
          type: object
          format: date-time
          nullable: true
      required:
        - orgId
        - orgSlug
        - orgName
        - meterEventName
        - expectedEvents
        - expectedValue
        - usageRows
        - sentRows
        - missingUsageRows
        - missingStripeRows
        - sentValue
        - stripeInvoiceAmountCents
        - stripeUpcomingAmountCents
        - status
    BillingVerificationMissingSampleOutput:
      type: object
      properties:
        queryId:
          type: string
          example: query_abc123
        orgId:
          type: string
          example: o_abc123
        orgSlug:
          type: string
          example: acme
        datasetSlug:
          type: string
          example: dataset_slug
        meterEventName:
          type: string
          example: dataset_query.executed
        meterEventValue:
          type: number
          example: 1000
        createdAt:
          type: string
          format: date-time
        reason:
          type: string
          example: missing_stripe
          enum:
            - missing_usage
            - missing_stripe
      required:
        - queryId
        - orgId
        - orgSlug
        - datasetSlug
        - meterEventName
        - meterEventValue
        - createdAt
        - reason
    BillingVerificationInvoiceLineOutput:
      type: object
      properties:
        orgId:
          type: string
          example: o_abc123
        orgSlug:
          type: string
          example: acme
        meterEventName:
          type: string
          example: dataset_query.executed
        source:
          type: string
          example: invoice
          enum:
            - invoice
            - upcoming
        invoiceId:
          type: object
          example: in_abc123
          nullable: true
        invoiceNumber:
          type: object
          example: INV-0001
          nullable: true
        status:
          type: object
          example: paid
          nullable: true
        amountCents:
          type: number
          example: 40000
        quantity:
          type: object
          example: 40
          nullable: true
        description:
          type: object
          example: Consumo de créditos
          nullable: true
        createdAt:
          type: string
          format: date-time
      required:
        - orgId
        - orgSlug
        - meterEventName
        - source
        - amountCents
        - createdAt
  securitySchemes:
    OAuth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://id.local.base39.cloud/oauth2/authorize
          tokenUrl: https://id.local.base39.cloud/oauth2/token
          scopes:
            profile: Read user profile
            email: Read user email
            openid: OpenID authentication
      description: OAuth2 Authorization Code flow

````