openapi: 3.0.3
info:
  title: Everflow Network API - Business Units
  description: >
    Endpoints for managing business units in the Everflow network. Business
    units are an administrative tool for organization-wide structure — they
    categorize your network's internal departments or regions (e.g. Sales,
    Finance, APAC Team), enabling team assignment and filtered reporting.
    For setup details, see the [Segmentation guide](https://helpdesk.everflow.io/customer/offer-labels-categories-segmentation-options).
  version: 1.0.0
servers:
  - url: https://api.eflow.team/v1
tags:
  - name: Business Units
paths:
  /networks/businessunits:
    get:
      summary: List Business Units
      description: >
        Retrieve all business units for the network.
      tags:
        - Business Units
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                type: object
                properties:
                  units:
                    type: array
                    description: List of business units.
                    items:
                      $ref: "#/components/schemas/BusinessUnit"
              example:
                units:
                  - network_business_unit_id: 1
                    network_id: 1
                    name: "test business unit"
                    time_created: 1774712393
                    time_saved: 1774712393
      security:
        - API Key: []
    post:
      summary: Create Business Unit
      description: >
        Create a new business unit. Required field is `name`.
      tags:
        - Business Units
      requestBody:
        required: true
        content:
          application/json:
            example:
              name: "Manufacturing"
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  description: Name of the business unit.
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BusinessUnit"
              example:
                network_business_unit_id: 1
                network_id: 1
                name: "Manufacturing"
                time_created: 1774712393
                time_saved: 1774712393
      security:
        - API Key: []
  /networks/businessunits/{businessUnitId}:
    get:
      summary: Get Business Unit by ID
      description: >
        Retrieve a single business unit by its ID.
      tags:
        - Business Units
      parameters:
        - in: path
          name: businessUnitId
          required: true
          schema:
            type: integer
          description: The ID of the business unit.
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BusinessUnit"
              example:
                network_business_unit_id: 1
                network_id: 1
                name: "test business unit"
                time_created: 1774712393
                time_saved: 1774712393
      security:
        - API Key: []
    put:
      summary: Update Business Unit
      description: >
        Update an existing business unit. Required field is `name`.
      tags:
        - Business Units
      parameters:
        - in: path
          name: businessUnitId
          required: true
          schema:
            type: integer
          description: The ID of the business unit to update.
      requestBody:
        required: true
        content:
          application/json:
            example:
              name: "Marketing"
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  description: Name of the business unit.
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BusinessUnit"
              example:
                network_business_unit_id: 1
                network_id: 1
                name: "Marketing"
                time_created: 1774712393
                time_saved: 1774712448
      security:
        - API Key: []
components:
  schemas:
    BusinessUnit:
      type: object
      description: A business unit in the network.
      properties:
        network_business_unit_id:
          type: integer
          description: Unique business unit ID.
        network_id:
          type: integer
          description: Network ID.
        name:
          type: string
          description: Name of the business unit.
        time_created:
          type: integer
          example: 1734455015
          description: Unix timestamp of creation.
        time_saved:
          type: integer
          example: 1734455015
          description: Unix timestamp of last update.
  securitySchemes:
    API Key:
      description: The Everflow API key generated from the Control Center > Security.
      in: header
      name: X-Eflow-Api-Key
      type: apiKey
