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

# Configure a customer's agent billing policy

> Create or replace one billing scope — the default policy, or one agent's own when `agent` is passed. Whole-row replacement. Sending `plan_id` attaches the customer to that plan: the plan supplies the mode, overage stance, rate card, windows and markups, and when the plan carries a minted invoice container the customer's subscription gains its overage line (a minimal monthly subscription is opened when they have none). Choosing wallet mode opens the customer's wallet if they have none; credits mode opens their pot. Both open EMPTY — the policy makes the customer billable, it grants them nothing.



## OpenAPI

````yaml put /v1/agents/customers/{customer_id}/policy
openapi: 3.1.0
info:
  title: Hyperline API
  version: 0.0.0
servers:
  - url: https://api.hyperline.co
  - url: https://sandbox.api.hyperline.co
security: []
paths:
  /v1/agents/customers/{customer_id}/policy:
    put:
      tags:
        - Agents
      summary: Configure a customer's agent billing policy
      description: >-
        Create or replace one billing scope — the default policy, or one agent's
        own when `agent` is passed. Whole-row replacement. Sending `plan_id`
        attaches the customer to that plan: the plan supplies the mode, overage
        stance, rate card, windows and markups, and when the plan carries a
        minted invoice container the customer's subscription gains its overage
        line (a minimal monthly subscription is opened when they have none).
        Choosing wallet mode opens the customer's wallet if they have none;
        credits mode opens their pot. Both open EMPTY — the policy makes the
        customer billable, it grants them nothing.
      operationId: upsertAgentCustomerPolicy
      parameters:
        - schema:
            type: string
          required: true
          name: customer_id
          in: path
        - schema:
            type: string
            minLength: 1
            maxLength: 128
          required: false
          name: agent
          in: query
      requestBody:
        description: Upsert billing policy payload
        content:
          application/json:
            schema:
              type: object
              properties:
                internal_description:
                  type:
                    - string
                    - 'null'
                  maxLength: 1000
                mode:
                  type: string
                  enum:
                    - wallet
                    - credits
                    - windows
                wallet_id:
                  type:
                    - string
                    - 'null'
                  minLength: 1
                credit_product_id:
                  type:
                    - string
                    - 'null'
                  minLength: 1
                markup_percent:
                  type:
                    - string
                    - 'null'
                  pattern: ^\d+(\.\d+)?$
                overage_mode:
                  type:
                    - string
                    - 'null'
                  enum:
                    - refuse
                    - metered
                overage_markup_percent:
                  type:
                    - string
                    - 'null'
                  pattern: ^\d+(\.\d+)?$
                overage_rate_card_id:
                  type:
                    - string
                    - 'null'
                  minLength: 1
                overage_wallet_id:
                  type:
                    - string
                    - 'null'
                  minLength: 1
                floor:
                  type:
                    - string
                    - 'null'
                  pattern: ^\d+(\.\d+)?$
                settlement_interval_minutes:
                  type:
                    - integer
                    - 'null'
                  minimum: 60
                  maximum: 44640
                settlement_schedule:
                  type:
                    - string
                    - 'null'
                  enum:
                    - calendar_month
                credit_rates:
                  type:
                    - object
                    - 'null'
                  properties:
                    llm:
                      type: array
                      items:
                        type: object
                        properties:
                          provider:
                            type: string
                            minLength: 1
                            maxLength: 64
                          model:
                            type: string
                            minLength: 1
                            maxLength: 128
                          credits_per_1m_input:
                            type: string
                            maxLength: 40
                            pattern: ^\d+(\.\d+)?$
                          credits_per_1m_output:
                            type: string
                            maxLength: 40
                            pattern: ^\d+(\.\d+)?$
                          credits_per_1m_cached_input:
                            type: string
                            maxLength: 40
                            pattern: ^\d+(\.\d+)?$
                          credits_per_1m_cache_write:
                            type: string
                            maxLength: 40
                            pattern: ^\d+(\.\d+)?$
                          dimensions:
                            type: array
                            items:
                              type: object
                              properties:
                                key:
                                  type: string
                                  pattern: ^[a-z0-9_.]{1,64}$
                                rate:
                                  type: string
                                  maxLength: 40
                                  pattern: ^\d+(\.\d+)?$
                                per:
                                  type: string
                                  enum:
                                    - 1m
                                    - 1k
                                    - unit
                              required:
                                - key
                                - rate
                                - per
                            maxItems: 20
                        required:
                          - credits_per_1m_input
                          - credits_per_1m_output
                      maxItems: 500
                    items:
                      type: array
                      items:
                        type: object
                        properties:
                          vendor:
                            type: string
                            minLength: 1
                            maxLength: 64
                          item:
                            type: string
                            minLength: 1
                            maxLength: 128
                          credits_per_unit:
                            type: string
                            maxLength: 40
                            pattern: ^\d+(\.\d+)?$
                          dimensions:
                            type: array
                            items:
                              type: object
                              properties:
                                key:
                                  type: string
                                  pattern: ^[a-z0-9_.]{1,64}$
                                rate:
                                  type: string
                                  maxLength: 40
                                  pattern: ^\d+(\.\d+)?$
                                per:
                                  type: string
                                  enum:
                                    - 1m
                                    - 1k
                                    - unit
                              required:
                                - key
                                - rate
                                - per
                            maxItems: 20
                        required:
                          - vendor
                          - item
                          - credits_per_unit
                      maxItems: 500
                    fallback_credits_per_usd:
                      type: string
                      pattern: ^\d+(\.\d+)?$
                window_rates:
                  type:
                    - object
                    - 'null'
                  properties:
                    unit_rates:
                      type: object
                      properties:
                        llm:
                          type: array
                          items:
                            type: object
                            properties:
                              provider:
                                type: string
                                minLength: 1
                                maxLength: 64
                              model:
                                type: string
                                minLength: 1
                                maxLength: 128
                              units_per_1m_input:
                                type: string
                                maxLength: 40
                                pattern: ^\d+(\.\d+)?$
                              units_per_1m_output:
                                type: string
                                maxLength: 40
                                pattern: ^\d+(\.\d+)?$
                              units_per_1m_cached_input:
                                type: string
                                maxLength: 40
                                pattern: ^\d+(\.\d+)?$
                              units_per_1m_cache_write:
                                type: string
                                maxLength: 40
                                pattern: ^\d+(\.\d+)?$
                              dimensions:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    key:
                                      type: string
                                      pattern: ^[a-z0-9_.]{1,64}$
                                    rate:
                                      type: string
                                      maxLength: 40
                                      pattern: ^\d+(\.\d+)?$
                                    per:
                                      type: string
                                      enum:
                                        - 1m
                                        - 1k
                                        - unit
                                  required:
                                    - key
                                    - rate
                                    - per
                                maxItems: 20
                            required:
                              - units_per_1m_input
                              - units_per_1m_output
                          maxItems: 500
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              vendor:
                                type: string
                                minLength: 1
                                maxLength: 64
                              item:
                                type: string
                                minLength: 1
                                maxLength: 128
                              units_per_unit:
                                type: string
                                maxLength: 40
                                pattern: ^\d+(\.\d+)?$
                              dimensions:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    key:
                                      type: string
                                      pattern: ^[a-z0-9_.]{1,64}$
                                    rate:
                                      type: string
                                      maxLength: 40
                                      pattern: ^\d+(\.\d+)?$
                                    per:
                                      type: string
                                      enum:
                                        - 1m
                                        - 1k
                                        - unit
                                  required:
                                    - key
                                    - rate
                                    - per
                                maxItems: 20
                            required:
                              - vendor
                              - item
                              - units_per_unit
                          maxItems: 500
                        fallback_units_per_usd:
                          type: string
                          pattern: ^\d+(\.\d+)?$
                    windows:
                      type: array
                      items:
                        type: object
                        properties:
                          key:
                            type: string
                            minLength: 1
                            maxLength: 32
                            pattern: ^[a-z0-9][a-z0-9_-]*$
                          duration_minutes:
                            type: integer
                            minimum: 1
                            maximum: 527040
                          included_units:
                            type: string
                            maxLength: 40
                            pattern: ^\d+(\.\d+)?$
                        required:
                          - key
                          - duration_minutes
                          - included_units
                      minItems: 1
                      maxItems: 8
                  required:
                    - windows
                rate_card_id:
                  type:
                    - string
                    - 'null'
                  minLength: 1
                plan_id:
                  type:
                    - string
                    - 'null'
                  minLength: 1
                blocked:
                  type: boolean
              required:
                - mode
                - blocked
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  customer_id:
                    type: string
                  internal_description:
                    type:
                      - string
                      - 'null'
                  created_at:
                    type: string
                    format: date-time
                    description: >-
                      UTC date time string in the [ISO
                      8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    example: '2024-12-20T16:04:11Z'
                  updated_at:
                    type: string
                    format: date-time
                    description: >-
                      UTC date time string in the [ISO
                      8601](https://en.wikipedia.org/wiki/ISO_8601) format.
                    example: '2024-12-20T16:04:11Z'
                  agent_slug:
                    type: string
                  is_default:
                    type: boolean
                  mode:
                    type: string
                    enum:
                      - wallet
                      - credits
                      - windows
                  wallet_id:
                    type:
                      - string
                      - 'null'
                  credit_product_id:
                    type:
                      - string
                      - 'null'
                  markup_percent:
                    type: string
                  overage_mode:
                    type: string
                    enum:
                      - refuse
                      - metered
                  overage_markup_percent:
                    type: string
                  overage_rate_card_id:
                    type:
                      - string
                      - 'null'
                  overage_rate_card_source:
                    type:
                      - string
                      - 'null'
                    enum:
                      - policy
                      - plan
                  overage_wallet_id:
                    type:
                      - string
                      - 'null'
                  floor:
                    type: string
                  credit_rates:
                    type:
                      - object
                      - 'null'
                    properties:
                      llm:
                        type: array
                        items:
                          type: object
                          properties:
                            provider:
                              type: string
                              minLength: 1
                              maxLength: 64
                            model:
                              type: string
                              minLength: 1
                              maxLength: 128
                            credits_per_1m_input:
                              type: string
                              maxLength: 40
                              pattern: ^\d+(\.\d+)?$
                            credits_per_1m_output:
                              type: string
                              maxLength: 40
                              pattern: ^\d+(\.\d+)?$
                            credits_per_1m_cached_input:
                              type: string
                              maxLength: 40
                              pattern: ^\d+(\.\d+)?$
                            credits_per_1m_cache_write:
                              type: string
                              maxLength: 40
                              pattern: ^\d+(\.\d+)?$
                            dimensions:
                              type: array
                              items:
                                type: object
                                properties:
                                  key:
                                    type: string
                                    pattern: ^[a-z0-9_.]{1,64}$
                                  rate:
                                    type: string
                                    maxLength: 40
                                    pattern: ^\d+(\.\d+)?$
                                  per:
                                    type: string
                                    enum:
                                      - 1m
                                      - 1k
                                      - unit
                                required:
                                  - key
                                  - rate
                                  - per
                              maxItems: 20
                          required:
                            - credits_per_1m_input
                            - credits_per_1m_output
                        maxItems: 500
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            vendor:
                              type: string
                              minLength: 1
                              maxLength: 64
                            item:
                              type: string
                              minLength: 1
                              maxLength: 128
                            credits_per_unit:
                              type: string
                              maxLength: 40
                              pattern: ^\d+(\.\d+)?$
                            dimensions:
                              type: array
                              items:
                                type: object
                                properties:
                                  key:
                                    type: string
                                    pattern: ^[a-z0-9_.]{1,64}$
                                  rate:
                                    type: string
                                    maxLength: 40
                                    pattern: ^\d+(\.\d+)?$
                                  per:
                                    type: string
                                    enum:
                                      - 1m
                                      - 1k
                                      - unit
                                required:
                                  - key
                                  - rate
                                  - per
                              maxItems: 20
                          required:
                            - vendor
                            - item
                            - credits_per_unit
                        maxItems: 500
                      fallback_credits_per_usd:
                        type: string
                        maxLength: 40
                        pattern: ^\d+(\.\d+)?$
                  window_rates:
                    type:
                      - object
                      - 'null'
                    properties:
                      unit_rates:
                        type: object
                        properties:
                          llm:
                            type: array
                            items:
                              type: object
                              properties:
                                provider:
                                  type: string
                                  minLength: 1
                                  maxLength: 64
                                model:
                                  type: string
                                  minLength: 1
                                  maxLength: 128
                                units_per_1m_input:
                                  type: string
                                  maxLength: 40
                                  pattern: ^\d+(\.\d+)?$
                                units_per_1m_output:
                                  type: string
                                  maxLength: 40
                                  pattern: ^\d+(\.\d+)?$
                                units_per_1m_cached_input:
                                  type: string
                                  maxLength: 40
                                  pattern: ^\d+(\.\d+)?$
                                units_per_1m_cache_write:
                                  type: string
                                  maxLength: 40
                                  pattern: ^\d+(\.\d+)?$
                                dimensions:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      key:
                                        type: string
                                        pattern: ^[a-z0-9_.]{1,64}$
                                      rate:
                                        type: string
                                        maxLength: 40
                                        pattern: ^\d+(\.\d+)?$
                                      per:
                                        type: string
                                        enum:
                                          - 1m
                                          - 1k
                                          - unit
                                    required:
                                      - key
                                      - rate
                                      - per
                                  maxItems: 20
                              required:
                                - units_per_1m_input
                                - units_per_1m_output
                            maxItems: 500
                          items:
                            type: array
                            items:
                              type: object
                              properties:
                                vendor:
                                  type: string
                                  minLength: 1
                                  maxLength: 64
                                item:
                                  type: string
                                  minLength: 1
                                  maxLength: 128
                                units_per_unit:
                                  type: string
                                  maxLength: 40
                                  pattern: ^\d+(\.\d+)?$
                                dimensions:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      key:
                                        type: string
                                        pattern: ^[a-z0-9_.]{1,64}$
                                      rate:
                                        type: string
                                        maxLength: 40
                                        pattern: ^\d+(\.\d+)?$
                                      per:
                                        type: string
                                        enum:
                                          - 1m
                                          - 1k
                                          - unit
                                    required:
                                      - key
                                      - rate
                                      - per
                                  maxItems: 20
                              required:
                                - vendor
                                - item
                                - units_per_unit
                            maxItems: 500
                          fallback_units_per_usd:
                            type: string
                            maxLength: 40
                            pattern: ^\d+(\.\d+)?$
                      windows:
                        type: array
                        items:
                          type: object
                          properties:
                            key:
                              type: string
                              minLength: 1
                              maxLength: 32
                              pattern: ^[a-z0-9][a-z0-9_-]*$
                            duration_minutes:
                              type: integer
                              minimum: 1
                              maximum: 527040
                            included_units:
                              type: string
                              maxLength: 40
                              pattern: ^\d+(\.\d+)?$
                          required:
                            - key
                            - duration_minutes
                            - included_units
                        minItems: 1
                        maxItems: 8
                    required:
                      - unit_rates
                      - windows
                  rate_card_id:
                    type:
                      - string
                      - 'null'
                  rate_card_source:
                    type:
                      - string
                      - 'null'
                    enum:
                      - policy
                      - plan
                  plan:
                    type:
                      - object
                      - 'null'
                    properties:
                      id:
                        type: string
                      name:
                        type: string
                    required:
                      - id
                      - name
                  settlement_interval_minutes:
                    type:
                      - number
                      - 'null'
                  settlement_schedule:
                    type:
                      - string
                      - 'null'
                    enum:
                      - calendar_month
                  resolved_rate_card:
                    type:
                      - object
                      - 'null'
                    properties:
                      fallback_per_usd:
                        type:
                          - string
                          - 'null'
                      layer_count:
                        type: number
                      llm_rows:
                        type: number
                      item_rows:
                        type: number
                      has_default_llm_row:
                        type: boolean
                    required:
                      - fallback_per_usd
                      - layer_count
                      - llm_rows
                      - item_rows
                      - has_default_llm_row
                  blocked:
                    type: boolean
                required:
                  - id
                  - customer_id
                  - internal_description
                  - created_at
                  - updated_at
                  - agent_slug
                  - is_default
                  - mode
                  - wallet_id
                  - credit_product_id
                  - markup_percent
                  - overage_mode
                  - overage_markup_percent
                  - overage_rate_card_id
                  - overage_rate_card_source
                  - overage_wallet_id
                  - floor
                  - credit_rates
                  - window_rates
                  - rate_card_id
                  - rate_card_source
                  - plan
                  - settlement_interval_minutes
                  - settlement_schedule
                  - resolved_rate_card
                  - blocked
        '404':
          description: Customer not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                required:
                  - message
      security:
        - bearer: []
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````