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

> Requires `write` (or `*`) scope.



## OpenAPI

````yaml /openapi.yaml post /v1/campaigns
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.

    All requests authenticate with a workspace key (`sa_live_…`) as a Bearer
    token. Scopes: `read` / `write` / `track` / `*`.

    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: Campaigns
    description: Create and configure campaigns + commission rules (workspace key)
  - name: Links
    description: Manage referral links (workspace key)
  - name: Risk
    description: AI risk assessments for fraud triage (workspace key)
  - name: Commissions
    description: Approve, deny, and manage commissions (workspace key)
  - name: Conversions
    description: Re-attribute and manage conversions (workspace key)
  - name: Webhooks
    description: Manage webhook endpoint subscriptions (workspace key)
  - name: Reports
    description: Aggregated reporting data (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")
paths:
  /v1/campaigns:
    post:
      tags:
        - Campaigns
      summary: Create a campaign
      description: Requires `write` (or `*`) scope.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                cookie_window_days:
                  type: integer
                  default: 60
                  minimum: 1
                attribution_model:
                  type: string
                  enum:
                    - last_click
                    - first_click
                  default: last_click
                status:
                  type: string
                  enum:
                    - active
                    - paused
                    - archived
                  default: active
                destination_url:
                  type: string
                  description: >-
                    Where referral links land (https). The dashboard requires
                    this before a campaign can go live - API-created campaigns
                    without it produce links with no landing page.
                additional_referral_links:
                  type: array
                  items:
                    type: string
                ref_param:
                  type: string
                  description: Referral-link query parameter (e.g. via, ref, aff).
      responses:
        '201':
          description: Created campaign
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    example: campaign
                  data:
                    $ref: '#/components/schemas/Campaign'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/InsufficientScope'
      security:
        - WorkspaceKey: []
components:
  schemas:
    Campaign:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        status:
          type: string
          example: active
        cookie_window_days:
          type: integer
          example: 60
        attribution_model:
          type: string
          enum:
            - last_click
            - first_click
        destination_url:
          type: string
          description: >-
            Where referral links land. The dashboard requires this before a
            campaign can go live.
        additional_referral_links:
          type: array
          items:
            type: string
          description: Extra landing URLs affiliates can generate links for.
        ref_param:
          type: string
          description: Query parameter used on referral links (e.g. via, ref, aff).
        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
  securitySchemes:
    WorkspaceKey:
      type: http
      scheme: bearer
      description: 'Workspace API key, e.g. `sa_live_…`. Scopes: read / write / track / *.'

````