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

# Create a transaction

> Records a customer's activity, such as a deposit, revenue or wagering, so commission can be
calculated for the affiliate who referred them. The transaction is queued and processed in
the background, so a `202` response means it was accepted, not that commission was created.
            
Identify the customer with `externalCustomerId` (the ID you used when you created the
customer) or with `clickKey`. A `Sale` needs an `externalId` of 1 to 100 characters. Sending
the same `externalId` again for the same brand doesn't create a duplicate.
            
To credit or debit an affiliate directly, send an `Adjustment` with `affiliateId` and one of
`revShareCommission`, `cpaCommission` or `fixedCommission`. Adjustments can't carry deposit,
revenue or wagering amounts, and other types can't carry commission amounts.



## OpenAPI

````yaml https://platform.affelios.com/swagger/v1/swagger.json post /api/v1/transaction
openapi: 3.0.4
info:
  title: Affelios Platform API
  description: >-
    Send customers and transactions to Affelios, and read your affiliate
    program's data. Authenticate every request with an API key in the X-Api-Key
    header. Create keys in the dashboard under Settings > API keys.
  version: v1
servers:
  - url: https://platform.affelios.com
security:
  - ApiKey: []
tags:
  - name: Affiliates
    description: >-
      Affiliate accounts in your program, their collaborators and their
      commission plan assignments.
  - name: Customers
    description: >-
      Customers referred by affiliates. Create a customer with the click key
      from the landing page to credit the affiliate who referred them.
  - name: Mcp Connection
  - name: Testimonials
    description: Affiliate testimonials and the published list shown on public pages.
  - name: Transactions
    description: >-
      Customer activity such as deposits, revenue and wagering. Commission is
      calculated from transactions.
paths:
  /api/v1/transaction:
    post:
      tags:
        - Transactions
      summary: Create a transaction
      description: >-
        Records a customer's activity, such as a deposit, revenue or wagering,
        so commission can be

        calculated for the affiliate who referred them. The transaction is
        queued and processed in

        the background, so a `202` response means it was accepted, not that
        commission was created.
                    
        Identify the customer with `externalCustomerId` (the ID you used when
        you created the

        customer) or with `clickKey`. A `Sale` needs an `externalId` of 1 to 100
        characters. Sending

        the same `externalId` again for the same brand doesn't create a
        duplicate.
                    
        To credit or debit an affiliate directly, send an `Adjustment` with
        `affiliateId` and one of

        `revShareCommission`, `cpaCommission` or `fixedCommission`. Adjustments
        can't carry deposit,

        revenue or wagering amounts, and other types can't carry commission
        amounts.
      operationId: TransactionPost
      requestBody:
        description: The transaction to create.
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/TransactionBody'
              description: >-
                A customer transaction, or an adjustment to an affiliate's
                commission.
      responses:
        '202':
          description: The transaction was queued for processing.
        '400':
          description: The transaction failed validation. The response body says why.
        '401':
          description: The X-Api-Key header is missing or the key is not valid.
        '403':
          description: The API key is valid but does not have permission for this endpoint.
components:
  schemas:
    TransactionBody:
      type: object
      properties:
        externalId:
          type: string
          description: >-
            Your unique ID for the transaction. Required for a single `Sale`;
            optional in bulk requests.
          nullable: true
        type:
          type: string
          description: >-
            One of `Sale`, `Adjustment`, `Payout` or `SubAffiliate`. Use `Sale`
            for customer activity and `Adjustment` to change an affiliate's
            commission directly.
          nullable: true
        affiliateId:
          type: string
          description: The Affelios ID of the affiliate. Used by `Adjustment` transactions.
          nullable: true
        clickKey:
          type: string
          description: >-
            The click key the customer arrived with. Use this or
            `externalCustomerId` to identify the customer.
          nullable: true
        externalCustomerId:
          type: string
          description: >-
            Your ID for the customer, as sent when you created them. Use this or
            `clickKey`.
          nullable: true
        externalBrandId:
          type: string
          description: The External ID of the brand, as set on the brand in Affelios.
          nullable: true
        externalProductId:
          type: string
          description: The External ID of the product, if the transaction belongs to one.
          nullable: true
        transactionDate:
          type: string
          description: When the activity happened, in UTC.
          format: date-time
        country:
          type: string
          description: The customer's country name.
          nullable: true
        country_code:
          type: string
          description: The customer's country as an ISO country code, for example `GB`.
          nullable: true
        depositAmount:
          type: number
          description: Amount deposited.
          format: double
        grossRevenue:
          type: number
          description: >-
            Gross revenue, such as gross gaming revenue or the sale value. Can
            be negative.
          format: double
        wageredAmount:
          type: number
          description: Amount wagered (turnover).
          format: double
        revShareCommission:
          type: number
          description: Revenue share commission to add or remove. `Adjustment` only.
          format: double
        cpaCommission:
          type: number
          description: CPA commission to add or remove. `Adjustment` only.
          format: double
        fixedCommission:
          type: number
          description: Fixed commission to add or remove. `Adjustment` only.
          format: double
        category:
          type: string
          description: A category for your own reporting.
          nullable: true
        label:
          type: string
          description: A label for your own reporting.
          nullable: true
        note:
          type: string
          description: A note, for example the reason for an adjustment.
          nullable: true
        operatorId:
          type: string
          description: >-
            Not needed when you authenticate with an API key: your program is
            taken from the key.
          nullable: true
      additionalProperties: false
      description: A customer transaction, or an adjustment to an affiliate's commission.
  securitySchemes:
    ApiKey:
      type: apiKey
      description: >-
        Your Affelios API key. Create one in the dashboard under Settings > API
        keys.
      name: X-Api-Key
      in: header

````

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