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

# Track a sale

> Server-to-server sale conversion. Requires `track` (or `*`) scope.
Idempotent on `external_id`.




## OpenAPI

````yaml /openapi.yaml post /v1/track/sale
openapi: 3.1.0
info:
  title: Affixo API
  version: 1.0.0
  description: |
    The Affixo REST API for affiliate program management and server-to-server
    conversion tracking.

    There are two families of bearer tokens:

    - **Workspace keys** (`sa_live_…`) — full program access, scoped by
      `read` / `write` / `track`. Used for the management and tracking endpoints.
    - **Affiliate keys** (`refa_live_…`) — read-only, return **only the calling
      affiliate's own data**. Used for the `/v1/affiliate/*` endpoints.

    Tokens are sent as `Authorization: Bearer <token>`. Rate limit: 600 req/min
    per key (enforced at the edge).
servers:
  - url: https://go.affixo.dev
    description: Production
security: []
tags:
  - name: Affiliates
    description: Manage affiliates (workspace key)
  - name: Links
    description: Manage referral links (workspace key)
  - name: Resources
    description: Read campaigns, commissions, conversions, payouts (workspace key)
  - name: Tracking
    description: >-
      Server-to-server click & conversion tracking (workspace key, scope
      "track")
  - name: Affiliate
    description: Read-only, self-scoped endpoints (affiliate key)
paths:
  /v1/track/sale:
    post:
      tags:
        - Tracking
      summary: Track a sale
      description: |
        Server-to-server sale conversion. Requires `track` (or `*`) scope.
        Idempotent on `external_id`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/ConversionInput'
                - type: object
                  properties:
                    amount:
                      type: number
                      example: 99
                    currency:
                      type: string
                      example: usd
                      default: usd
      responses:
        '200':
          description: Sale processed (attributed or not)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversionResult'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/ServerError'
      security:
        - WorkspaceKey: []
components:
  schemas:
    ConversionInput:
      type: object
      description: >
        Visitor identity plus optional attribution hints. Provide at least one
        of

        `visitor_id`, `fingerprint`, `ref`, or `manual_code` so the event can be

        attributed.
      properties:
        visitor_id:
          type: string
          nullable: true
        fingerprint:
          type: string
          nullable: true
        ref:
          type: string
          nullable: true
          description: Referral code, used to pin the campaign/window.
        manual_code:
          type: string
          nullable: true
          description: Self-attribution code, if enabled.
        external_id:
          type: string
          nullable: true
          description: Idempotency key (order id).
        currency:
          type: string
          example: usd
          default: usd
        is_test:
          type: boolean
          default: false
        url:
          type: string
          format: uri
          nullable: true
        referrer:
          type: string
          nullable: true
    ConversionResult:
      type: object
      properties:
        ok:
          type: boolean
          example: true
        attributed:
          type: boolean
          example: true
        conversion_id:
          type: string
          description: Present when attributed.
        visitor_id:
          type: string
          description: Present when not attributed.
    Error:
      type: object
      properties:
        error:
          type: string
        need:
          type: string
          description: Present on insufficient_scope.
        detail:
          type: string
  responses:
    Unauthorized:
      description: Missing or invalid bearer token
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: unauthorized
    ServerError:
      description: Internal error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: conversion_failed
  securitySchemes:
    WorkspaceKey:
      type: http
      scheme: bearer
      description: 'Workspace API key, e.g. `sa_live_…`. Scopes: read / write / track / *.'

````