> ## 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.

# Create billing plan

> Create an AI billing plan; metered overage also provisions the catalog products needed for invoicing.



## OpenAPI

````yaml post /v1/ai/billing/plans
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/ai/billing/plans:
    post:
      tags:
        - Agents > Billing > Plans
      summary: Create billing plan
      description: >-
        Create an AI billing plan; metered overage also provisions the catalog
        products needed for invoicing.
      operationId: createAgentPlan
      requestBody:
        description: Create plan payload
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 120
                  description: Human-readable resource name.
                  example: Support agent plan
                credit_product_id:
                  type:
                    - string
                    - 'null'
                  minLength: 1
                  description: >-
                    ID of the credit product every customer on the plan draws
                    from. Credits plans only; null leaves each customer's policy
                    to name its own. On replacement, omission preserves the
                    current product and null clears it. Rejected while a
                    customer on the plan draws from another product.
                  example: prd_credits
                rate_card_id:
                  type:
                    - string
                    - 'null'
                  minLength: 1
                  description: >-
                    ID of the attached rate card. On policy writes, omission
                    preserves the current reference and null detaches it; on
                    plan replacement omission clears it.
                  example: airc_example
                agents:
                  type: array
                  items:
                    type: object
                    properties:
                      agent_slug:
                        type: string
                        minLength: 1
                        maxLength: 128
                        description: >-
                          Slug of the agent this entry prices, as its records
                          report it (trimmed, lowercase). Must name an agent of
                          the workspace.
                        example: support
                      rate_card_id:
                        type:
                          - string
                          - 'null'
                        minLength: 1
                        description: >-
                          ID of the rate card that prices this agent on the
                          plan, or null for the plan's own card. Its
                          denomination must match the plan's mode.
                        example: airc_support
                    required:
                      - agent_slug
                      - rate_card_id
                  maxItems: 200
                  description: >-
                    Agents the plan lists, each with its own rate card or null
                    for the plan's. Listing an agent does two things: it prices
                    that agent's records with its card first (falling through to
                    the plan's card row by row), and it routes that agent to
                    this plan for every customer on it, ahead of an all-agents
                    plan. So an agent listed only to give it a price on a plan
                    with `all_agents_enabled` still counts as listed: attaching
                    a customer who has another plan listing the same agent is
                    rejected (`plan_agent_conflict`), and so is listing it here
                    while such a customer is attached
                    (`agent_routing_conflict`). At most one entry per agent. On
                    replacement, omission keeps the current list and an empty
                    list clears it.
                  example:
                    - agent_id: aiap_example
                      agent_slug: support
                      rate_card_id: airc_support
                all_agents_enabled:
                  type: boolean
                  description: >-
                    Whether the plan bills every agent of its customers, besides
                    the agents it lists. When false, only the listed agents are
                    billed through it, and an agent no plan of the customer
                    covers is recorded and not billed. Defaults to true on
                    creation; on replacement, omission keeps the current value.
                    Turning it on, or listing an agent, is rejected while a
                    customer on the plan already gets that agent through another
                    plan.
                  example: true
                overage_mode:
                  type:
                    - string
                    - 'null'
                  enum:
                    - refuse
                    - metered
                    - usage_events
                  description: >-
                    Behavior when credits or an allowance are exhausted. Policy
                    values may inherit the attached plan.


                    - refuse: Rejects the call that crosses the boundary without
                    deducting usage.

                    - metered: Prices the whole call as monetary overage, using
                    the overage card or USD provider cost plus markup.

                    - usage_events: Accepts the call as overage and bills it as
                    usage events (`event_type: ai_overage_usage`, one per item
                    with its `units`) priced by your catalog.
                    overage_markup_percent and overage_rate_card_id must be
                    null. Not available in wallet mode.
                  example: metered
                markup_percent:
                  type:
                    - string
                    - 'null'
                  maxLength: 40
                  pattern: ^\d+(\.\d+)?$
                  description: >-
                    Percentage added to resolved cost. Null on writes means no
                    override; an attached plan may supply the value.
                  example: '20'
                overage_markup_percent:
                  type:
                    - string
                    - 'null'
                  maxLength: 40
                  pattern: ^\d+(\.\d+)?$
                  description: >-
                    Percentage added to provider cost for overage. Mutually
                    exclusive with overage_rate_card_id. Null when overage_mode
                    is usage_events.
                  example: '10'
                overage_rate_card_id:
                  type:
                    - string
                    - 'null'
                  minLength: 1
                  description: >-
                    ID of the currency rate card used to price overage directly.
                    Null means provider cost plus the resolved overage markup.
                  example: airc_overage
                windows:
                  type: array
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                        minLength: 1
                        maxLength: 32
                        pattern: ^[a-z0-9][a-z0-9_-]*$
                        description: >-
                          Dimension or allowance identifier used by usage
                          payloads and meter results.
                        example: cached_input_tokens
                      duration_minutes:
                        type: integer
                        minimum: 1
                        maximum: 527040
                        description: >-
                          Rolling allowance duration in whole minutes, from 1
                          through 527040.
                        example: 1440
                      included_units:
                        type: string
                        maxLength: 40
                        pattern: ^\d+(\.\d+)?$
                        description: >-
                          Weighted units included in one allowance window, as an
                          exact decimal string.
                        example: '10000'
                    required:
                      - key
                      - duration_minutes
                      - included_units
                  minItems: 1
                  maxItems: 8
                  description: >-
                    Rolling allowances. Required for windows plans; each window
                    meters every call. A plan replacement replaces the entire
                    array.
                  example:
                    - key: daily
                      duration_minutes: 1440
                      included_units: '10000'
                per_seat_credits:
                  type:
                    - string
                    - 'null'
                  maxLength: 40
                  pattern: ^\d+(\.\d+)?$
                  description: >-
                    Credits granted per seat per billing period. Null grants no
                    credits.
                  example: '10000'
                grant_rollover_enabled:
                  type: boolean
                  description: >-
                    Whether granted credits survive renewal. Purchased credits
                    always roll over.
                  example: true
                settlement_interval_minutes:
                  type:
                    - integer
                    - 'null'
                  minimum: 60
                  maximum: 44640
                  description: >-
                    Settlement interval in minutes. Null means no interval
                    override. Mutually exclusive with settlement_schedule and
                    settlement_threshold_amount.
                  example: 60
                settlement_schedule:
                  type:
                    - string
                    - 'null'
                  enum:
                    - calendar_month
                  description: >-
                    Calendar settlement schedule. Null clears the override;
                    mutually exclusive with settlement_interval_minutes and
                    settlement_threshold_amount.


                    - calendar_month: Settles at the end of each UTC calendar
                    month.
                  example: calendar_month
                settlement_threshold_amount:
                  type:
                    - integer
                    - 'null'
                  minimum: 1
                  maximum: 100000000
                  description: >-
                    Unsettled balance, in whole minor units, at which usage
                    settles. Null means no amount override. Mutually exclusive
                    with settlement_interval_minutes and settlement_schedule,
                    and refused with overage_mode usage_events, whose overage is
                    sent whatever its amount.
                  example: null
                mode:
                  type: string
                  enum:
                    - wallet
                    - credits
                    - windows
                  description: |-
                    Billing mode.

                    - wallet: Charges a monetary wallet.
                    - credits: Consumes a credit balance.
                    - windows: Meters weighted units against rolling allowances.
                  example: wallet
              required:
                - name
                - mode
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Resource ID.
                    example: d18603dd-7285-4bf5-a45e-88d7de8f37c9
                  name:
                    type: string
                    description: Human-readable resource name.
                    example: Support agent plan
                  mode:
                    type: string
                    enum:
                      - wallet
                      - credits
                      - windows
                    description: >-
                      Billing mode.


                      - wallet: Charges a monetary wallet.

                      - credits: Consumes a credit balance.

                      - windows: Meters weighted units against rolling
                      allowances.
                    example: wallet
                  credit_product_id:
                    type:
                      - string
                      - 'null'
                    description: >-
                      ID of the credit product every customer on the plan draws
                      from. Credits plans only; null leaves each customer's
                      policy to name its own. On replacement, omission preserves
                      the current product and null clears it. Rejected while a
                      customer on the plan draws from another product.
                    example: prd_credits
                  rate_card_id:
                    type:
                      - string
                      - 'null'
                    description: >-
                      ID of the attached rate card. On policy writes, omission
                      preserves the current reference and null detaches it; on
                      plan replacement omission clears it.
                    example: airc_example
                  agents:
                    type: array
                    items:
                      type: object
                      properties:
                        agent_id:
                          type: string
                          description: ID of the agent this entry prices.
                          example: aiap_example
                        agent_slug:
                          type: string
                          description: >-
                            Slug of the agent this entry prices, as its records
                            report it (trimmed, lowercase). Must name an agent
                            of the workspace.
                          example: support
                        rate_card_id:
                          type:
                            - string
                            - 'null'
                          description: >-
                            ID of the rate card that prices this agent on the
                            plan, or null for the plan's own card. Its
                            denomination must match the plan's mode.
                          example: airc_support
                      required:
                        - agent_id
                        - agent_slug
                        - rate_card_id
                    description: >-
                      Agents the plan lists, each with its own rate card or null
                      for the plan's. Listing an agent does two things: it
                      prices that agent's records with its card first (falling
                      through to the plan's card row by row), and it routes that
                      agent to this plan for every customer on it, ahead of an
                      all-agents plan. So an agent listed only to give it a
                      price on a plan with `all_agents_enabled` still counts as
                      listed: attaching a customer who has another plan listing
                      the same agent is rejected (`plan_agent_conflict`), and so
                      is listing it here while such a customer is attached
                      (`agent_routing_conflict`). At most one entry per agent.
                      On replacement, omission keeps the current list and an
                      empty list clears it.
                    example:
                      - agent_id: aiap_example
                        agent_slug: support
                        rate_card_id: airc_support
                  all_agents_enabled:
                    type: boolean
                    description: >-
                      Whether the plan bills every agent of its customers,
                      besides the agents it lists. When false, only the listed
                      agents are billed through it, and an agent no plan of the
                      customer covers is recorded and not billed. Defaults to
                      true on creation; on replacement, omission keeps the
                      current value. Turning it on, or listing an agent, is
                      rejected while a customer on the plan already gets that
                      agent through another plan.
                    example: true
                  windows:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                          minLength: 1
                          maxLength: 32
                          pattern: ^[a-z0-9][a-z0-9_-]*$
                          description: >-
                            Dimension or allowance identifier used by usage
                            payloads and meter results.
                          example: cached_input_tokens
                        duration_minutes:
                          type: integer
                          minimum: 1
                          maximum: 527040
                          description: >-
                            Rolling allowance duration in whole minutes, from 1
                            through 527040.
                          example: 1440
                        included_units:
                          type: string
                          maxLength: 40
                          pattern: ^\d+(\.\d+)?$
                          description: >-
                            Weighted units included in one allowance window, as
                            an exact decimal string.
                          example: '10000'
                      required:
                        - key
                        - duration_minutes
                        - included_units
                    description: >-
                      Rolling allowances. Required for windows plans; each
                      window meters every call. A plan replacement replaces the
                      entire array.
                    example:
                      - key: daily
                        duration_minutes: 1440
                        included_units: '10000'
                  markup_percent:
                    type:
                      - string
                      - 'null'
                    pattern: ^-?\d+(\.\d+)?(e[+-]?\d+)?$/i
                    description: >-
                      Percentage added to resolved cost. Null on writes means no
                      override; an attached plan may supply the value.
                    example: '20'
                  overage_mode:
                    type: string
                    enum:
                      - refuse
                      - metered
                      - usage_events
                    description: >-
                      Behavior when credits or an allowance are exhausted.
                      Policy values may inherit the attached plan.


                      - refuse: Rejects the call that crosses the boundary
                      without deducting usage.

                      - metered: Prices the whole call as monetary overage,
                      using the overage card or USD provider cost plus markup.

                      - usage_events: Accepts the call as overage and bills it
                      as usage events (`event_type: ai_overage_usage`, one per
                      item with its `units`) priced by your catalog.
                      overage_markup_percent and overage_rate_card_id must be
                      null. Not available in wallet mode.
                    example: metered
                  overage_markup_percent:
                    type:
                      - string
                      - 'null'
                    pattern: ^-?\d+(\.\d+)?(e[+-]?\d+)?$/i
                    description: >-
                      Percentage added to provider cost for overage. Mutually
                      exclusive with overage_rate_card_id. Null when
                      overage_mode is usage_events.
                    example: '10'
                  overage_rate_card_id:
                    type:
                      - string
                      - 'null'
                    description: >-
                      ID of the currency rate card used to price overage
                      directly. Null means provider cost plus the resolved
                      overage markup.
                    example: airc_overage
                  settlement_interval_minutes:
                    type:
                      - number
                      - 'null'
                    description: >-
                      Settlement interval in minutes. Null means no interval
                      override. Mutually exclusive with settlement_schedule and
                      settlement_threshold_amount.
                    example: 60
                  settlement_schedule:
                    type:
                      - string
                      - 'null'
                    enum:
                      - calendar_month
                    description: >-
                      Calendar settlement schedule. Null clears the override;
                      mutually exclusive with settlement_interval_minutes and
                      settlement_threshold_amount.


                      - calendar_month: Settles at the end of each UTC calendar
                      month.
                    example: calendar_month
                  settlement_threshold_amount:
                    type:
                      - number
                      - 'null'
                    description: >-
                      Unsettled balance, in whole minor units, at which usage
                      settles. Null means no amount override. Mutually exclusive
                      with settlement_interval_minutes and settlement_schedule,
                      and refused with overage_mode usage_events, whose overage
                      is sent whatever its amount.
                    example: null
                  per_seat_credits:
                    type:
                      - string
                      - 'null'
                    pattern: ^-?\d+(\.\d+)?(e[+-]?\d+)?$/i
                    description: >-
                      Credits granted per seat per billing period. Null grants
                      no credits.
                    example: '10000'
                  grant_rollover_enabled:
                    type: boolean
                    description: >-
                      Whether granted credits survive renewal. Purchased credits
                      always roll over.
                    example: true
                  billing_item_ids:
                    type: array
                    items:
                      type: string
                    description: >-
                      IDs of the products charged on this plan's invoices, in
                      creation order. Read-only; amounts are defined by the
                      corresponding price configurations.
                    example:
                      - prd_agent_plan
                  price_configuration_ids:
                    type: array
                    items:
                      type: string
                    description: >-
                      IDs of the price configurations matching
                      `billing_item_ids`. Read-only.
                    example:
                      - pcfg_agent_plan
                  using_policy_count:
                    type: number
                    description: >-
                      Number of customer policy scopes referencing this
                      resource.
                    example: 1
                  is_default:
                    type: boolean
                    description: Whether this is the default plan or shared customer scope.
                    example: false
                required:
                  - id
                  - name
                  - mode
                  - credit_product_id
                  - rate_card_id
                  - agents
                  - all_agents_enabled
                  - windows
                  - markup_percent
                  - overage_mode
                  - overage_markup_percent
                  - overage_rate_card_id
                  - settlement_interval_minutes
                  - settlement_schedule
                  - settlement_threshold_amount
                  - per_seat_credits
                  - grant_rollover_enabled
                  - billing_item_ids
                  - price_configuration_ids
                  - using_policy_count
                  - is_default
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                required:
                  - message
        '409':
          description: The request conflicts with the current configuration.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                required:
                  - message
      security:
        - bearer: []
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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