> ## Documentation Index
> Fetch the complete documentation index at: https://docs.comfy.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Serverless spend, grouped and bucketed

> Aggregates the workspace's serverless usage into per-group totals and, unless granularity=none, a time series per group. Sorting and paging operate on groups, not buckets: the chosen page of groups determines which buckets come back, and totalChargedMicroUsd/totalCredits/truncated describe the whole filtered set rather than the returned page, so share stays honest against the real denominator.

GPU time, network-volume storage and container disk are all counted. Use groupBy=resource or the resource filter to tell them apart; without either they are summed into one figure per group. Buckets stored before the meter split container disk out of the endpoint charge carry it inside their compute figure, so a window spanning that change reports less container_disk than the hardware actually used.

Only what the workspace is billed is reported, and only usage actually billed is counted. Workspace scope always comes from the caller's identity, never from a parameter.




## OpenAPI

````yaml /openapi-deploy.yaml get /v1/usage/serverless
openapi: 3.0.3
info:
  title: Comfy Deploy API
  version: 0.1.0
  description: >
    Deploy takes an immutable release cut by Builder and runs it as a live
    autoscaling serverless endpoint.
servers:
  - url: https://platformapi.comfy.org/deploy
    description: Comfy Developer Platform
security:
  - BearerAuth: []
  - ApiKeyAuth: []
paths:
  /v1/usage/serverless:
    get:
      summary: Serverless spend, grouped and bucketed
      description: >
        Aggregates the workspace's serverless usage into per-group totals and,
        unless granularity=none, a time series per group. Sorting and paging
        operate on groups, not buckets: the chosen page of groups determines
        which buckets come back, and totalChargedMicroUsd/totalCredits/truncated
        describe the whole filtered set rather than the returned page, so share
        stays honest against the real denominator.


        GPU time, network-volume storage and container disk are all counted. Use
        groupBy=resource or the resource filter to tell them apart; without
        either they are summed into one figure per group. Buckets stored before
        the meter split container disk out of the endpoint charge carry it
        inside their compute figure, so a window spanning that change reports
        less container_disk than the hardware actually used.


        Only what the workspace is billed is reported, and only usage actually
        billed is counted. Workspace scope always comes from the caller's
        identity, never from a parameter.
      operationId: getServerlessUsage
      parameters:
        - name: groupBy
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/UsageGroupBy'
        - name: granularity
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/UsageGranularity'
        - name: timezone
          in: query
          required: false
          description: >
            IANA zone name (e.g. America/Los_Angeles), not a fixed offset.
            Default UTC. Applies to day/week/month bucketing; irrelevant for
            hour/none. An unrecognized name is a 400.
          schema:
            type: string
        - name: startingOn
          in: query
          required: false
          description: >
            Inclusive. Default: 30 days before endingBefore (which itself
            defaults to the request time), truncated down to the granularity
            boundary in the requested timezone.
          schema:
            type: string
            format: date-time
        - name: endingBefore
          in: query
          required: false
          description: Exclusive. Default the request time.
          schema:
            type: string
            format: date-time
        - name: deploymentId
          in: query
          required: false
          description: Repeatable. OR within the field. At most 100 values.
          schema:
            type: array
            maxItems: 100
            items:
              type: string
        - name: userId
          in: query
          required: false
          description: >
            Repeatable. Required by scope=user (identifies whose spend); usable
            as a plain narrowing filter under scope=workspace. Rejected under
            scope=self, which is already the caller. At most 100 values.
          schema:
            type: array
            maxItems: 100
            items:
              type: string
        - name: buildId
          in: query
          required: false
          description: >-
            Repeatable. OR within the field. At most 100 values. Narrows to
            deployments cut from these builds; a deployment records the release
            it came from, and the release records its build.
          schema:
            type: array
            maxItems: 100
            items:
              type: string
        - name: resource
          in: query
          required: false
          description: >-
            Repeatable. OR within the field. Omitted, or naming all three kinds,
            returns every kind together; naming only compute and storage leaves
            container_disk out.
          schema:
            type: array
            maxItems: 100
            items:
              $ref: '#/components/schemas/UsageResource'
        - name: gpuClass
          in: query
          required: false
          description: Repeatable. OR within the field. At most 100 values.
          schema:
            type: array
            maxItems: 100
            items:
              type: string
        - name: scope
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/UsageScope'
        - name: sort
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/UsageSort'
        - $ref: '#/components/parameters/Limit'
        - name: offset
          in: query
          required: false
          description: Pages groups (not buckets). Default 0.
          schema:
            type: integer
            minimum: 0
            default: 0
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageServerlessResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '503':
          $ref: '#/components/responses/KeyUnverified'
components:
  schemas:
    UsageGroupBy:
      type: string
      description: >-
        Aggregation key. none collapses every row into a single group. resource
        answers one group per kind: compute, storage and container_disk.
        deployment answers one group per deployment, with every release it ran;
        release answers each release a deployment ran apart.
      enum:
        - deployment
        - user
        - gpuClass
        - resource
        - none
        - release
      default: deployment
    UsageGranularity:
      type: string
      description: >-
        Time-bucket size. none returns totals only (breakdown/totals), with an
        empty buckets array — no series to draw.
      enum:
        - hour
        - day
        - week
        - month
        - none
      default: day
    UsageResource:
      type: string
      description: >-
        What a charge is for. compute is GPU time; storage is the deployment's
        network volume, which bills continuously whether or not anything runs;
        container_disk is the worker's own local disk, itemised inside the
        endpoint's bucket by the provider. It is not charged: its rows are
        recorded at zero charge, though buckets stored before that change carry
        a charge for it.
      enum:
        - compute
        - storage
        - container_disk
      x-enum-varnames:
        - UsageResourceCompute
        - UsageResourceStorage
        - UsageResourceContainerDisk
    UsageScope:
      type: string
      description: >-
        Whose spend to return. workspace (the default) is every row in the
        workspace, self is the deployments the caller created, user is the rows
        for the given userId. Spend is visible workspace-wide to every member,
        so no scope is role-gated; the workspace comes from the caller's
        identity and is the only boundary.
      enum:
        - self
        - workspace
        - user
      default: workspace
    UsageSort:
      type: string
      description: >-
        Ranks groups by their total charged amount over the whole filtered set,
        or by group key. Accepted but inert when groupBy=none, since a single
        group has no order to rank.
      enum:
        - costDesc
        - costAsc
        - keyAsc
        - keyDesc
      default: costDesc
    UsageServerlessResponse:
      type: object
      required:
        - groupBy
        - granularity
        - timezone
        - startingOn
        - endingBefore
        - groups
        - buckets
        - breakdown
        - totalChargedMicroUsd
        - totalCredits
        - truncated
      properties:
        groupBy:
          $ref: '#/components/schemas/UsageGroupBy'
        granularity:
          $ref: '#/components/schemas/UsageGranularity'
        timezone:
          type: string
          description: The IANA zone actually used (the request's timezone, or UTC).
        startingOn:
          type: string
          format: date-time
        endingBefore:
          type: string
          format: date-time
        groups:
          type: array
          description: The selected page of groups, in sort order.
          items:
            $ref: '#/components/schemas/UsageGroup'
        buckets:
          type: array
          description: >-
            Sparse: a period with no matching rows is omitted, not zero-filled.
            Only covers the groups on this page. Empty when granularity=none.
          items:
            $ref: '#/components/schemas/UsageBucket'
        breakdown:
          type: array
          description: Per-group totals for the groups on this page, with share.
          items:
            $ref: '#/components/schemas/UsageBreakdownEntry'
        totalChargedMicroUsd:
          type: integer
          format: int64
          description: >-
            What the workspace was charged across every group in the filtered
            set, not just this page.
        totalCredits:
          type: integer
          format: int64
        truncated:
          type: boolean
          description: True when more groups exist beyond this page (limit/offset).
    UsageGroup:
      type: object
      required:
        - key
        - label
      properties:
        key:
          type: string
          description: >-
            Opaque group identifier: a deployment id, a Comfy user id, a GPU
            class name, a resource kind, or for groupBy=release a deployment id
            and a release id joined by a slash, depending on groupBy. A usage
            row whose deployment was erased keeps its own id as its key.
        label:
          type: string
          nullable: true
          description: >-
            Human-readable label. For groupBy=deployment, the deployment's own
            label: its first copy's invoice label with any trailing release
            version removed (null on legacy rows that predate the snapshot,
            never the id). For groupBy=release, the copy's own invoice label,
            which names the release the copy runs (a deployment's first copy may
            not name it yet); null where the deployment was erased or predates
            the snapshot. For groupBy=user, always null: this route does not
            return user names. For groupBy=gpuClass, equal to key.
    UsageBucket:
      type: object
      required:
        - periodStart
        - periodEnd
        - groupKey
        - chargedMicroUsd
        - credits
      properties:
        periodStart:
          type: string
          format: date-time
        periodEnd:
          type: string
          format: date-time
        groupKey:
          type: string
          description: Matches a UsageGroup.key on this response.
        chargedMicroUsd:
          type: integer
          format: int64
          description: >-
            What the workspace was charged for this group and bucket, in
            micro-USD.
        credits:
          type: integer
          format: int64
          description: >-
            chargedMicroUsd converted to credits at 211 credits per USD, rounded
            half-up from this row alone. Does not sum exactly across rows;
            compute from chargedMicroUsd instead.
    UsageBreakdownEntry:
      type: object
      required:
        - groupKey
        - chargedMicroUsd
        - credits
        - share
      properties:
        groupKey:
          type: string
          description: Matches a UsageGroup.key on this response.
        chargedMicroUsd:
          type: integer
          format: int64
          description: >-
            What the workspace was charged for this group across the whole
            requested range.
        credits:
          type: integer
          format: int64
        share:
          type: number
          format: double
          description: >-
            chargedMicroUsd divided by totalChargedMicroUsd (the whole filtered
            set, not just the returned page). 0 when totalChargedMicroUsd is 0;
            groups that charged nothing are still returned. Shares sum to 1 only
            across every group, so a page that leaves groups out (an offset
            above 0, or truncated true) can sum to less; truncated says only
            that more groups follow.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Machine-readable error code.
        message:
          type: string
          description: Human-readable detail.
  parameters:
    Limit:
      name: limit
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
  responses:
    BadRequest:
      description: >
        Invalid request (INVALID_REQUEST), or RELEASE_AND_SOURCE_BOTH when an
        update names both a release and a source deployment.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid token (UNAUTHORIZED)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >
        Caller's workspace does not own the resource (FORBIDDEN), or an API key
        was refused because its user may not use it, its workspace was deleted
        or blocked, or its account is on the free tier or is being deleted. The
        message says which.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: >
        Unknown id, or not in the caller's workspace (NOT_FOUND). An API key
        also gets this when its workspace no longer exists or its user is no
        longer a member.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    KeyUnverified:
      description: >
        The request could not be served now (SERVICE_UNAVAILABLE), and the same
        request may succeed if retried. Either a workspace API key could not be
        verified, because the key check gave no answer, or because the service
        was already checking as many keys as it will at once, overall or from
        the caller's address, which carries Retry-After; or the request ran past
        the service's request deadline, 30 seconds by default and 120 for a
        model add, and was cut off; or a model add could not read another
        deployment's storage to check which disk it mounts. The body's message
        says which.
      headers:
        Retry-After:
          description: >
            Seconds to wait before retrying; sent when the service refused the
            key check because too many were in flight.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: A workspace-scoped Cloud JWT.
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: >
        A workspace API key, sent alone. The service checks it on every request
        and acts as the key's user in the key's workspace. A request carrying a
        key and a Bearer token is 400, and a value that is not a key's shape is
        401. A refused key answers 401, 403 or 404 with its message; a 503 means
        the key could not be checked right now, so retry.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.