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

# What a managed user's editor sessions spent

> Says how many credits the editor sessions of one of your managed users took from your account over a
period, in total and for each operation. A generation costs one credit, taken from your account when it
starts; one that fails is refunded and is counted as refunded, not as spent.

Only what was spent through editor sessions is here, and only since usage was first recorded: what you
spend with your API key, and anything from before, is not. Use it to see which of your users spend the
most, or to charge them for it. To hold one session to a number of credits, set `max_credits` when you
make it (`createManagedUserEditorSession`).

The period runs from `startDate` (included) to `endDate` (not included): the 30 days before now when you
give neither, and at most 366 days. A date without a time is midnight UTC at the start of that day, so for
all of October give `startDate=2026-10-01` and `endDate=2026-11-01`.




## OpenAPI

````yaml /openapi/widgetic-api-public.json get /managed-users/{id}/usage
openapi: 3.0.0
info:
  title: Widgetic API Gateway
  version: 1.0.0
  description: API documentation for the Widgetic API Gateway
  license:
    name: Widgetic Integration License
    url: https://docs.widgetic.com/resources/license
servers:
  - url: https://api.widgetic.com/v1
    description: Production server
    variables:
      env:
        default: production
        description: Environment
      apiUrl:
        default: https://api.widgetic.com
        description: API URL
      apiVersion:
        default: /v1
        description: API Version path prefix
security: []
tags: []
paths:
  /managed-users/{id}/usage:
    get:
      tags:
        - Managed Users
      summary: What a managed user's editor sessions spent
      description: >
        Says how many credits the editor sessions of one of your managed users
        took from your account over a

        period, in total and for each operation. A generation costs one credit,
        taken from your account when it

        starts; one that fails is refunded and is counted as refunded, not as
        spent.


        Only what was spent through editor sessions is here, and only since
        usage was first recorded: what you

        spend with your API key, and anything from before, is not. Use it to see
        which of your users spend the

        most, or to charge them for it. To hold one session to a number of
        credits, set `max_credits` when you

        make it (`createManagedUserEditorSession`).


        The period runs from `startDate` (included) to `endDate` (not included):
        the 30 days before now when you

        give neither, and at most 366 days. A date without a time is midnight
        UTC at the start of that day, so for

        all of October give `startDate=2026-10-01` and `endDate=2026-11-01`.
      operationId: getManagedUserUsage
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
            format: uuid
          description: The managed user whose usage you want (Widgetic's id for the user)
        - in: query
          name: startDate
          schema:
            type: string
          description: >
            Start of the period, included: an ISO 8601 date (`2026-10-01`) or
            date-time with its offset (`2026-10-01T08:00:00Z`). Default: 30 days
            before `endDate`.
        - in: query
          name: endDate
          schema:
            type: string
          description: >
            End of the period, not included, in the same forms. Default: now. It
            must be after `startDate`, by at most 366 days.
      responses:
        '200':
          description: What the managed user's editor sessions spent in the period
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedUserUsageResponse'
        '400':
          description: >-
            A date is not a date, `startDate` is not before `endDate`, or the
            period is longer than 366 days
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - the caller is not a partner
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: >-
            No managed user with this id on your account
            (`MANAGED_USER_NOT_FOUND`). Another partner's managed user answers
            404 as well.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - apiKeyAuth: []
      x-code-samples:
        - lang: TypeScript
          label: TypeScript SDK
          source: >
            import { Configuration, ManagedUsersApi } from
            '@widgetic/api-sdk-ts';


            const managedUsersApi = new ManagedUsersApi(new Configuration({
            apiKey: 'YOUR_API_KEY' }));


            // What this user's editor sessions spent in October:

            const { data: usage } = await managedUsersApi.getManagedUserUsage({
              id: managedUserId,
              startDate: '2026-10-01',
              endDate: '2026-11-01'
            });


            console.log(usage.totals.credits, usage.operations);
components:
  schemas:
    ManagedUserUsageResponse:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          description: Always `true` on a success.
          example: true
        data:
          $ref: '#/components/schemas/ManagedUserUsage'
        meta:
          $ref: '#/components/schemas/ResponseMeta'
    ErrorResponse:
      type: object
      required:
        - success
        - message
        - error
      additionalProperties: true
      properties:
        success:
          type: boolean
          description: Always `false` on a failure.
          example: false
        message:
          type: string
          description: The same text as `error.message`, for a caller that reads one line.
        error:
          $ref: '#/components/schemas/ErrorDetail'
    ManagedUserUsage:
      type: object
      description: >
        What a managed user's editor sessions spent over a period. Only credits
        taken through editor sessions are counted, from the day usage was first
        recorded: what you spend with your API key is not, and neither is
        anything from before.
      required:
        - managedUserId
        - managedUserExternalId
        - from
        - to
        - totals
        - operations
      properties:
        managedUserId:
          type: string
          format: uuid
        managedUserExternalId:
          type: string
          description: Your own identifier for the managed user
        from:
          type: string
          format: date-time
          description: Start of the period, included
        to:
          type: string
          format: date-time
          description: End of the period, not included
        totals:
          type: object
          description: All operations together
          required:
            - calls
            - credits
            - refundedCalls
            - refundedCredits
          properties:
            calls:
              type: integer
            credits:
              type: integer
            refundedCalls:
              type: integer
            refundedCredits:
              type: integer
        operations:
          type: array
          description: >-
            One entry for each operation that was paid for in the period, in
            alphabetical order
          items:
            $ref: '#/components/schemas/ManagedUserOperationUsage'
      example:
        managedUserId: 3fa85f64-5717-4562-b3fc-2c963f66afa6
        managedUserExternalId: Example managedUserExternalId
        from: '2026-01-15T09:30:00.000Z'
        to: '2026-01-15T09:30:00.000Z'
        totals: {}
        operations:
          - Example ManagedUserOperationUsage
    ResponseMeta:
      type: object
      description: >-
        Extra information about the answer: where a page sits in a list, the
        cursor of the next page, or warnings about a call that succeeded with a
        caveat.
      additionalProperties: true
      properties:
        page:
          type: integer
          description: The page that was read, counting from 1.
          example: 1
        size:
          type: integer
          description: How many items one page holds.
          example: 20
        total:
          type: integer
          description: How many items the whole list has.
          example: 135
        limit:
          type: integer
          description: The same as `size`.
          example: 20
        offset:
          type: integer
          description: How many items come before this page.
          example: 0
        hasNextPage:
          type: boolean
          example: true
        hasPreviousPage:
          type: boolean
          example: false
        nextCursor:
          type: string
          nullable: true
          description: >-
            Pass this as `cursor` to read the next page of a list that is read
            by cursor. `null` on the last page.
        warnings:
          type: array
          items:
            type: string
          description: >-
            Things the call did not do, though it succeeded (for example a table
            that could not be created just now).
    ErrorDetail:
      type: object
      required:
        - code
        - message
        - timestamp
      properties:
        code:
          type: string
          description: Machine-readable error code.
          example: RESOURCE_NOT_FOUND
        message:
          type: string
          description: Human-readable explanation.
          example: Composition not found
        param:
          type: string
          description: The field that caused the error, when one did.
          example: name
        docUrl:
          type: string
          description: Where this error is explained.
        suggestedAction:
          type: string
          description: What to do about it.
        retryAfter:
          type: integer
          description: >-
            Seconds to wait before trying again (rate limits). The same number
            is in the `Retry-After` header.
          example: 60
        details:
          type: object
          additionalProperties: true
          description: >-
            More about the error: the fields that failed, a limit that was
            reached.
        correlationId:
          type: string
          description: Quote this when you ask support about the call.
          example: req_123e4567-e89b-12d3-a456-426614174000
        timestamp:
          type: string
          format: date-time
          example: '2026-10-15T10:00:00.000Z'
    ManagedUserOperationUsage:
      type: object
      description: >-
        What one metered operation cost a managed user's editor sessions over
        the period
      required:
        - operation
        - calls
        - credits
        - refundedCalls
        - refundedCredits
      properties:
        operation:
          type: string
          description: The metered operation, as the credit ledger names it
          example: agent.code.generate
        calls:
          type: integer
          description: >-
            How many runs of the operation were paid for and kept (a run that
            was refunded is not one)
        credits:
          type: integer
          description: The credits those runs took from your account
        refundedCalls:
          type: integer
          description: >-
            How many runs were refunded (a generation that failed), and so are
            not in `calls`
        refundedCredits:
          type: integer
          description: The credits the refunded runs took, which went back to your account
      example:
        operation: agent.code.generate
        calls: 42
        credits: 42
        refundedCalls: 42
        refundedCredits: 42
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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