> ## 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 a referral link

> Requires `write` (or `*`) scope. The affiliate must belong to the key's workspace.



## OpenAPI

````yaml /openapi.yaml post /v1/links
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/links:
    post:
      tags:
        - Links
      summary: Create a referral link
      description: >-
        Requires `write` (or `*`) scope. The affiliate must belong to the key's
        workspace.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - affiliate_id
              properties:
                affiliate_id:
                  type: string
                  format: uuid
                destination_url:
                  type: string
                  format: uri
                  example: https://shop.example.com/pricing
                ref_param:
                  type: string
                  example: jane
                campaign_id:
                  type: string
                  format: uuid
      responses:
        '201':
          description: Link created
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    example: link
                  data:
                    $ref: '#/components/schemas/Link'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/InsufficientScope'
        '404':
          $ref: '#/components/responses/NotFound'
      security:
        - WorkspaceKey: []
components:
  schemas:
    Link:
      type: object
      properties:
        id:
          type: string
          format: uuid
        affiliate_id:
          type: string
          format: uuid
        ref_param:
          type: string
          nullable: true
        destination_url:
          type: string
          format: uri
          nullable: true
        campaign_id:
          type: string
          format: uuid
          nullable: true
        domain_id:
          type: string
          format: uuid
          nullable: true
        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
    NotFound:
      description: Resource not found / not in workspace
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: link_not_found
  securitySchemes:
    WorkspaceKey:
      type: http
      scheme: bearer
      description: 'Workspace API key, e.g. `sa_live_…`. Scopes: read / write / track / *.'

````