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

# Apply rate adjustment to plan instances

> Applies a rate adjustment to each plan instance of the body: the prices of its plan charges rise by the percentage, and a new plan instance version, with the reason readjustment, becomes its active plan instance version. The request applies all the rate adjustments or none, and a plan instance without plan charges stays as it is. With the header `x-override-rate-adjustment-check` set to true, the request also adjusts a plan instance that had a rate adjustment in the last 30 days.

Requires the role `plan_instances:write`.



## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/plan-instances/rate-adjust
openapi: 3.1.0
info:
  title: API Reference
  version: '1.0'
  description: Aira API Reference
  x-logo:
    url: https://static.useaira.com/images/airalogo.svg
    backgroundColor: '#FFFFFF'
    altText: Aira Logo
servers:
  - url: https://api.useaira.com
    description: API base URL
security:
  - ApiKey: []
paths:
  /v1/plan-instances/rate-adjust:
    post:
      tags:
        - Plan Instances
      summary: Apply rate adjustment to plan instances
      description: >-
        Applies a rate adjustment to each plan instance of the body: the prices
        of its plan charges rise by the percentage, and a new plan instance
        version, with the reason readjustment, becomes its active plan instance
        version. The request applies all the rate adjustments or none, and a
        plan instance without plan charges stays as it is. With the header
        `x-override-rate-adjustment-check` set to true, the request also adjusts
        a plan instance that had a rate adjustment in the last 30 days.


        Requires the role `plan_instances:write`.
      parameters:
        - schema:
            type: boolean
          in: header
          name: x-override-rate-adjustment-check
          required: false
          description: >-
            When true, the request also adjusts a plan instance that had a rate
            adjustment in the last 30 days, which it refuses otherwise.
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: object
                description: The rate adjustment of one plan instance.
                properties:
                  planInstanceId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the plan instance whose prices
                      the rate adjustment raises.
                  percentage:
                    type: string
                    pattern: ^\d+(\.\d{1,6})?$
                    description: >-
                      The percentage that the rate adjustment adds to the prices
                      of the plan instance, as a decimal of zero or more with at
                      most six decimal places, such as "5" for a raise of 5%. A
                      percentage of zero leaves the plan instance as it is.
                    example: '5'
                required:
                  - planInstanceId
                  - percentage
                additionalProperties: false
              maxItems: 10000
        description: >-
          The rate adjustments to apply, one for each plan instance, at most
          10,000.
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `plan_instance_rate_adjustment_recently_applied`: a plan instance
            of the body had a rate adjustment in the last 30 days and the header
            `x-override-rate-adjustment-check` is not true, and
            `details.readjustments` lists those rate adjustments.

            - `invalid_plan_charges`: a plan charge of a plan instance of the
            body breaks a rule of plan charges that is newer than the plan
            charge, such as a billing frequency other than 1 or 2 weeks or 1, 3,
            6 or 12 months.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - plan_instance_rate_adjustment_recently_applied
                      - invalid_plan_charges
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: body must be object
                    code: json_schema_validation_error
                plan_instance_rate_adjustment_recently_applied:
                  value:
                    message: Plan instance already rate adjusted in the last 30 days
                    code: plan_instance_rate_adjustment_recently_applied
                invalid_plan_charges:
                  value:
                    message: 'plan charge "{itemName}": {reason}'
                    code: invalid_plan_charges
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the tenant does not allow the IP of the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instances:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist in the tenant.


            - `plan_instance_not_found`: no plan instance of the tenant has a
            `planInstanceId` of the body.

            - `plan_instance_version_not_found`: the active plan instance
            version of a plan instance of the body has the plan charges of a
            plan version whose plan was deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_instance_not_found
                      - plan_instance_version_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_instance_not_found:
                  value:
                    message: plan instance not found
                    code: plan_instance_not_found
                plan_instance_version_not_found:
                  value:
                    message: plan instance version not found
                    code: plan_instance_version_not_found
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      description: API Key Authentication.
      name: X-API-KEY
      in: header

````

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