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

# Record sales and refunds

> Server-to-server only: authenticate with an organization API key, never from a browser. Amounts are positive integer minor units (1999 is $19.99) with an ISO 4217 currency; a refund is `type: "refund"` with a positive amount. Each event is idempotent on `event_id`: resending it with the same money is reported as `duplicate`, resending it with different money is `rejected`. Totals in the console only include events in the club's reporting currency. Revenue reported here does not award XP.



## OpenAPI

````yaml https://api.develop.fourdos.dev/openapi/partner.json post /v1/revenue
openapi: 3.1.0
info:
  title: 4D OS Partner API
  version: 0.1.0
  description: >-
    REST API for 4D OS partners. Authenticate with your organization API key:
    `Authorization: Bearer <key>`.


    Requests and responses are JSON with `snake_case` field names. Errors share
    one envelope: `{ "error": { "code", "status", "message", "details"? } }`.


    Mutating endpoints that declare it accept an `Idempotency-Key` header so
    retries are safe.


    Bulk-migrating members? See the [Migrating to 4D
    guide](https://docs.fourdos.dev/walkthroughs/migrate-existing-members) for
    the canonical import schema, a worked example, and the `/v1/imports`
    sequence.
servers:
  - url: https://api.develop.fourdos.dev
security:
  - partnerApiKey: []
tags:
  - name: Users
    description: Create, read, and manage users and their org membership
  - name: Imports
    description: Bulk member import jobs (staging → validate → commit)
  - name: API keys
    description: Issue, list, and revoke server-side organization API keys
  - name: Modules
    description: >-
      Publish private modules, install visible modules, and manage their
      credentials
  - name: Ingest
    description: Receive signed native events from an installed module
  - name: Engagement
    description: Browser event tracking (publishable keys) and tracking-key management
  - name: Revenue
    description: Report sales and refunds for the club's revenue dashboards
  - name: Ad delivery
    description: Fill a club site's ad slots, for anonymous or signed-in fans
  - name: Ad entries
    description: Fans entering a sponsor's draw, reported by the club's backend
paths:
  /v1/revenue:
    post:
      tags:
        - Revenue
      summary: Record sales and refunds
      description: >-
        Server-to-server only: authenticate with an organization API key, never
        from a browser. Amounts are positive integer minor units (1999 is
        $19.99) with an ISO 4217 currency; a refund is `type: "refund"` with a
        positive amount. Each event is idempotent on `event_id`: resending it
        with the same money is reported as `duplicate`, resending it with
        different money is `rejected`. Totals in the console only include events
        in the club's reporting currency. Revenue reported here does not award
        XP.
      operationId: recordRevenueEvents
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RevenueBatchBody'
      responses:
        '202':
          description: Per-event outcomes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RevenueResponse'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: The credential is not an organization API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Revenue rate limit exceeded for this key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - partnerApiKey: []
components:
  schemas:
    RevenueBatchBody:
      type: object
      properties:
        events:
          minItems: 1
          maxItems: 100
          type: array
          items:
            type: object
            properties:
              event_id:
                type: string
                minLength: 1
                maxLength: 128
              type:
                default: sale
                type: string
                enum:
                  - sale
                  - refund
              amount_minor:
                type: integer
                exclusiveMinimum: 0
                maximum: 9007199254740991
              currency:
                type: string
                pattern: ^[A-Z]{3}$
              category:
                default: other
                type: string
                pattern: ^[a-z0-9][a-z0-9_-]{0,47}$
              product_name:
                type: string
                minLength: 1
                maxLength: 200
              order_ref:
                type: string
                minLength: 1
                maxLength: 128
              member_external_id:
                type: string
                minLength: 1
                maxLength: 256
              user_id:
                type: string
                format: uuid
                pattern: >-
                  ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
              occurred_at:
                type: string
                format: date-time
                pattern: >-
                  ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
            required:
              - event_id
              - amount_minor
              - currency
              - occurred_at
      required:
        - events
    RevenueResponse:
      type: object
      properties:
        results:
          type: array
          items:
            type: object
            properties:
              event_id:
                type: string
                description: The event_id you sent, echoed back
              status:
                type: string
                enum:
                  - accepted
                  - duplicate
                  - rejected
              id:
                type: string
                description: Stored revenue event id (accepted or duplicate)
              reason:
                type: string
                enum:
                  - idempotency_conflict
                description: >-
                  The event_id was already used with a different type, amount or
                  currency
            required:
              - event_id
              - status
      required:
        - results
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            status:
              type: integer
            message:
              type: string
            details:
              type: object
              additionalProperties: true
          required:
            - code
            - status
            - message
      required:
        - error
  securitySchemes:
    partnerApiKey:
      type: http
      scheme: bearer
      description: >-
        Organization API key (`org_...`) sent as `Authorization: Bearer <key>`.
        Keys are scoped to one organization; every request operates within that
        tenant.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.