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

# Reallocate Credit Limits

> Postpaid, individual-billing families only. Sets every active sub-workspace's credit limit in one call and optionally the family total. The map must name every active sub-workspace exactly once; a slice cannot drop below what that sub-workspace has already used this month, the slices cannot exceed the family total, and what remains for the primary must cover its own usage. Not applicable to common-billing families, where credit is pooled on the primary.

Set every sub-workspace's credit limit in one call, and optionally the family total. Postpaid families in **individual** billing mode only.

## When to use

* Splitting the family's credit limit across clients or teams.
* Raising one client's limit at month end while keeping the total unchanged.

## Request parameters

| Parameter             | Type   | Required | Description                                                                                                                                                  |
| --------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `allocations`         | object | Yes      | Map of `sub_workspace_id` to its new credit limit. Must include **every active sub-workspace exactly once**. Values are absolute, `0` or more, two decimals. |
| `parent_credit_limit` | number | No       | New family total (the primary's credit limit). Omit to keep the current total.                                                                               |

## Rules

* A sub-workspace's limit cannot go below what it has already used this month.
* The sum of all allocations cannot exceed the family total. Allocating less than the total is allowed; the remainder stays with the primary.
* What remains with the primary must still cover the primary's own utilized amount.

## Integration notes

* Authenticate with the primary workspace's API key.
* Read the current limits and usage from [Get Sub-workspaces](/api-reference/endpoint/sub-workspace/get-sub-workspaces) first, then send the full map.
* Amounts in the response are **decimal strings** (`"200000.00"`), unlike the read endpoints.

<Note>
  In a **common-billing** family there are no per-sub-workspace limits: every charge utilizes the primary's single credit limit. This endpoint returns `400 This family uses common billing; per-sub credit limits do not exist.` Allocate [concurrency](/api-reference/endpoint/sub-workspace/allocate-concurrency) instead.
</Note>

## Error responses

* **400**: `Credit-limit reallocation applies to postpaid families only.`
* **400**: `This family uses common billing; per-sub credit limits do not exist.`
* **400**: `Allocations must cover every active sub-workspace exactly once. Missing: [...]; unknown: [...].`
* **400**: `Credit limit 100.00 for sub-workspace 'Mumbai Collections' is below its utilized amount 34210.50.`
* **400**: `The total credit limit across sub-workspaces must not exceed the parent workspace's credit limit (500000.00); allocations sum to 600000.00.`
* **400**: `These allocations would leave the primary workspace with 1000.00, below its already-utilized 12500.00. Lower the sub-workspace limits or raise the primary credit limit.`
* **401**: Invalid or missing API key.
* **403**: `Sub-workspaces are not enabled for this workspace.`
* **404**: `Workspace is not a sub-workspace family parent.` — the primary has no sub-workspaces yet.
* **422**: Empty map, negative value, or a key that is not a UUID.

## Example

```bash theme={null}
curl --request PATCH "https://prod-api.ringg.ai/ca/api/v0/workspace/sub/credit-limits" \
  --header "X-API-KEY: $RINGG_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "parent_credit_limit": 500000.00,
    "allocations": {
      "b7c1f0e2-4d3a-4a91-9f2e-8c1d5a6b7e30": 200000.00,
      "d21e8c55-9a0f-4c3b-86de-1f4b7a2c9e88": 150000.00
    }
  }'
```


## OpenAPI

````yaml patch /workspace/sub/credit-limits
openapi: 3.0.0
info:
  title: Ringg AI API Documentation
  description: >-
    This is the documentation for the Ringg AI APIs. The Ringg AI API follows
    RESTful principles, making it intuitive and easy to integrate with your
    applications. All API requests should be made to the base URL. The API
    accepts and returns data in JSON format. Ensure your requests include the
    appropriate Content-Type header for POST and PATCH requests.
  version: 2.0.0
servers:
  - url: https://prod-api.ringg.ai/ca/api/v0
security: []
tags:
  - name: workspace
    description: Endpoints for managing your workspace.
  - name: agent
    description: Endpoints for managing assistants (agents).
  - name: calling
    description: Endpoints for making and managing calls.
  - name: campaign
    description: Endpoints for managing campaigns.
  - name: analytics
    description: Endpoints for accessing call analytics and performance metrics.
  - name: termination
    description: Endpoints for terminating active calls using different methods.
  - name: knowledgebase
    description: Endpoints for managing knowledge bases.
paths:
  /workspace/sub/credit-limits:
    patch:
      tags:
        - workspace
      summary: Reallocate Credit Limits
      description: >-
        Postpaid, individual-billing families only. Sets every active
        sub-workspace's credit limit in one call and optionally the family
        total. The map must name every active sub-workspace exactly once; a
        slice cannot drop below what that sub-workspace has already used this
        month, the slices cannot exceed the family total, and what remains for
        the primary must cover its own usage. Not applicable to common-billing
        families, where credit is pooled on the primary.
      operationId: reallocateSubWorkspaceCreditLimits
      parameters:
        - name: X-API-KEY
          in: header
          description: >-
            (Required) The API key of the PRIMARY workspace. A sub-workspace's
            key is refused with 400.
          required: true
          schema:
            type: string
            example: 7251cb4b-3373-43a4-844c-b27a1d45e0c9
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - allocations
              properties:
                allocations:
                  type: object
                  description: >-
                    (Required) sub_workspace_id -> new credit limit. Must
                    include every active sub-workspace exactly once. Values >=
                    0, two decimals.
                  additionalProperties:
                    type: number
                parent_credit_limit:
                  type: number
                  minimum: 0
                  description: >-
                    (Optional) New family total (the primary's credit limit).
                    Omit to keep the current total.
                  example: 500000
            example:
              parent_credit_limit: 500000
              allocations:
                b7c1f0e2-4d3a-4a91-9f2e-8c1d5a6b7e30: 200000
                d21e8c55-9a0f-4c3b-86de-1f4b7a2c9e88: 150000
      responses:
        '200':
          description: >-
            Successful Response: The applied limits. Amounts are decimal
            strings.
          content:
            application/json:
              schema:
                type: object
                properties:
                  parent_workspace_id:
                    type: string
                    example: 2f9a1c44-7e88-4bb1-9a01-5d3c2e7f6a11
                  parent_credit_limit:
                    type: string
                    description: The family total, as a decimal string.
                    example: '500000.00'
                  allocations:
                    type: object
                    additionalProperties:
                      type: string
                    example:
                      b7c1f0e2-4d3a-4a91-9f2e-8c1d5a6b7e30: '200000.00'
                      d21e8c55-9a0f-4c3b-86de-1f4b7a2c9e88: '150000.00'
                  primary:
                    type: object
                    properties:
                      id:
                        type: string
                        example: 2f9a1c44-7e88-4bb1-9a01-5d3c2e7f6a11
                      name:
                        type: string
                        example: Acme Collections HQ
              example:
                parent_workspace_id: 2f9a1c44-7e88-4bb1-9a01-5d3c2e7f6a11
                parent_credit_limit: '500000.00'
                allocations:
                  b7c1f0e2-4d3a-4a91-9f2e-8c1d5a6b7e30: '200000.00'
                  d21e8c55-9a0f-4c3b-86de-1f4b7a2c9e88: '150000.00'
                primary:
                  id: 2f9a1c44-7e88-4bb1-9a01-5d3c2e7f6a11
                  name: Acme Collections HQ
        '400':
          description: >-
            Bad Request - Wrong billing mode, an incomplete map, or an
            allocation the family cannot cover.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: >-
                      This family uses common billing; per-sub credit limits do
                      not exist.
        '401':
          description: Unauthorized - Invalid or missing API key.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        example: 401 Unauthorized
                      message:
                        type: string
                        example: Invalid credentials
        '403':
          description: >-
            Forbidden - Sub-workspaces are not enabled for this workspace, or
            the caller is not an active member of the primary.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Sub-workspaces are not enabled for this workspace.
        '404':
          description: Not Found - The primary has no sub-workspaces yet.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Workspace is not a sub-workspace family parent.
        '500':
          description: Internal Server Error - Something went wrong on our end.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        example: 500 Internal Server Error
                      message:
                        type: string
                        example: An unexpected error occurred on the server.

````