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

# Update Spending Caps

> Update spending cap configuration.

Configure spending limits and alert thresholds to control costs.

**Features:**
- **Soft Limit (Budget)**: Triggers alerts but doesn't block API access
- **Hard Cap**: Blocks API access when reached (requires explicit enable)
- **Alert Thresholds**: Customize when to receive spending notifications

**Requirements:**
- Admin permission
- Only applies to organizations with auto-billing enabled

**Example:**
```python
# Set $100 budget with alerts at 75% and 100%
response = await client.post(
    "/v1/organizations/billing/spending-caps",
    json={
        "monthly_spending_budget": 10000,  # $100 in cents
        "spending_alert_thresholds": [75, 100],
        "spending_alerts_enabled": True,
    }
)

# Enable hard cap at $500
response = await client.post(
    "/v1/organizations/billing/spending-caps",
    json={
        "hard_spending_cap": 50000,  # $500 in cents
        "hard_cap_enabled": True,
    }
)

# Disable all spending limits
response = await client.post(
    "/v1/organizations/billing/spending-caps",
    json={
        "monthly_spending_budget": None,
        "hard_spending_cap": None,
        "hard_cap_enabled": False,
    }
)
```



## OpenAPI

````yaml post /v1/organizations/billing/spending-caps
openapi: 3.1.0
info:
  title: Mixpeek API
  description: >-
    This is the Mixpeek API, providing access to various endpoints for data
    processing and retrieval.
  termsOfService: https://mixpeek.com/terms
  contact:
    name: Mixpeek Support
    url: https://mixpeek.com/contact
    email: info@mixpeek.com
  version: '0.82'
servers:
  - url: https://api.mixpeek.com
    description: Production
security: []
paths:
  /v1/organizations/billing/spending-caps:
    post:
      tags:
        - Organization Billing
      summary: Update Spending Caps
      description: >-
        Update spending cap configuration.


        Configure spending limits and alert thresholds to control costs.


        **Features:**

        - **Soft Limit (Budget)**: Triggers alerts but doesn't block API access

        - **Hard Cap**: Blocks API access when reached (requires explicit
        enable)

        - **Alert Thresholds**: Customize when to receive spending notifications


        **Requirements:**

        - Admin permission

        - Only applies to organizations with auto-billing enabled


        **Example:**

        ```python

        # Set $100 budget with alerts at 75% and 100%

        response = await client.post(
            "/v1/organizations/billing/spending-caps",
            json={
                "monthly_spending_budget": 10000,  # $100 in cents
                "spending_alert_thresholds": [75, 100],
                "spending_alerts_enabled": True,
            }
        )


        # Enable hard cap at $500

        response = await client.post(
            "/v1/organizations/billing/spending-caps",
            json={
                "hard_spending_cap": 50000,  # $500 in cents
                "hard_cap_enabled": True,
            }
        )


        # Disable all spending limits

        response = await client.post(
            "/v1/organizations/billing/spending-caps",
            json={
                "monthly_spending_budget": None,
                "hard_spending_cap": None,
                "hard_cap_enabled": False,
            }
        )

        ```
      operationId: update_spending_caps_v1_organizations_billing_spending_caps_post
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSpendingCapsRequest'
              description: Spending cap configuration
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpendingCapsResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    UpdateSpendingCapsRequest:
      properties:
        monthly_spending_budget:
          anyOf:
            - type: integer
              minimum: 0
            - type: 'null'
          title: Monthly Spending Budget
          description: >-
            Soft spending limit in USD cents. Triggers alerts but doesn't block
            API access. Set to null to remove budget limit.
          examples:
            - 10000
            - 50000
            - 100000
        spending_alert_thresholds:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Spending Alert Thresholds
          description: >-
            Percentage thresholds for spending alerts (0-100). When current
            spending reaches each threshold, an alert is sent.
          examples:
            - - 50
              - 75
              - 90
              - 100
            - - 80
              - 100
        spending_alerts_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Spending Alerts Enabled
          description: Whether to send spending alerts when thresholds are crossed.
        hard_spending_cap:
          anyOf:
            - type: integer
              minimum: 0
            - type: 'null'
          title: Hard Spending Cap
          description: >-
            Hard spending limit in USD cents. When reached, API access is
            blocked. Set to null to remove hard cap.
          examples:
            - 50000
            - 100000
            - 500000
        hard_cap_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Hard Cap Enabled
          description: Whether to enforce the hard spending cap.
      type: object
      title: UpdateSpendingCapsRequest
      description: Request to update spending cap configuration.
    SpendingCapsResponse:
      properties:
        monthly_spending_budget:
          anyOf:
            - type: integer
            - type: 'null'
          title: Monthly Spending Budget
          description: Soft spending limit in USD cents (null = unlimited)
          examples:
            - 10000
            - 50000
            - 100000
        monthly_spending_budget_usd:
          anyOf:
            - type: number
            - type: 'null'
          title: Monthly Spending Budget Usd
          description: Soft spending limit in USD
          examples:
            - 100
            - 500
            - 1000
        spending_alert_thresholds:
          items:
            type: integer
          type: array
          title: Spending Alert Thresholds
          description: Percentage thresholds for spending alerts
          examples:
            - - 50
              - 75
              - 90
              - 100
        spending_alerts_enabled:
          type: boolean
          title: Spending Alerts Enabled
          description: Whether spending alerts are enabled
          default: true
        spending_alerts_sent:
          items:
            type: integer
          type: array
          title: Spending Alerts Sent
          description: Alert thresholds triggered in current billing cycle
          examples:
            - - 50
              - 75
        hard_spending_cap:
          anyOf:
            - type: integer
            - type: 'null'
          title: Hard Spending Cap
          description: Hard spending limit in USD cents (null = no hard cap)
          examples:
            - 50000
            - 100000
            - 500000
        hard_spending_cap_usd:
          anyOf:
            - type: number
            - type: 'null'
          title: Hard Spending Cap Usd
          description: Hard spending limit in USD
          examples:
            - 500
            - 1000
            - 5000
        hard_cap_enabled:
          type: boolean
          title: Hard Cap Enabled
          description: Whether hard spending cap is enforced
          default: false
        current_spending_cents:
          type: integer
          title: Current Spending Cents
          description: Current spending in current billing cycle (cents)
          examples:
            - 23450
        current_spending_usd:
          type: number
          title: Current Spending Usd
          description: Current spending in current billing cycle (USD)
          examples:
            - 234.5
        budget_percentage_used:
          anyOf:
            - type: number
            - type: 'null'
          title: Budget Percentage Used
          description: Percentage of budget used (null if no budget set)
          examples:
            - 46.9
            - 78.2
      type: object
      required:
        - current_spending_cents
        - current_spending_usd
      title: SpendingCapsResponse
      description: Response with spending cap configuration.
    ErrorResponse:
      properties:
        success:
          type: boolean
          title: Success
          description: Always false for error responses
          default: false
        status:
          type: integer
          title: Status
          description: HTTP status code for this error
        error:
          $ref: '#/components/schemas/ErrorDetail'
          description: Error details payload
      type: object
      required:
        - status
        - error
      title: ErrorResponse
      description: Error response model.
      examples:
        - error:
            details:
              id: ns_123
              resource: namespace
            message: Namespace not found
            type: NotFoundError
          status: 404
          success: false
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ErrorDetail:
      properties:
        message:
          type: string
          title: Message
          description: Human-readable error message
        type:
          type: string
          title: Type
          description: Stable error type identifier (machine-readable)
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
          description: >-
            Fine-grained error code for programmatic handling (e.g.,
            namespace_name_taken, feature_extractor_not_found). Present only
            when consumers may need to branch on a specific error condition.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: >-
            Optional structured details to help debugging (validation errors,
            IDs, etc.)
      type: object
      required:
        - message
        - type
      title: ErrorDetail
      description: Error detail model.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````