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

# Attribute a referral code

> Records first-touch referral attribution for the authenticated user. Idempotent; self-referral and invalid codes are rejected. Requires SIWE bearer auth.



## OpenAPI

````yaml /api-spec/openapi.yaml post /referral/attribution
openapi: 3.0.3
info:
  title: United Market API
  version: 1.0.0
  description: >-
    Public backend API for market data, trading, authentication, profiles,
    comments, and leaderboards.
servers:
  - url: https://api.unitedmarket.ai
    description: United Market backend
security: []
tags:
  - name: Markets
    description: >-
      Market discovery, market details, orderbooks, tickers, price history, and
      trades.
  - name: Orders
    description: Signed order submission, cancellation, order lookup, and balances.
  - name: Authentication
    description: SIWE wallet authentication.
  - name: Discovery
    description: Tags and market groups.
  - name: Social
    description: Comments, users, and leaderboard data.
  - name: Fees
    description: Effective trading fee rate per market.
  - name: Referral
    description: Referral codes, attribution, and reward summaries.
paths:
  /referral/attribution:
    post:
      tags:
        - Referral
      summary: Attribute a referral code
      description: >-
        Records first-touch referral attribution for the authenticated user.
        Idempotent; self-referral and invalid codes are rejected. Requires SIWE
        bearer auth.
      operationId: createReferralAttribution
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReferralAttributionRequest'
      responses:
        '200':
          description: Attribution recorded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReferralAttribution'
        '400':
          $ref: '#/components/responses/BadRequest'
      security:
        - bearerAuth: []
components:
  schemas:
    ReferralAttributionRequest:
      type: object
      required:
        - code
      properties:
        code:
          type: string
          maxLength: 32
          description: Referral code to attribute the authenticated user to.
          example: UM-7ZAFAB8F
    ReferralAttribution:
      type: object
      properties:
        ok:
          type: boolean
        changed:
          type: boolean
          description: >-
            True when this call set the referrer (first touch); false when
            already attributed.
        referredBy:
          type: string
          description: Wallet address of the referrer.
    Error:
      type: object
      properties:
        message:
          type: string
        statusCode:
          type: integer
  responses:
    BadRequest:
      description: Invalid request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: SIWE access token returned by POST /auth/verify.

````