openapi: 3.1.0
info:
  title: 'Forward Networks: Network Collection API'
  summary: Configure configuration and state collection from network devices
  description: |-
    Use these resources to query the state of a network’s Collector, to trigger a collection of configuration and state
    from a network’s devices, to define collection schedules, or to cancel an in-progress collection.
  contact:
    email: support@forwardnetworks.com
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
  version: ${apiVersion}
servers:
  - url: /api
security:
  - api_token: []
tags:
  - name: Network Collection
    description: Configure configuration and state collection from network devices
paths:
  /collector-tasks:
    post:
      tags:
        - Network Collection
      summary: Add a collector task
      description: |-
        Signals the system to begin collecting a new network Snapshot as soon as a Collector is available. Use [Get a
        collector task](https://docs.fwd.app/latest/api/network-collection/get-collector-task/) to check a task’s
        status.

        A network can have only one network collection task running at a time.
      operationId: addCollectorTask
      parameters:
        - name: networkId
          in: query
          required: true
          schema:
            type: string
        - name: type
          in: query
          required: true
          schema:
            type: string
            const: NETWORK_COLLECTION
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StartCollectionResponse'
  /collector-tasks/{taskId}:
    get:
      tags:
        - Network Collection
      summary: Get a collector task
      description: |-
        Get information about a recent collector task. Use
        [Add a collector task](https://docs.fwd.app/latest/api/network-collection/add-collector-task/) to create a task.
      operationId: getCollectorTask
      parameters:
        - name: taskId
          in: path
          description: The identifier of the collector task to retrieve
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectorTask'
  /networks/{networkId}/cancelcollection:
    post:
      tags:
        - Network Collection
      summary: Cancel an in-progress network collection
      operationId: cancelCollect
      parameters:
        - name: networkId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
  /networks/{networkId}/collection-schedules:
    get:
      tags:
        - Network Collection
      summary: Get a network’s collection schedules
      operationId: getCollectionSchedules
      parameters:
        - name: networkId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectionSchedules'
    post:
      tags:
        - Network Collection
      summary: Add a network collection schedule
      operationId: addCollectionSchedule
      parameters:
        - name: networkId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CollectionScheduleDefinition'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectionSchedule'
  /networks/{networkId}/collection-schedules/{scheduleId}:
    get:
      tags:
        - Network Collection
      summary: Get a network collection schedule
      operationId: getCollectionSchedule
      parameters:
        - name: networkId
          in: path
          required: true
          schema:
            type: string
        - name: scheduleId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectionSchedule'
    put:
      tags:
        - Network Collection
      summary: Replace a network collection schedule
      operationId: replaceCollectionSchedule
      parameters:
        - name: networkId
          in: path
          required: true
          schema:
            type: string
        - name: scheduleId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CollectionSchedule'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
    delete:
      tags:
        - Network Collection
      summary: Delete a network collection schedule
      operationId: deleteCollectionSchedule
      parameters:
        - name: networkId
          in: path
          required: true
          schema:
            type: string
        - name: scheduleId
          in: path
          required: true
          schema:
            type: string
      responses:
        '204':
          description: No Content
          content: {}
  /networks/{networkId}/collector/status:
    get:
      tags:
        - Network Collection
      summary: Get the status of a network’s collector
      description: |-
        **Deprecated for removal in release 26.6.** Use [Get a collector
        task](https://docs.fwd.app/latest/api/network-collection/get-collector-task/) instead to check the status of
        a task.
      operationId: getCollectorState
      parameters:
        - name: networkId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectorState'
      deprecated: true
  /networks/{networkId}/startcollection:
    post:
      tags:
        - Network Collection
      summary: Trigger a network collection
      description: |-
        **Deprecated for removal in release 26.6.** Use
        [Add a collector task](https://docs.fwd.app/latest/api/network-collection/add-collector-task/) instead.
      operationId: collect
      parameters:
        - name: networkId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
      deprecated: true
components:
  schemas:
    CollectionSchedule:
      allOf:
        - type: object
          required:
            - id
          properties:
            id:
              type: string
              description: Network-specific collection schedule identifier
              examples:
                - '1'
        - $ref: '#/components/schemas/CollectionScheduleDefinition'
    CollectionScheduleDefinition:
      type: object
      required:
        - enabled
        - daysOfTheWeek
      properties:
        enabled:
          type: boolean
          description: Whether the schedule is currently in effect
          examples:
            - true
        timeZone:
          $ref: '#/components/schemas/TimeZone'
          description: |-
            The time zone used to identify day boundaries and to interpret `times`, `startAt`, and `endAt`. Defaults to
            the organization’s preferred time zone.
          examples:
            - America/Los_Angeles
        daysOfTheWeek:
          type: array
          items:
            type: integer
            format: int32
          description: |-
            The days of the week, Sun (0), Mon (1), …, Sat (6), on which the collection schedule is active.
            Never empty.
          examples:
            - - 0
              - 2
              - 4
              - 6
        times:
          type: array
          items:
            type: string
          description: |-
            Times of the day (in "HH:mm" format) at which network collections should start. Either `times` or
            `periodInSeconds` must be specified—not both. Never empty if present.
          examples:
            - - '01:00'
              - '06:00'
              - '11:00'
              - '16:00'
              - '21:00'
        periodInSeconds:
          type: integer
          format: int32
          description: |-
            How many seconds after the start of the most recent collection that the next one should begin. Either
            `times` or `periodInSeconds` must be specified—not both. Must be positive.

            **Note**: A Collector can only perform one network collection at a time. A scheduled collection will be
            delayed if it cannot start on time due to an earlier collection running long.
          examples:
            - 1800
        startAt:
          type: string
          description: |-
            The time of day (in "HH:mm" format) at which a rate-based collection schedule begins. Must be absent if
            `times` is specified. Defaults to the start of the day (00:00).
          examples:
            - '05:30'
        endAt:
          type: string
          description: |-
            The time of day (in "HH:mm" format) at which a rate-based collection schedule ends. Must be absent if
            `times` is specified. Defaults to the end of the day.
          examples:
            - '20:00'
    CollectionSchedules:
      type: object
      properties:
        schedules:
          type: array
          items:
            $ref: '#/components/schemas/CollectionSchedule'
    CollectorState:
      type: object
      required:
        - isSet
      properties:
        isSet:
          type: boolean
          description: Whether the network has a Collector assigned
        busyStatus:
          $ref: '#/components/schemas/CollectorStatus'
          description: Absent if the network has no Collector assigned
    CollectorTask:
      type: object
      properties:
        id:
          type: string
          description: System-assigned identifier of this task.
          examples:
            - P1234
        type:
          type: string
          description: The type of the task
          examples:
            - NETWORK_COLLECTION
        status:
          type: string
          description: The current status of the task.
          examples:
            - SUCCEEDED
          enum:
            - QUEUED
            - RUNNING
            - SUCCEEDED
            - FAILED
            - TIMED_OUT
            - CANCELED
        networkId:
          type: string
          description: The ID of the network this task is associated with
          examples:
            - '123'
        networkName:
          type: string
          description: The name of the network this task is associated with
          examples:
            - My Network
        note:
          type: string
          description: An optional user-provided note about the task.
        createdById:
          type: string
          description: |-
            The ID of the user who created this entity, if known. *Note*: The referenced user account might no longer
            exist since an administrator can delete accounts.
          examples:
            - '456'
        createdBy:
          type: string
          description: |-
            The ID of the user who created this entity, if known. *Note*: The referenced user account might no longer
            exist since an administrator can delete accounts.
          examples:
            - '456'
        createdAt:
          type: string
          description: When this entity was created, if known.
          examples:
            - '2024-10-27T16:30:45.111Z'
        startedAt:
          type: string
          description: When this task started. Absent if the task hasn’t started yet.
          examples:
            - '2024-10-27T21:44:51.345Z'
        finishedAt:
          type: string
          description: When this task finished. Absent if the task hasn’t finished yet.
          examples:
            - '2024-10-28T00:41:31.123Z'
        canceledById:
          type: string
          description: The ID of the user who canceled this task, if the `status` is CANCELED.
          examples:
            - '456'
        canceledBy:
          type: string
          description: |-
            The username of the user who canceled this task, if the `status` is CANCELED. Absent if the user account has
            been deleted.
          examples:
            - me@example.com
    StartCollectionResponse:
      type: object
      properties:
        taskId:
          type: string
          description: The system-assigned identifier of the new network collection task.
          examples:
            - P1234
    TimeZone:
      type: string
      enum:
        - UTC
        - Africa/Accra
        - Africa/Addis_Ababa
        - Africa/Algiers
        - Africa/Cairo
        - Africa/Dar_es_Salaam
        - Africa/Johannesburg
        - Africa/Khartoum
        - Africa/Kinshasa
        - Africa/Lagos
        - Africa/Luanda
        - Africa/Maputo
        - America/Argentina/Buenos_Aires
        - America/Bogota
        - America/Chicago
        - America/Denver
        - America/Lima
        - America/Los_Angeles
        - America/Mexico_City
        - America/New_York
        - America/Phoenix
        - America/Santiago
        - America/Sao_Paulo
        - America/Toronto
        - Asia/Amman
        - Asia/Baghdad
        - Asia/Bangkok
        - Asia/Beirut
        - Asia/Dhaka
        - Asia/Ho_Chi_Minh
        - Asia/Hong_Kong
        - Asia/Jakarta
        - Asia/Jerusalem
        - Asia/Karachi
        - Asia/Kolkata
        - Asia/Kuala_Lumpur
        - Asia/Manila
        - Asia/Riyadh
        - Asia/Seoul
        - Asia/Shanghai
        - Asia/Singapore
        - Asia/Tehran
        - Asia/Tokyo
        - Asia/Yangon
        - Australia/Adelaide
        - Australia/Eucla
        - Australia/Perth
        - Australia/Sydney
        - Europe/Belgrade
        - Europe/Berlin
        - Europe/Istanbul
        - Europe/London
        - Europe/Madrid
        - Europe/Moscow
        - Europe/Paris
        - Europe/Rome
    CollectorStatus:
      type: string
      enum:
        - OFFLINE
        - IDLE
        - TESTING
        - COLLECTING
        - COLLECTION_QUEUED
        - DISCOVERING
        - UPDATING
  securitySchemes:
    api_token:
      type: http
      scheme: basic
