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

# settle incurred usage against a run

> Record already-incurred usage without feature-limit enforcement and reconcile its cost against the run budget. The run remains open until runs.end.



## OpenAPI

````yaml /openapi.json post /v1/runs/settle/{runId}
openapi: 3.0.3
info:
  title: Unprice API
  version: 1.0.0
servers:
  - url: https://api.unprice.dev
    description: Production
  - url: http://localhost:8787
    description: Development
  - url: https://preview-api.unprice.dev
    description: Preview
security:
  - bearerAuth: []
paths:
  /v1/runs/settle/{runId}:
    post:
      tags:
        - runs
      summary: settle incurred usage against a run
      description: >-
        Record already-incurred usage without feature-limit enforcement and
        reconcile its cost against the run budget. The run remains open until
        runs.end.
      operationId: runs.settle
      parameters:
        - schema:
            type: string
            minLength: 1
            description: The run ID
            example: brun_123
          required: true
          name: runId
          in: path
      requestBody:
        description: The incurred usage payload
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                featureSlug:
                  type: string
                  minLength: 1
                idempotencyKey:
                  type: string
                  minLength: 1
                id:
                  type: string
                  minLength: 1
                eventSlug:
                  type: string
                  minLength: 1
                timestamp:
                  type: integer
                  minimum: 0
                  exclusiveMinimum: true
                properties:
                  type: object
                  additionalProperties:
                    nullable: true
              required:
                - featureSlug
                - idempotencyKey
      responses:
        '200':
          description: The settlement decision
          content:
            application/json:
              schema:
                type: object
                properties:
                  accepted:
                    type: boolean
                  reason:
                    type: string
                    enum:
                      - accepted
                      - duplicate
                      - insufficient_budget
                      - expired
                      - not_running
                      - entitlement_denied
                  fundingStatus:
                    type: string
                    enum:
                      - fully_funded
                      - partially_funded
                      - unfunded
                  fundedAmountMinor:
                    type: integer
                    minimum: 0
                  unfundedAmountMinor:
                    type: integer
                    minimum: 0
                  run:
                    type: object
                    properties:
                      runId:
                        type: string
                      status:
                        type: string
                        enum:
                          - running
                          - completed
                          - expired
                          - canceled
                          - budget_exceeded
                          - failed
                      endedAt:
                        type: integer
                        nullable: true
                        minimum: 0
                        description: >-
                          Authoritative run terminal timestamp in epoch
                          milliseconds; null while running.
                      customerId:
                        type: string
                      currency:
                        type: string
                      workloadType:
                        type: string
                        nullable: true
                        enum:
                          - agent
                          - workflow
                          - job
                          - tool
                          - custom
                          - null
                      workloadId:
                        type: string
                        nullable: true
                      traceId:
                        type: string
                        nullable: true
                      parentRunId:
                        type: string
                        nullable: true
                      budgetAmountMinor:
                        type: integer
                        description: Budget in currency minor units (cents).
                      consumedAmountMinor:
                        type: integer
                        description: Consumed in currency minor units (cents).
                      remainingAmountMinor:
                        type: integer
                        description: Remaining in currency minor units (cents).
                    required:
                      - runId
                      - status
                      - customerId
                      - currency
                      - workloadType
                      - workloadId
                      - traceId
                      - parentRunId
                      - budgetAmountMinor
                      - consumedAmountMinor
                      - remainingAmountMinor
                required:
                  - accepted
                  - reason
                  - run
        '400':
          description: >-
            The server cannot or will not process the request due to something
            that is perceived to be a client error (e.g., malformed request
            syntax, invalid request message framing, or deceptive request
            routing).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrBadRequest'
        '401':
          description: >-
            Although the HTTP standard specifies "unauthorized", semantically
            this response means "unauthenticated". That is, the client must
            authenticate itself to get the requested response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrUnauthorized'
        '403':
          description: >-
            The client does not have access rights to the content; that is, it
            is unauthorized, so the server is refusing to give the requested
            resource. Unlike 401 Unauthorized, the client's identity is known to
            the server.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrForbidden'
        '404':
          description: >-
            The server cannot find the requested resource. In the browser, this
            means the URL is not recognized. In an API, this can also mean that
            the endpoint is valid but the resource itself does not exist.
            Servers may also send this response instead of 403 Forbidden to hide
            the existence of a resource from an unauthorized client. This
            response code is probably the most well known due to its frequent
            occurrence on the web.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrNotFound'
        '409':
          description: >-
            This response is sent when a request conflicts with the current
            state of the server.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrConflict'
        '412':
          description: >-
            The requested operation cannot be completed because certain
            conditions were not met. This typically occurs when a required
            resource state or version check fails.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrPreconditionFailed'
        '413':
          description: The request payload is larger than the server is willing to process.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrPayloadTooLarge'
        '429':
          description: >-
            The user has sent too many requests in a given amount of time ("rate
            limiting")
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrTooManyRequests'
        '500':
          description: >-
            The server has encountered a situation it does not know how to
            handle.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrInternalServerError'
components:
  schemas:
    ErrBadRequest:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - BAD_REQUEST
              description: A machine readable error code.
              example: BAD_REQUEST
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: https://docs.unprice.dev/api-reference/errors/code/BAD_REQUEST
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
            details:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                    - invalid_config
                    - slug_conflict
                    - unresolved_reference
                  description: >-
                    What kind of failure this is. Currently only the
                    monetization configuration operations set it
                  example: invalid_config
                issues:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        description: JSON path into the submitted document
                        example: config.plans[0].version.features[1].featureSlug
                      message:
                        type: string
                    required:
                      - path
                      - message
                  description: Per-location detail, when the failure has locations
              required:
                - kind
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrUnauthorized:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - UNAUTHORIZED
              description: A machine readable error code.
              example: UNAUTHORIZED
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: https://docs.unprice.dev/api-reference/errors/code/UNAUTHORIZED
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
            details:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                    - invalid_config
                    - slug_conflict
                    - unresolved_reference
                  description: >-
                    What kind of failure this is. Currently only the
                    monetization configuration operations set it
                  example: invalid_config
                issues:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        description: JSON path into the submitted document
                        example: config.plans[0].version.features[1].featureSlug
                      message:
                        type: string
                    required:
                      - path
                      - message
                  description: Per-location detail, when the failure has locations
              required:
                - kind
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrForbidden:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - FORBIDDEN
              description: A machine readable error code.
              example: FORBIDDEN
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: https://docs.unprice.dev/api-reference/errors/code/FORBIDDEN
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
            details:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                    - invalid_config
                    - slug_conflict
                    - unresolved_reference
                  description: >-
                    What kind of failure this is. Currently only the
                    monetization configuration operations set it
                  example: invalid_config
                issues:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        description: JSON path into the submitted document
                        example: config.plans[0].version.features[1].featureSlug
                      message:
                        type: string
                    required:
                      - path
                      - message
                  description: Per-location detail, when the failure has locations
              required:
                - kind
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrNotFound:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - NOT_FOUND
              description: A machine readable error code.
              example: NOT_FOUND
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: https://docs.unprice.dev/api-reference/errors/code/NOT_FOUND
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
            details:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                    - invalid_config
                    - slug_conflict
                    - unresolved_reference
                  description: >-
                    What kind of failure this is. Currently only the
                    monetization configuration operations set it
                  example: invalid_config
                issues:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        description: JSON path into the submitted document
                        example: config.plans[0].version.features[1].featureSlug
                      message:
                        type: string
                    required:
                      - path
                      - message
                  description: Per-location detail, when the failure has locations
              required:
                - kind
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrConflict:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - CONFLICT
              description: A machine readable error code.
              example: CONFLICT
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: https://docs.unprice.dev/api-reference/errors/code/CONFLICT
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
            details:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                    - invalid_config
                    - slug_conflict
                    - unresolved_reference
                  description: >-
                    What kind of failure this is. Currently only the
                    monetization configuration operations set it
                  example: invalid_config
                issues:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        description: JSON path into the submitted document
                        example: config.plans[0].version.features[1].featureSlug
                      message:
                        type: string
                    required:
                      - path
                      - message
                  description: Per-location detail, when the failure has locations
              required:
                - kind
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrPreconditionFailed:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - PRECONDITION_FAILED
              description: A machine readable error code.
              example: PRECONDITION_FAILED
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: >-
                https://docs.unprice.dev/api-reference/errors/code/PRECONDITION_FAILED
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
            details:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                    - invalid_config
                    - slug_conflict
                    - unresolved_reference
                  description: >-
                    What kind of failure this is. Currently only the
                    monetization configuration operations set it
                  example: invalid_config
                issues:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        description: JSON path into the submitted document
                        example: config.plans[0].version.features[1].featureSlug
                      message:
                        type: string
                    required:
                      - path
                      - message
                  description: Per-location detail, when the failure has locations
              required:
                - kind
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrPayloadTooLarge:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - PAYLOAD_TOO_LARGE
              description: A machine readable error code.
              example: PAYLOAD_TOO_LARGE
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: >-
                https://docs.unprice.dev/api-reference/errors/code/PAYLOAD_TOO_LARGE
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
            details:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                    - invalid_config
                    - slug_conflict
                    - unresolved_reference
                  description: >-
                    What kind of failure this is. Currently only the
                    monetization configuration operations set it
                  example: invalid_config
                issues:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        description: JSON path into the submitted document
                        example: config.plans[0].version.features[1].featureSlug
                      message:
                        type: string
                    required:
                      - path
                      - message
                  description: Per-location detail, when the failure has locations
              required:
                - kind
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrTooManyRequests:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - TOO_MANY_REQUESTS
              description: A machine readable error code.
              example: TOO_MANY_REQUESTS
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: >-
                https://docs.unprice.dev/api-reference/errors/code/TOO_MANY_REQUESTS
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
            details:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                    - invalid_config
                    - slug_conflict
                    - unresolved_reference
                  description: >-
                    What kind of failure this is. Currently only the
                    monetization configuration operations set it
                  example: invalid_config
                issues:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        description: JSON path into the submitted document
                        example: config.plans[0].version.features[1].featureSlug
                      message:
                        type: string
                    required:
                      - path
                      - message
                  description: Per-location detail, when the failure has locations
              required:
                - kind
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrInternalServerError:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - INTERNAL_SERVER_ERROR
              description: A machine readable error code.
              example: INTERNAL_SERVER_ERROR
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: >-
                https://docs.unprice.dev/api-reference/errors/code/INTERNAL_SERVER_ERROR
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
            details:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                    - invalid_config
                    - slug_conflict
                    - unresolved_reference
                  description: >-
                    What kind of failure this is. Currently only the
                    monetization configuration operations set it
                  example: invalid_config
                issues:
                  type: array
                  items:
                    type: object
                    properties:
                      path:
                        type: string
                        description: JSON path into the submitted document
                        example: config.plans[0].version.features[1].featureSlug
                      message:
                        type: string
                    required:
                      - path
                      - message
                  description: Per-location detail, when the failure has locations
              required:
                - kind
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
  securitySchemes:
    bearerAuth:
      bearerFormat: root key
      type: http
      scheme: bearer
      x-speakeasy-example: UNPRICE_API_KEY

````