> ## 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.

# Create an affiliate

> Requires `write` (or `*`) scope. One of `email` or `name` is required.



## OpenAPI

````yaml /openapi.yaml post /v1/affiliates
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/affiliates:
    post:
      tags:
        - Affiliates
      summary: Create an affiliate
      description: Requires `write` (or `*`) scope. One of `email` or `name` is required.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                  example: promoter@example.com
                name:
                  type: string
                  example: Jane Promoter
                ref_code:
                  type: string
                  description: Optional referral code; auto-generated when omitted.
                  example: jane
      responses:
        '201':
          description: Affiliate created
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    example: affiliate
                  data:
                    $ref: '#/components/schemas/Affiliate'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/InsufficientScope'
        '409':
          $ref: '#/components/responses/Conflict'
      security:
        - WorkspaceKey: []
components:
  schemas:
    Affiliate:
      type: object
      properties:
        id:
          type: string
          format: uuid
        ref_code:
          type: string
          example: jane
        email:
          type: string
          format: email
          nullable: true
        name:
          type: string
          nullable: true
        status:
          type: string
          example: pending
        created_at:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        error:
          type: string
        need:
          type: string
          description: Present on insufficient_scope.
        detail:
          type: string
  responses:
    BadRequest:
      description: Invalid or missing parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: invalid_json
    Unauthorized:
      description: Missing or invalid bearer token
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: unauthorized
    InsufficientScope:
      description: The key lacks the required scope
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: insufficient_scope
            need: write
    Conflict:
      description: Could not create the resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: create_failed
  securitySchemes:
    WorkspaceKey:
      type: http
      scheme: bearer
      description: 'Workspace API key, e.g. `sa_live_…`. Scopes: read / write / track / *.'

````