openapi: 3.0.3
info:
  title: Everflow Network API - Affiliate Tiers
  description: >
    Endpoints for managing affiliate (partner) tiers in the Everflow network.
    Partner tiers automatically calculate partner payouts based on defined
    margin goals, streamlining payment management and offer approvals across
    different partner performance levels. For configuration, see the
    [Partner Tiers guide](https://helpdesk.everflow.io/customer/partner-tiers-automated-margins).
  version: 1.0.0
servers:
  - url: https://api.eflow.team/v1
tags:
  - name: Affiliate Tiers
paths:
  /networks/affiliatetiers:
    get:
      summary: List Affiliate Tiers
      tags:
        - Affiliate Tiers
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                tiers:
                  - network_affiliate_tier_id: 2
                    network_id: 1
                    name: "Gold10"
                    status: "active"
                    description: "Top performing partners"
                    network_affiliate_ids: [14, 21, 35]
                    payout_margin: 10
                    is_default_tier: false
                    time_created: 1774620705
                    time_saved: 1774620705
              schema:
                type: object
                properties:
                  tiers:
                    type: array
                    description: List of affiliate tiers.
                    items:
                      $ref: "#/components/schemas/AffiliateTier"
      security:
        - API Key: []
    post:
      summary: Create Affiliate Tier
      tags:
        - Affiliate Tiers
      requestBody:
        required: true
        content:
          application/json:
            example:
              name: "Gold10"
              status: "active"
              description: "Top performing partners"
              network_affiliate_ids: [14, 21, 35]
              payout_margin: 10
              is_default_tier: false
              labels: ["gold", "premium"]
            schema:
              type: object
              required:
                - name
                - status
                - payout_margin
                - is_default_tier
              properties:
                name:
                  type: string
                  description: The name of the affiliate tier.
                status:
                  type: string
                  enum:
                    - active
                    - paused
                    - deleted
                  description: Status of the affiliate tier. Can be one of the following values - active, paused or deleted.
                description:
                  type: string
                  description: Optional description of the affiliate tier.
                network_affiliate_ids:
                  type: array
                  nullable: true
                  items:
                    type: integer
                  description: IDs of the affiliates to assign to this tier.
                payout_margin:
                  type: number
                  description: The payout margin percentage applied to affiliates in this tier.
                is_default_tier:
                  type: boolean
                  description: Whether or not the affiliate tier will be automatically tied to all new partners.
                labels:
                  type: array
                  items:
                    type: string
                  description: List of labels to associate with the affiliate tier.
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                network_affiliate_tier_id: 2
                network_id: 1
                name: "Gold10"
                status: "active"
                description: "Top performing partners"
                network_affiliate_ids: [14, 21, 35]
                payout_margin: 10
                is_default_tier: false
                time_created: 1774620705
                time_saved: 1774620705
              schema:
                $ref: "#/components/schemas/AffiliateTier"
      security:
        - API Key: []
  /networks/affiliatetiers/{affiliateTierId}:
    get:
      summary: Get Affiliate Tier
      description: >
        Retrieve a single affiliate tier by its ID.
      tags:
        - Affiliate Tiers
      parameters:
        - in: path
          name: affiliateTierId
          required: true
          schema:
            type: integer
          description: The ID of the affiliate tier you want to fetch.
        - in: query
          name: relationship
          schema:
            type: string
            enum:
              - all
          description: >
            Include additional relationship data in the response. Use `all`
            to include all available relationships (e.g. labels).
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                network_affiliate_tier_id: 1
                network_id: 1
                name: "Updated Tier"
                status: "active"
                description: "Updated description"
                network_affiliate_ids: null
                payout_margin: 25
                is_default_tier: true
                time_created: 1774620660
                time_saved: 1774620995
                relationship:
                  labels:
                    total: 1
                    entries:
                      - "updated-label"
              schema:
                $ref: "#/components/schemas/AffiliateTier"
        "404":
          description: Affiliate tier not found.
      security:
        - API Key: []
    put:
      summary: Update Affiliate Tier
      tags:
        - Affiliate Tiers
      parameters:
        - in: path
          name: affiliateTierId
          required: true
          schema:
            type: integer
          description: The ID of the affiliate tier you want to update.
      requestBody:
        required: true
        content:
          application/json:
            example:
              name: "Platinum10"
              status: "active"
              description: "Example tier"
              network_affiliate_ids: [1]
              payout_margin: 10
              is_default_tier: false
              labels: ["platinum", "premium"]
            schema:
              type: object
              required:
                - name
                - status
                - payout_margin
                - is_default_tier
              properties:
                name:
                  type: string
                  description: The name of the affiliate tier.
                status:
                  type: string
                  enum:
                    - active
                    - paused
                    - deleted
                  description: Status of the affiliate tier. Can be one of the following values - active, paused or deleted.
                description:
                  type: string
                  description: Optional description of the affiliate tier.
                network_affiliate_ids:
                  type: array
                  nullable: true
                  items:
                    type: integer
                  description: IDs of the affiliates to assign to this tier.
                payout_margin:
                  type: number
                  description: The payout margin percentage applied to affiliates in this tier.
                is_default_tier:
                  type: boolean
                  description: Whether or not the affiliate tier will be automatically tied to all new partners.
                labels:
                  type: array
                  items:
                    type: string
                  description: List of labels to associate with the affiliate tier.
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                network_affiliate_tier_id: 1
                network_id: 1
                name: "Platinum10"
                status: "active"
                description: "Example tier"
                network_affiliate_ids: [1]
                payout_margin: 10
                is_default_tier: false
                time_created: 1774620660
                time_saved: 1774620995
              schema:
                $ref: "#/components/schemas/AffiliateTier"
        "404":
          description: Affiliate tier not found.
      security:
        - API Key: []
  /networks/affiliatetiers/{affiliateTierId}/bulk:
    post:
      summary: Bulk Update Affiliate Tiers
      tags:
        - Affiliate Tiers
      parameters:
        - in: path
          name: affiliateTierId
          required: true
          schema:
            type: integer
          description: The ID of the affiliate tier.
      requestBody:
        required: true
        content:
          application/json:
            example:
              assignments:
                - network_affiliate_id: 1
                  network_affiliate_tier_id: 5
                - network_affiliate_id: 2
                  network_affiliate_tier_id: 5
            schema:
              type: object
              properties:
                assignments:
                  type: array
                  description: List of affiliate-to-tier assignments to apply.
                  items:
                    type: object
                    properties:
                      network_affiliate_id:
                        type: integer
                        description: The affiliate ID to update.
                      network_affiliate_tier_id:
                        type: integer
                        description: The tier ID to assign.
      responses:
        "200":
          description: Tier assignments updated successfully.
      security:
        - API Key: []
components:
  schemas:
    AffiliateTier:
      type: object
      properties:
        network_affiliate_tier_id:
          type: integer
          description: The unique ID of the affiliate tier.
        network_id:
          type: integer
          description: The ID of the network this tier belongs to.
        name:
          type: string
          description: The name of the affiliate tier.
        status:
          type: string
          enum:
            - active
            - paused
            - deleted
          description: Status of the affiliate tier. Can be one of the following values - active, paused or deleted.
        description:
          type: string
          description: Optional description of the affiliate tier.
        network_affiliate_ids:
          type: array
          nullable: true
          items:
            type: integer
          description: IDs of the affiliates assigned to this tier.
        payout_margin:
          type: number
          description: The affiliate's payout margin.
        is_default_tier:
          type: boolean
          description: Whether or not the affiliate tier will be automatically tied to all new partners.
        time_created:
          type: integer
          example: 1734455015
          description: Unix timestamp of creation.
        time_saved:
          type: integer
          example: 1734455015
          description: Unix timestamp of last update.
        relationship:
          type: object
          description: >
            Related data for this affiliate tier. Populate by passing the
            `relationship` query parameter (e.g. `?relationship=all`).
          properties:
            labels:
              type: object
              description: Labels associated with the affiliate tier.
              properties:
                total:
                  type: integer
                  description: Total number of labels.
                entries:
                  type: array
                  nullable: true
                  description: List of label strings.
                  items:
                    type: string
            affiliates:
              type: object
              description: Affiliates assigned to this tier. Included when using `relationship=all`.
              properties:
                total:
                  type: integer
                  description: Total number of affiliates in this tier.
                entries:
                  type: array
                  nullable: true
                  description: List of affiliate objects.
                  items:
                    type: object
  securitySchemes:
    API Key:
      description: The Everflow API key generated from the Control Center > Security.
      in: header
      name: X-Eflow-Api-Key
      type: apiKey
