openapi: 3.0.0
info:
  version: 1.0.0
  title: Print Tracker API
  license:
    name: MIT
servers:
  - url: https://papi.printtrackerpro.com/v1
paths:
  /entity/{entityId}:
    get:
      summary: Get an entity
      description: Returns an entity object for the provided entity ID.
      security:
        - ApiKeyAuth: []
      operationId: getEntity
      tags:
        - Entity
      parameters:
        - name: includeChildren
          in: query
          description: >-
            If enabled, the response will include an array of all child entity
            names and IDs at every hierarchical level under the entity specified
            in the request.
          required: false
          schema:
            type: boolean
            default: false
        - name: entityId
          in: path
          description: The ID of the entity to retrieve.
          required: true
      responses:
        '200':
          description: An entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Entity'
    post:
      summary: Create an entity
      description: >-
        Creates a new entity underneath the entity specified in the path
        parameters.
      security:
        - ApiKeyAuth: []
      tags:
        - Entity
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity to create a child entity under.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: The name of the entity to create
      responses:
        '200':
          description: An entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Entity'
    put:
      summary: Update an entity
      description: >
        Updates the entity name, or entity settings.


        ### Updating Entity Settings

        _Audit logging is not yet supported for settings changed using this
        endpoint._


        Print Tracker supports [dynamic settings
        inheritance](https://docs.printtrackerpro.com/docs/guides/settings#inheriting-settings).
        This means that settings set at a parent entity will be inherited by all
        child entities, installs, and devices unless explicitly overridden. In
        order to be clear about how settings are being changed within the
        context of inheritance, this endpoint allows you to specify an array of
        settings that you want to `set` and an array of setting paths that you
        want to `reset` (remove any explicit value so that the value is
        inherited from the parent).


        The following settings paths are allowed to be set or reset. When
        setting a value, the following table describes the types of values that
        are allowed.


        |<div style="width:230px">Path</div>|Supported Values|

        |--|--|

        |`snmp.version`|One of: `1`, `2`, `3`|

        |`snmp.communities`|Array of strings|

        |`snmp.v3Algorithm`|One of: `MD5`, `SHA`|

        |`snmp.v3Context`|String|

        |`snmp.v3Username`|String|

        |`snmp.v3AuthPassword`|String|

        |`snmp.v3PrivacyPassword`|String|

        |`deviceDiscovery.ipaddress`|An array of IP addresses, ranges, or CIDR
        blocks to scan. May be formatted in any of the following styles,
        10.0.0.1, 10.0.0.1-10, 10.0.0.*, 10.0.0.0/24|

        |`deviceDiscovery.excludeIPAddress`|An array of IP addresses to exclude
        from scanning.|

        |`labels.<key>`|Any label key values can be provided. Both the keys and
        values must be strings.|
      security:
        - ApiKeyAuth: []
      tags:
        - Entity
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity to update.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: New entity name
                  description: The name of the entity to update
                set:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        example: snmp.communities
                      value:
                        type: any
                        description: >-
                          A value matching the supported types for the path (see
                          table above)
                        example:
                          - public
                  example:
                    - path: snmp.communities
                      value:
                        - public
                    - path: snmp.version
                      value: 1
                    - path: deviceDiscovery.ipaddress
                      value:
                        - 10.0.0.1
                        - 10.0.0.5-10
                        - 10.0.1.0/24
                        - 10.0.2.*
                    - path: deviceDiscovery.excludeIPAddress
                      value:
                        - 10.0.0.1
                    - path: snmp.v3Username
                      value: my username
                    - path: snmp.v3AuthPassword
                      value: my authentication password
                    - path: snmp.v3PrivacyPassword
                      value: my privacy password
                    - path: snmp.v3Context
                      value: my context
                    - path: snmp.v3Algorithm
                      value: MD5
                    - path: labels.foo
                      value: bar
                reset:
                  type: array
                  items:
                    type: string
                    description: >-
                      A setting path to reset. You cannot reset a path that is
                      being set in the same request.
                    example: snmp.communities
      responses:
        '200':
          description: An entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Entity'
    delete:
      summary: Delete an entity
      description: Deletes the entity and all of its children.
      security:
        - ApiKeyAuth: []
      tags:
        - Entity
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity to delete.
          required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: 'null'
  /entity/{entityId}/children:
    get:
      summary: Get child entities
      description: >
        Returns a paginated array of child entities under the specified entity.


        By default this endpoint returns only the direct children of the
        specified entity. Pass `includeChildren=true` to walk the entire subtree
        below the entity.


        Dynamic settings inheritance is not resolved per child for performance
        reasons; the `settings` field on each item reflects only explicit
        settings set on that entity. Use `GET /entity/{entityId}` for a single
        entity if you need resolved settings.
      security:
        - ApiKeyAuth: []
      tags:
        - Entity
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity to load children from.
          required: true
          schema:
            type: string
        - name: includeChildren
          in: query
          description: >-
            If true, the response includes every descendant of the entity
            instead of just its direct children.
          required: false
          schema:
            type: boolean
            default: false
        - name: limit
          in: query
          description: >-
            The maximum number of entities to return in a single request.
            Maximum is 50000.
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 50000
            default: 100
        - name: page
          in: query
          description: The page number to return. Page numbers start at 1.
          required: false
          schema:
            type: integer
            default: 1
      responses:
        '200':
          description: An array of child entities
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Entity'
  /entity/{entityId}/device:
    get:
      summary: Get devices by entity
      description: >-
        Returns an array of devices that belong to the specified entity and
        (optionally) its children.
      security:
        - ApiKeyAuth: []
      tags:
        - Devices
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity to load devices from.
          required: true
        - name: includeChildren
          in: query
          description: >-
            If enabled, the response will include devices at this entity, and
            all child entities.
          required: false
          schema:
            type: boolean
            default: false
        - name: limit
          in: query
          description: The maximum number of devices to return in a single request.
          required: false
          schema:
            type: integer
            default: 100
        - name: page
          in: query
          description: The page number to return.  Page numbers start at 1.
          required: false
          schema:
            type: integer
            default: 1
        - name: excludeDisabled
          in: query
          description: If true, only managed devices will be returned.
          required: false
          schema:
            type: boolean
            default: false
        - name: serialNumber
          in: query
          description: A comma-separated list of serial numbers to search
          required: false
          schema:
            type: string
            default: false
            example: SN123,SNABC
      responses:
        '200':
          description: An array of devices
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Device'
    post:
      summary: Create a device
      description: >
        Creates a device under the specified entity. This endpoint can be used
        to create devices in Print Tracker prior to discovering the physical
        devices using a Print Tracker data collection agent. Currently, this
        endpoint only supports creating devices with a smaller subset of the
        fields specified.


        If the device already exists, this endpoint will return the existing
        device. This means that calls to this endpoint are idempotent.


        If a data collection agent discovers a device with the same serial
        number in the future, the device will be updated with the new data. The
        values for properties in the schema below like `make` or `model` do not
        need to be perfect. As long as the serial number matches exactly, once
        the device is discovered by the data collection agent, all other
        properties will be updated.
      security:
        - ApiKeyAuth: []
      tags:
        - Devices
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity to load devices from.
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: array
              items:
                type: object
                properties:
                  make:
                    type: string
                    required: true
                    example: HP
                    description: |
                      The device's manufacturer, e.g. "HP", "Brother", "Canon".
                  model:
                    type: string
                    required: true
                    example: LaserJet M477fdw
                    description: |
                      The device's model, e.g. "LaserJet 4000", "HL-L2340DW".
                  serialNumber:
                    type: string
                    required: true
                    example: SN12345
                  customSerialNumber:
                    type: string
                    required: false
                    example: CUSTOM-SN12345
                  ipAddress:
                    type: string
                    required: false
                    example: 10.0.0.10
                  macAddress:
                    type: string
                    required: false
                    example: '00:00:00:00:00:00'
                  assetId:
                    type: string
                    required: false
                    example: 12345
                  customLocation:
                    type: string
                    required: false
                    example: Room 123
                  note:
                    type: string
                    required: false
                    example: This is a note
                  labels:
                    type: object
                    required: false
                    example:
                      foo: bar
                  managed:
                    description: >
                      Whether the device should be a managed device, with an
                      "enabled" tracking status in Print Tracker.
                    type: boolean
                    required: false
                    default: true
                    example: true
      responses:
        '200':
          description: An array of devices
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                      required: true
                      example: '000000000000000000000000'
                    make:
                      type: string
                      required: true
                      example: HP
                    model:
                      type: string
                      required: true
                      example: LaserJet M477fdw
                    serialNumber:
                      type: string
                      required: true
                      example: SN12345
                    customSerialNumber:
                      type: string
                      required: false
                      example: CUSTOM-SN12345
                    ipAddress:
                      type: string
                      required: false
                      example: 10.0.0.10
                    macAddress:
                      type: string
                      required: false
                      example: '00:00:00:00:00:00'
                    assetId:
                      type: string
                      required: false
                      example: 12345
                    customLocation:
                      type: string
                      required: false
                      example: Room 123
                    note:
                      type: string
                      required: false
                      example: This is a note
                    labels:
                      type: object
                      required: false
                      example:
                        foo: bar
                    managed:
                      type: boolean
                      required: false
                      default: true
  /entity/{entityId}/device/{deviceId}:
    get:
      summary: Get a device by ID
      description: Returns a single device by its ID within the specified entity.
      security:
        - ApiKeyAuth: []
      tags:
        - Devices
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that the device belongs to.
          required: true
        - name: deviceId
          in: path
          description: The ID of the device to retrieve.
          required: true
      responses:
        '200':
          description: A device
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Device'
    put:
      summary: Update a device
      description: Updates the specified fields on a device
      security:
        - ApiKeyAuth: []
      tags:
        - Devices
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that the device belongs to.
          required: true
        - name: deviceId
          in: path
          description: The ID of the device to update.
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                macAddress:
                  type: string
                  required: false
                  example: '00:00:00:00:00:00'
                assetId:
                  type: string
                  required: false
                  example: 12345
                customLocation:
                  type: string
                  required: false
                  example: Room 123
                note:
                  type: string
                  required: false
                  example: This is a note
                labels:
                  type: object
                  required: false
                  example:
                    foo: bar
      responses:
        '200':
          description: The updated device
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Device'
    delete:
      summary: Delete a device
      description: >-
        Deletes the device and all associated data including meter history,
        supply history, etc.
      security:
        - ApiKeyAuth: []
      tags:
        - Devices
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that the device belongs to.
          required: true
        - name: deviceId
          in: path
          description: The ID of the device to delete.
          required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: 'null'
  /entity/{entityId}/device/{deviceId}/settings:
    put:
      summary: Update device settings
      description: >
        Updates the settings of a single device. Currently only SNMP settings
        can be set or reset on a device; other setting paths supported at the
        entity level are not yet accepted here.


        ### Updating Device Settings

        _Audit logging is not yet supported for settings changed using this
        endpoint._


        Print Tracker supports [dynamic settings
        inheritance](https://docs.printtrackerpro.com/docs/guides/settings#inheriting-settings).
        Settings set on a device override any value inherited from the parent
        entity hierarchy. Reset a setting to remove the explicit value on the
        device and fall back to the inherited value.


        The following settings paths are allowed to be set or reset. When
        setting a value, the following table describes the types of values that
        are allowed.


        |<div style="width:230px">Path</div>|Supported Values|

        |--|--|

        |`snmp.version`|One of: `1`, `2`, `3`|

        |`snmp.communities`|Array of strings|

        |`snmp.v3Algorithm`|One of: `MD5`, `SHA`|

        |`snmp.v3Context`|String|

        |`snmp.v3Username`|String|

        |`snmp.v3AuthPassword`|String|

        |`snmp.v3PrivacyPassword`|String|
      security:
        - ApiKeyAuth: []
      tags:
        - Devices
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that the device belongs to.
          required: true
        - name: deviceId
          in: path
          description: The ID of the device whose settings should be updated.
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                set:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        example: snmp.communities
                      value:
                        type: any
                        description: >-
                          A value matching the supported types for the path (see
                          table above)
                        example:
                          - public
                  example:
                    - path: snmp.communities
                      value:
                        - public
                    - path: snmp.version
                      value: 2
                    - path: snmp.v3Username
                      value: my username
                    - path: snmp.v3AuthPassword
                      value: my authentication password
                    - path: snmp.v3PrivacyPassword
                      value: my privacy password
                    - path: snmp.v3Context
                      value: my context
                    - path: snmp.v3Algorithm
                      value: MD5
                reset:
                  type: array
                  items:
                    type: string
                    description: >-
                      A setting path to reset. You cannot reset a path that is
                      being set in the same request.
                    example: snmp.communities
      responses:
        '200':
          description: The updated device
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Device'
  /entity/{entityId}/device/{deviceId}/skipAlert:
    put:
      summary: Set a device skip alert
      description: >-
        Configures a skip alert for the device. When added to a specific supply,
        a skip alert prevents a low supply alert from being generated for that
        supply.
      security:
        - ApiKeyAuth: []
      tags:
        - Devices
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that the device belongs to.
          required: true
        - name: deviceId
          in: path
          description: The ID of the device to set a skip alert on.
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                skipsRemaining:
                  type: integer
                  required: true
                  example: 1
                  description: >-
                    The number of low supply alerts that should be skipped
                    before alerts are resumed. If set to 0, alerts will be
                    resumed immediately.
                supplyKey:
                  type: string
                  required: true
                  example: blackToner
                  description: >
                    The key of the supply to skip alerts for. The following
                    supply keys are supported:

                    - `blackToner`

                    - `cyanToner`

                    - `magentaToner`

                    - `yellowToner`

                    - `blackInk`

                    - `cyanInk`

                    - `magentaInk`

                    - `yellowInk`

                    - `blackDrum`

                    - `cyanDrum`

                    - `magentaDrum`

                    - `yellowDrum`
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: 'null'
  /entity/{entityId}/install:
    get:
      summary: Get installs by entity
      description: >-
        Returns an array of installs that belong to the specified entity and
        (optionally) its children.
      security:
        - ApiKeyAuth: []
      tags:
        - Installs
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity to load devices from.
          required: true
        - name: includeChildren
          in: query
          description: >-
            If enabled, the response will include devices at this entity, and
            all child entities.
          required: false
          schema:
            type: boolean
            default: false
        - name: limit
          in: query
          description: The maximum number of devices to return in a single request.
          required: false
          schema:
            type: integer
            default: 100
        - name: page
          in: query
          description: The page number to return.  Page numbers start at 1.
          required: false
          schema:
            type: integer
            default: 1
      responses:
        '200':
          description: An array of installs
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Install'
  /entity/{entityId}/device/{deviceId}/install:
    get:
      summary: Get installs by device
      description: >-
        Returns an array of installs associated with the specified device. A
        device may be tracked by more than one install, and this endpoint
        returns all of them.
      security:
        - ApiKeyAuth: []
      operationId: getInstallsByDevice
      tags:
        - Installs
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity the device belongs to.
          required: true
        - name: deviceId
          in: path
          description: The ID of the device to load installs for.
          required: true
      responses:
        '200':
          description: An array of installs
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Install'
  /entity/{entityId}/meter:
    get:
      summary: Get meters by entity
      description: Returns an array of meter reads for the specified entity.
      security:
        - ApiKeyAuth: []
      tags:
        - Meters
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity to load meters from.
          required: true
        - name: excludeDisabled
          in: query
          description: If true, only meters form managed devices will be returned.
          required: false
          schema:
            type: boolean
            default: false
        - name: start
          in: query
          required: true
          description: >-
            The start of the meter read date range formatted as RFC3339, ISO8601
            (without timezone), RFC1123Z, RFC1123, RFC1123, RFC822Z, RFC822,
            RFC8250, ANSIC, or Unix.
          example: '2020-12-18T17:52:52.417Z'
        - name: end
          in: query
          required: true
          description: >-
            The end of the meter read date range formatted as RFC3339, ISO8601
            (without timezone), RFC1123Z, RFC1123, RFC1123, RFC822Z, RFC822,
            RFC8250, ANSIC, or Unix.
          example: '2021-01-25T17:52:52.417Z'
      responses:
        '200':
          description: An array of meters
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Meter'
  /entity/{entityId}/currentMeter:
    get:
      summary: Get current meters by entity
      description: >-
        Returns an array of current meter reads for all devices at the specified
        entity. If includeChildren is enabled and provided in the query string,
        this endpoint will return the current meter reads for all devices at the
        provided entity and any children of the provided entity. This endpoint
        is paginated, and the caller should pass a page and limit to paginate
        all the results from the endpoint.
      security:
        - ApiKeyAuth: []
      tags:
        - Meters
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity to load meters from.
          required: true
        - name: excludeDisabled
          in: query
          description: If true, only meters form managed devices will be returned.
          required: false
          schema:
            type: boolean
            default: false
        - name: includeChildren
          in: query
          description: >-
            If enabled, the response will include meters at this entity, and all
            child entities.
          required: false
          schema:
            type: boolean
            default: false
        - name: limit
          in: query
          description: >-
            The maximum number of results to return in a single request. Maximum
            is 50000.
          required: false
          schema:
            type: integer
            default: 100
        - name: page
          in: query
          description: The page number to return. Page numbers start at 1.
          required: false
          schema:
            type: integer
            default: 1
      responses:
        '200':
          description: An array of meters
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Meter'
  /entity/{entityId}/device/{deviceId}/meter:
    get:
      summary: Get meters by device
      description: Returns an array of meter reads for a single device
      security:
        - ApiKeyAuth: []
      tags:
        - Meters
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that the device belongs to
          required: true
        - name: deviceId
          in: path
          description: The ID of the device to load meters from.
          required: true
        - name: limit
          in: query
          description: The maximum number of devices to return in a single request.
          required: false
          schema:
            type: integer
            default: 100
        - name: page
          in: query
          description: The page number to return.  Page numbers start at 1.
          required: false
          schema:
            type: integer
            default: 1
        - name: start
          in: query
          required: true
          description: >-
            The start of the meter read date range formatted as RFC3339, ISO8601
            (without timezone), RFC1123Z, RFC1123, RFC1123, RFC822Z, RFC822,
            RFC8250, ANSIC, or Unix.
          example: '2020-12-18T17:52:52.417Z'
        - name: end
          in: query
          required: true
          description: >-
            The end of the meter read date range formatted as RFC3339, ISO8601
            (without timezone), RFC1123Z, RFC1123, RFC1123, RFC822Z, RFC822,
            RFC8250, ANSIC, or Unix.
          example: '2021-01-25T17:52:52.417Z'
      responses:
        '200':
          description: An array of meters
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Meter'
    post:
      summary: Create meters for device
      description: >
        Creates meter readings for a device. This endpoint can be used to load
        meter history collected from another data collection agent, into Print
        Tracker.


        ### Requirements

        - The total number of meter reads for a single device cannot exceed 186.

        - The meter read timestamps must be in the same timezone.

        - The meter read timestamps must be in the past.

        - No more than one meter read per calendar day.

        - The `pageCounts` must contain at least a `default` format.

        - Each `pageCounts` format must contain at least a `total` counter.
      security:
        - ApiKeyAuth: []
      tags:
        - Meters
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that the device belongs to
          required: true
        - name: deviceId
          in: path
          description: The ID of the device to load meters from.
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                meters:
                  type: array
                  items:
                    type: object
                    properties:
                      timestamp:
                        type: string
                        required: true
                        description: The timestamp of the meter read formatted as RFC3339
                        example: '2024-03-24T01:45:58-06:00'
                      pageCounts:
                        type: object
                        additionalProperties: false
                        patternProperties:
                          ^(default|engine|life|equiv)$:
                            $ref: '#/components/schemas/CreateMeterPageCounts'
                        example:
                          default:
                            total:
                              value: 150
                            totalBlack:
                              value: 100
                            totalColor:
                              value: 50
                          equiv:
                            total:
                              value: 175
                            totalBlack:
                              value: 125
                            totalColor:
                              value: 50
      responses:
        '200':
          description: An array of meters
          content:
            application/json:
              schema:
                type: null
  /entity/{entityId}/device/{deviceId}/meter/mostRecentPriorTo:
    get:
      summary: Get meter immediately prior to a date
      description: >-
        Returns the meter read for a device that is closest to, but not after
        the provided date query parameter.
      security:
        - ApiKeyAuth: []
      tags:
        - Meters
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that the device belongs to
          required: true
        - name: deviceId
          in: path
          description: The ID of the device to load meters from.
          required: true
        - name: date
          in: query
          required: true
          description: >-
            The meter read returned will be the most recent meter read that
            occurred before this date, formatted as RFC3339, ISO8601 (without
            timezone), RFC1123Z, RFC1123, RFC1123, RFC822Z, RFC822, RFC8250,
            ANSIC, or Unix.
          example: '2021-01-25T17:52:52.417Z'
      responses:
        '200':
          description: An array of meters
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Meter'
  /entity/{entityId}/supplies:
    get:
      summary: Get supplies by entity
      description: >-
        Returns all the supplies from all the devices belonging to the specified
        entity or its children.
      security:
        - ApiKeyAuth: []
      tags:
        - Supplies
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that we want to pull supplies
          required: true
        - name: includeChildren
          in: query
          description: >-
            If enabled, the response will include meters at this entity, and all
            child entities.
          required: false
          schema:
            type: boolean
            default: false
        - name: replaced
          in: query
          description: If enabled, the response will only include replaced supplies
          required: false
          schema:
            type: boolean
            default: false
        - name: start
          in: query
          required: true
          description: >-
            If `replaced` is true, only supplies replaced after this date will
            be included. The date should be formatted as RFC3339, ISO8601
            (without timezone), RFC1123Z, RFC1123, RFC1123, RFC822Z, RFC822,
            RFC8250, ANSIC, or Unix.
          example: '2020-12-18T17:52:52.417Z'
        - name: end
          in: query
          required: true
          description: >-
            If `replaced` is true, only supplies replaced before this date will
            be included. The date should be formatted as RFC3339, ISO8601
            (without timezone), RFC1123Z, RFC1123, RFC1123, RFC822Z, RFC822,
            RFC8250, ANSIC, or Unix.
          example: '2021-01-25T17:52:52.417Z'
        - name: limit
          in: query
          description: >-
            The maximum number of supplies to return in a single request.
            Maximum is 50000.
          required: false
          schema:
            type: integer
            default: 100
        - name: page
          in: query
          description: The page number to return.  Page numbers start at 1.
          required: false
          schema:
            type: integer
            default: 1
      responses:
        '200':
          description: An array of supplies
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Supply'
  /entity/{entityId}/device/{deviceId}/supplies:
    get:
      summary: Get supplies by device
      description: Returns all the supplies for a single device
      security:
        - ApiKeyAuth: []
      tags:
        - Supplies
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that the device belongs to
          required: true
        - name: deviceId
          in: path
          description: The ID of the entity that the device belongs to
          required: true
        - name: replaced
          in: query
          description: If enabled, the response will only include replaced supplies
          required: false
          schema:
            type: boolean
            default: false
        - name: start
          in: query
          required: true
          description: >-
            If `replaced` is true, only supplies replaced after this date will
            be included. The date should be formatted as RFC3339, ISO8601
            (without timezone), RFC1123Z, RFC1123, RFC1123, RFC822Z, RFC822,
            RFC8250, ANSIC, or Unix.
          example: '2020-12-18T17:52:52.417Z'
        - name: end
          in: query
          required: true
          description: >-
            If `replaced` is true, only supplies replaced before this date will
            be included. The date should be formatted as RFC3339, ISO8601
            (without timezone), RFC1123Z, RFC1123, RFC1123, RFC822Z, RFC822,
            RFC8250, ANSIC, or Unix.
          example: '2021-01-25T17:52:52.417Z'
        - name: limit
          in: query
          description: >-
            The maximum number of supplies to return in a single request.
            Maximum is 50000.
          required: false
          schema:
            type: integer
            default: 100
        - name: page
          in: query
          description: The page number to return.  Page numbers start at 1.
          required: false
          schema:
            type: integer
            default: 1
      responses:
        '200':
          description: An array of supplies
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Supply'
    put:
      summary: Update current supply
      description: >
        Updates the currently installed supply's settings.


        ### Updating Supply Settings

        _Audit logging is not yet supported for settings changed using this
        endpoint._


        The following settings paths are allowed to be set or reset. When
        setting a value, the following table describes the types of values that
        are allowed.


        |<div style="width:230px">Path</div>|Supported Values|

        |--|--|

        |`partNumber`|String|

        |`expectedFillRate`|Number|

        |`expectedYield`|Number|

        |`supplyCost`|Number|
      security:
        - ApiKeyAuth: []
      tags:
        - Supplies
      parameters:
        - name: entityId
          schema:
            type: string
          in: path
          required: true
          description: The entity ID of the device that the supply belongs to.
        - name: deviceId
          schema:
            type: string
          in: path
          required: true
          description: The device ID that the supply belongs to.
        - name: type
          schema:
            type: string
          in: query
          required: true
          description: >-
            The supply type to use when finding which currently installed supply
            to update.
        - name: color
          schema:
            type: string
          in: query
          required: false
          description: >-
            The supply color to use when finding which currently installed
            supply to update. If not provided, it will look for a color-less
            supply (such as a waste toner kit).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                set:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        example: partNumber
                      value:
                        type: any
                        description: >-
                          A value matching the supported types for the path (see
                          table above)
                        example:
                          - CF410A
                  example:
                    - path: partNumber
                      value: CF410A
                reset:
                  type: array
                  items:
                    type: string
                    description: >-
                      A setting path to reset. You cannot reset a path that is
                      being set in the same request.
                    example: expectedYield
      responses:
        '200':
          description: A supply
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Supply'
  /entity/{entityId}/device/{deviceId}/supplies/{supplyId}:
    get:
      summary: Get supply by ID
      description: Returns a single supply by its ID.
      security:
        - ApiKeyAuth: []
      tags:
        - Supplies
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that the device belongs to.
          required: true
        - name: deviceId
          in: path
          description: The ID of the device that the supply belongs to.
          required: true
        - name: supplyId
          in: path
          description: The ID of the supply to retrieve.
          required: true
      responses:
        '200':
          description: A supply
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Supply'
  /entity/{entityId}/events:
    get:
      summary: Get events by entity
      description: Returns an array of events for the specified entity.
      security:
        - ApiKeyAuth: []
      tags:
        - Events
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity to load meters from.
          required: true
        - name: excludeDisabled
          in: query
          description: If true, only events from managed devices will be returned.
          required: false
          schema:
            type: boolean
            default: false
        - name: includeChildren
          in: query
          description: >-
            If true, events from this entity and child entities will be
            returned.
          required: false
          schema:
            type: boolean
            default: false
        - name: start
          in: query
          required: true
          description: >-
            The start of the event read date range formatted as RFC3339, ISO8601
            (without timezone), RFC1123Z, RFC1123, RFC1123, RFC822Z, RFC822,
            RFC8250, ANSIC, or Unix.
          example: '2020-12-18T17:52:52.417Z'
        - name: end
          in: query
          required: true
          description: >-
            The end of the event read date range formatted as RFC3339, ISO8601
            (without timezone), RFC1123Z, RFC1123, RFC1123, RFC822Z, RFC822,
            RFC8250, ANSIC, or Unix.
          example: '2021-01-25T17:52:52.417Z'
      responses:
        '200':
          description: An array of events
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Event'
  /entity/{entityId}/events/{eventId}:
    put:
      summary: Update event
      description: Update an event using its ID
      security:
        - ApiKeyAuth: []
      tags:
        - Events
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that this event belongs to.
          required: true
        - name: eventId
          in: path
          description: The ID of the event to update.
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                resolutionStatus:
                  $ref: '#/components/schemas/ResolutionStatus'
      responses:
        '200':
          description: The updated event
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
  /billing/{entityId}/usage:
    get:
      summary: Billing usage by entity
      description: >-
        Returns a list of SKUs and their associated quantities for a given
        entity. You can provide any entity and this endpoint will return the
        billable resources from the perspective of that entity. For example, if
        you provide your dealer entity key, you'll get SKUs and quantities that
        could be correlated to your monthly invoice. If you were to provide a
        customer entity, you'd see only the usage contributed to your account by
        that customer.
      security:
        - ApiKeyAuth: []
      tags:
        - Billing
      parameters:
        - name: entityId
          in: path
          description: The ID of the entity that we want to pull supplies
          required: true
        - name: year
          in: query
          description: The year to pull billing usage for
          required: true
          example: 2023
        - name: month
          in: query
          description: >-
            The month to pull billing usage for. Months are numbered 1-12
            starting with January.
          required: true
          example: 1
      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    sku:
                      type: string
                      description: The SKU of the billable item
                      example: PTRDVC
                    quantity:
                      type: integer
                      description: The quantity of the SKU
                      example: 150
                    description:
                      type: string
                      description: A description of the SKU
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
  schemas:
    Supply:
      type: object
      properties:
        deviceKey:
          type: string
          example: '000000000000000000000006'
          description: The device that this supply belongs to
        installedDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
          description: >-
            The date of the meter read where this supply was discovered in the
            device.
        replacedDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
          description: The date of the meter read where this supply was replaced.
        confirmedReplacedDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
          description: >-
            The date that Print Tracker confirmed this supply was replaced.
            Print Tracker may choose to wait some amount of time after the
            `replacedDate` before actually marking the supply as replaced. This
            is the date of the meter read where Print Tracker determined that a
            previously detected replacement was legitimate.
        depletionDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
          description: >-
            The date that this supply reached 0% remaining. Not all supplies
            that are replaced will have a depletion date. If a supply was
            replaced prior to reaching 0% remaining, this field will be null.
        previousSupplyKey:
          type: string
          example: '000000000000000000000007'
          description: >-
            The ID of the supply that this supply replaced. This field allows
            you to form a chain of identical supplies that were replaced by each
            other.
        supply:
          type: string
          example: blackToner
          description: >-
            A unique name for the supply that is consistent across all supplies
            of the same type and color that are installed in this device. For
            example, all black toner's for the same machine will have the value
            "blackToner" in this field.
        firstMeterRead:
          $ref: '#/components/schemas/AnonymousMeter'
        lastMeterRead:
          $ref: '#/components/schemas/AnonymousMeter'
        attributes:
          additionalProperties:
            type: object
            properties:
              value:
                oneOf:
                  - type: string
                  - type: integer
                  - type: number
                  - type: boolean
                description: The value of this attribute
              displayName:
                type: string
                example: Total
                description: The name of this attribute
          example:
            serialNum:
              displayName: Serial Number
              value: CAB231222A22
            sidesOnSupply:
              displayName: Sides on Supply
              value: 4869
            unit:
              displayName: Unit
              value: Impressions
            currentLevel:
              displayName: Current Level
              value: 360
            fillRate:
              displayName: Fill rate
              value: 0.06
            maxLevel:
              displayName: Max Level
              value: 6000
            pctRemaining:
              displayName: Percent Remaining
              value: 6
            type:
              displayName: Type
              value: toner
            color:
              displayName: Color
              value: black
            description:
              displayName: Description
              value: Black Toner
            displayableName:
              displayName: Displayable Name
              value: Black Toner
            partNum:
              displayName: Part Number
              value: 52D0Z00
        statistics:
          type: object
          properties:
            estimatedDepletionDate:
              type: string
              example: '2021-01-01T01:44:44.000Z'
              description: The date that this supply is estimated to reach 0% remaining.
            estimatedDepletionDateSource:
              enum:
                - Device
                - Calculated
              example: Calculated
              description: >-
                Some devices calculate and report a depletion date on their own.
                This field indicates whether the depletion date was reported by
                the device, or calculated by Print Tracker.
            fillRate:
              type: number
              example: 0.06
              description: >-
                See [fill
                rate](https://docs.printtrackerpro.com/docs/guides/supplies#fill-rate)
                for more details
            actualCostPerPage:
              type: number
              example: 0.06
              description: >-
                If the [supply
                cost](https://docs.printtrackerpro.com/docs/guides/supplies#supply-cost)
                is specified, Print Tracker will attempt to calculate the actual
                cost-per-page (CPP) of a supply based on the number of pages you
                actually printed.
            lostPages:
              type: number
              example: 150
              description: >-
                If the [rated
                yield](https://docs.printtrackerpro.com/docs/guides/supplies#rated-yield)
                is specified or provided by the device, Print Tracker will
                attempt to calculate the number of lost pages after a supply is
                replaced. Lost pages represents the difference between the
                number of pages a supply should have printed and the number of
                pages it actually printed.
            volumeByFormat:
              description: >-
                The amount of volume printed faceted by format, while this
                supply was installed in the machine. When performing supply
                related calculations, Print Tracker uses the formats in the
                following order of precedence: equiv, life, engine
              additionalProperties:
                type: number
              example:
                life: 100
                equiv: 200
            granularity:
              type: number
              example: 1
              description: >-
                The smallest difference between the remaining supply level that
                Print Tracker has observed over the life of the supply. Some
                supplies report supply levels at 1% granularity, while others
                only report 50%+ percent granularity. Some calculations can only
                be reliably performed on more granular supplies.
        settings:
          type: object
          properties:
            partNumber:
              type: string
              required: false
              example: CF410A
              description: The part number of the supply
            expectedFillRate:
              type: number
              required: false
              example: 0.05
              description: The expected fill rate of the supply
            expectedYield:
              type: number
              required: false
              example: 6000
              description: The expected yield of the supply
            supplyCost:
              type: number
              required: false
              example: 120.55
              description: The cost of the supply
    Entity:
      type: object
      properties:
        id:
          type: string
          example: '000000000000000000000002'
          description: The unique identifier for the entity
        name:
          type: string
          example: My Company
          description: The name of the entity
        genealogy:
          type: array
          description: >-
            An array of entity IDs that represent the hierarchical position of
            the entity from top to bottom
          example:
            - '000000000000000000000000'
            - '000000000000000000000001'
          items:
            type: string
        addresses:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                example: Main Office
              address1:
                type: string
                example: 1234 State St.
              address2:
                type: string
                example: Suite 100
              city:
                type: string
                example: Manhattan
              state:
                type: string
                example: NY
              stateOrProvince:
                type: string
                example: New York
              zipOrPostalCode:
                type: string
                example: '10001'
              country:
                type: string
                example: United States
        children:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                example: '000000000000000000000003'
              name:
                type: string
                example: My Child Company
        labels:
          type: object
          example:
            foo: bar
    AnonymousMeter:
      type: object
      properties:
        installKey:
          type: string
          example: '000000000000000000000003'
          description: The install that collected this meter read
        deviceKey:
          type: string
          example: '000000000000000000000006'
          description: The device that this meter read was collected from
        timestamp:
          type: string
          description: The date and time that the meter read was collected
          example: '2021-01-01T01:44:44.000Z'
        pageCounts:
          $ref: '#/components/schemas/MeterReadPageCounts'
        supplies:
          $ref: '#/components/schemas/MeterReadSupply'
    Meter:
      type: object
      properties:
        id:
          type: string
          example: '000000000000000000000008'
        createdDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
        modifiedDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
        entityKey:
          type: string
          example: '000000000000000000000002'
          description: The entity that the device belongs to
        installKey:
          type: string
          example: '000000000000000000000003'
          description: The install that collected this meter read
        deviceKey:
          type: string
          example: '000000000000000000000006'
          description: The device that this meter read was collected from
        timestamp:
          type: string
          description: The date and time that the meter read was collected
          example: '2021-01-01T01:44:44.000Z'
        console:
          type: string
          description: >-
            The console message collected on the device at the time the meter
            read was collected.
          example: Sleeping...
        pageCounts:
          $ref: '#/components/schemas/MeterReadPageCounts'
        supplies:
          $ref: '#/components/schemas/MeterReadSupply'
    MeterReadPageCounts:
      type: object
      description: >-
        The page counts collected from the device. This object uses nested
        objects to group counters into formats (ways of measuring a counter). In
        this example response, the meter contains the total, total black, and
        total color counters in measure in both life and equivalent formats.
        Many devices report many different kinds of formats, for example a
        wide-format device may report some counters in the square-feet (`sqFt`)
        format. All available data is provided to you in this structure for
        maximum flexibility.
      additionalProperties:
        type: object
        additionalProperties:
          type: object
          properties:
            value:
              type: integer
              example: 100
              description: The value of this counter
            displayName:
              type: string
              example: Total
              description: The name of this counter
      example:
        life:
          total:
            value: 100
            displayName: Total
          totalBlack:
            value: 75
            displayName: Total Black
          totalColor:
            value: 25
            displayName: Total Color
        equiv:
          total:
            value: 200
            displayName: Total
          totalBlack:
            value: 150
            displayName: Total Black
          totalColor:
            value: 50
            displayName: Total Color
    MeterReadSupply:
      type: object
      description: >-
        The supplies collected from the device. Similar to `pageCounts` this is
        also uses nested objects to group an arbitrary set of supply attributes
        for each supply. The first level is the supply, and the second level
        contains the attributes that belong to the supply.
      additionalProperties:
        type: object
        additionalProperties:
          type: object
          properties:
            value:
              oneOf:
                - type: string
                - type: integer
                - type: number
                - type: boolean
              description: The value of this attribute
            displayName:
              type: string
              example: Total
              description: The name of this attribute
      example:
        blackToner:
          serialNum:
            displayName: Serial Number
            value: CAB231222A22
          sidesOnSupply:
            displayName: Sides on Supply
            value: 4869
          unit:
            displayName: Unit
            value: Impressions
          currentLevel:
            displayName: Current Level
            value: 360
          fillRate:
            displayName: Fill rate
            value: 0.06
          maxLevel:
            displayName: Max Level
            value: 6000
          pctRemaining:
            displayName: Percent Remaining
            value: 6
          type:
            displayName: Type
            value: toner
          color:
            displayName: Color
            value: black
          description:
            displayName: Description
            value: Black Toner
          displayableName:
            displayName: Displayable Name
            value: Black Toner
          partNum:
            displayName: Part Number
            value: 52D0Z00
    CreateMeterPageCounts:
      type: object
      properties:
        total:
          $ref: '#/components/schemas/CreateMeterPageValue'
        totalBlack:
          $ref: '#/components/schemas/CreateMeterPageValue'
        totalColor:
          $ref: '#/components/schemas/CreateMeterPageValue'
    CreateMeterPageValue:
      type: object
      properties:
        value:
          type: integer
    ResolutionStatus:
      type: string
      enum:
        - Open
        - In Progress
        - Resolved
    Event:
      type: object
      properties:
        id:
          type: string
          example: '000000000000000000000006'
        createdDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
        modifiedDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
        entityKey:
          type: string
          example: '000000000000000000000002'
          description: The entity that the device belongs to
        installKey:
          type: string
          example: '000000000000000000000003'
          description: The install that fired this event
        deviceKey:
          type: string
          example: '000000000000000000000006'
          description: The device that this event was fired from
        deviceSerialNumber:
          type: string
          example: SN12345
          description: The serial number of the device that this event was fired from
        timestamp:
          type: string
          description: The date and time that the event was fired
          example: '2021-01-01T01:44:44.000Z'
        description:
          type: string
          description: A human-readable description of the event
          example: A black toner was replaced
        alertType:
          type: string
          oneOf:
            - Low supply
            - Low maintenance supply
            - Replacement
            - Premature replacement
            - Service
            - Volume
        supplyKey:
          type: string
          description: The key of the supply in the meter read
          example: blackToner
        deviceSupplyKey:
          type: string
          description: >-
            The ID of the DeviceSupply document associated with this event. Can
            be used to look up the supply via the get supply by ID endpoint.
          example: '000000000000000000000007'
        resolutionStatus:
          $ref: '#/components/schemas/ResolutionStatus'
        acknowledged:
          type: object
          properties:
            timestamp:
              type: string
              description: The date and time that the event was acknowledged
              example: '2021-01-01T01:44:44.000Z'
            note:
              type: string
              description: An optional note that can be added when acknowledging an event
            userKey:
              type: string
              description: The user that acknowledged the event
              example: '000000000000000000000001'
            userName:
              type: string
              description: The full name of the user that acknowledged the event
              example: John Doe
        meterRead:
          $ref: '#/components/schemas/AnonymousMeter'
        attributes:
          $ref: '#/components/schemas/MeterReadSupply'
    Device:
      type: object
      properties:
        id:
          type: string
          example: '000000000000000000000006'
        createdDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
        modifiedDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
        entityKey:
          type: string
          example: '000000000000000000000002'
          description: The entity that the device belongs to
        installKeys:
          type: array
          items:
            type: string
            example: '000000000000000000000005'
            description: >-
              The IDs of the installs that are tracking this device. At a single
              entity, the same device can be tracked by multiple installs.
        make:
          type: string
          example: HP
        model:
          type: string
          example: LaserJet 4000
        serialNumber:
          type: string
          example: CNDQQ05142
        customSerialNumber:
          type: string
          example: CUSTOM-CNDQQ05142
        ipAddress:
          type: string
          example: 10.0.0.5
        macAddress:
          type: string
          example: 00-60-d1-4d-e1-5f
        location:
          type: string
          description: The location according to the device
        customLocation:
          type: string
          description: The location as specified in Print Tracker
        assetID:
          type: string
          example: ABC123
          description: >-
            A custom identifier specified by a user for a device in Print
            Tracker
        integrationID:
          type: string
          example: EXT-98765
          description: >-
            An external identifier used to correlate this device with a record
            in an external system
        note:
          type: string
          description: Any notes specified by a user for a device in Print Tracker
        isLocal:
          type: boolean
          description: Whether the device is a USB-connected device
        firmware:
          type: object
          properties:
            device:
              type: string
              example: FW-101.v10.1.10
              description: The device's firwmare version
        labels:
          type: object
          example:
            foo: bar
        managed:
          type: boolean
          description: >-
            Whether the device should be a managed device, with an "enabled"
            tracking status in Print Tracker.
          example: true
    Install:
      type: object
      properties:
        id:
          type: string
          example: '000000000000000000000006'
        createdDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
        modifiedDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
        entityKey:
          type: string
          example: '000000000000000000000002'
          description: The entity that the install belongs to
        machine:
          type: string
          description: The name of the computer where the Print Tracker agent was installed
          example: John's MacBook Pro
        os:
          type: string
          description: The operating system of the computer
          example: Microsoft Windows 11 Enterprise
        osVersion:
          type: string
          description: Version information about the operating system of the computer
          example: 10.0.22631.6199 Build 22631.6199
        hasBattery:
          type: boolean
          description: >-
            Indicates whether the computer has a battery (helpful for
            identifying laptops)
          example: true
        publicIp:
          type: string
          description: The public IP address of the host
          example: 30.20.10.10
        privateIp:
          type: string
          description: The private IP address of the host
          example: 10.10.10.10
        version:
          type: string
          description: The version of the Print Tracker data collection agent
          example: 2.74.0
        lastCheckInDate:
          type: string
          example: '2021-01-01T01:44:44.000Z'
          description: The last time the install checked in with the server
        antivirus:
          type: string
          example: CrowdStrike Falcon
          description: The antivirus solution installed on the host
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
