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

# Nutzerpläne in einem Rutsch setzen

> Setze einen Plan für bis zu 500 Mitglieder in einem Aufruf

Liste aktive menschliche Mitglieder, ändere einen Plan und setze das Extra-Usage-Budget über dem enthaltenen Kontingent. Beträge sind US-Dollar.

Die Aufrufe laufen über den `BILLING_API` Scope des Workspace-API-Schlüssels. Schreibzugriffe laufen als der Service Account, dem der Schlüssel gehört. Diese API lädt niemanden ein und deaktiviert niemanden. Dafür nutzt du die [User Management API](https://docs.langdock.com/de/developer/user-management-api/user-management-overview.md).

## Basis-URL

```
https://api.langdock.com/billing/v1/bring-your-own-keys/users/plan/bulk
```

> [!WARNING]
>
> **Dedicated Deployments**
>
> Ersetze `api.langdock.com` durch `<your-deployment-url>/api/public` in allen Anfragen.

## Voraussetzungen

* **API-Schlüssel** mit dem Scope `BILLING_API`
* Der Besitzer ist ein Service Account, der nicht gelöscht ist und eine aktive Admin-Mitgliedschaft hat
* `USER_MANAGEMENT_API` am selben Schlüssel, wenn du `email`, `name` oder einen E-Mail-Filter brauchst

## Pläne in einem Rutsch ändern

`POST /users/plan/bulk` setzt einen Plan für 1 bis 500 Mitglieder-IDs.

```json theme={null}
{
  "userIds": [
    "11111111-1111-4111-8111-111111111111",
    "55555555-5555-4555-8555-555555555555"
  ],
  "plan": "power_user"
}
```

```json theme={null}
{
  "plan": "power_user",
  "updatedUserIds": ["11111111-1111-4111-8111-111111111111"],
  "alreadyOnPlanUserIds": ["55555555-5555-4555-8555-555555555555"]
}
```

Doppelte IDs zählen einmal. Ist eine ID kein aktives menschliches Mitglied des Workspace, kommt `400` mit diesen IDs in `details.userIds` und es ändert sich nichts. Mitglieder, die den Plan schon haben, stehen in `alreadyOnPlanUserIds` und bleiben unverändert. Für Nutzungsanfragen gelten dieselben Regeln wie beim einzelnen Planwechsel: `power_user` schließt verknüpfte offene Anfragen, `standard` schließt keine.

> [!NOTE]
>
> Langdock blockiert bewusst Browser-basierte Anfragen, um deinen API-Schlüssel zu schützen und die Sicherheit deiner Anwendungen zu gewährleisten. Weitere Informationen findest du in unserem Guide zu [Best Practices für API-Schlüssel](https://docs.langdock.com/de/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices.md).


## OpenAPI

````yaml POST /billing/v1/bring-your-own-keys/users/plan/bulk
openapi: 3.0.0
info:
  title: Langdock API
  version: 3.0.0
servers:
  - url: https://api.langdock.com
    description: Production
security:
  - bearerAuth: []
paths:
  /billing/v1/bring-your-own-keys/users/plan/bulk:
    post:
      tags:
        - Users
      summary: Set plans for 1 to 500 users
      description: >-
        If any ID is not an active human workspace member, returns 400 with
        details.userIds and changes nothing. alreadyOnPlanUserIds identifies
        members unchanged because they already had the plan.
      operationId: setByokBillingUserPlansBulk
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ByokBulkPlanRequest'
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ByokBulkPlanResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '405':
          $ref: '#/components/responses/MethodNotAllowed'
        '409':
          $ref: '#/components/responses/ModeMismatch'
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  schemas:
    ByokBulkPlanRequest:
      type: object
      additionalProperties: false
      required:
        - userIds
        - plan
      properties:
        userIds:
          type: array
          items:
            type: string
            format: uuid
          minItems: 1
          maxItems: 500
        plan:
          $ref: '#/components/schemas/ByokPlan'
    ByokBulkPlanResult:
      type: object
      additionalProperties: false
      required:
        - plan
        - updatedUserIds
        - alreadyOnPlanUserIds
      properties:
        plan:
          $ref: '#/components/schemas/ByokPlan'
        updatedUserIds:
          type: array
          items:
            type: string
            format: uuid
        alreadyOnPlanUserIds:
          type: array
          items:
            type: string
            format: uuid
    ByokPlan:
      type: string
      enum:
        - standard
        - power_user
    Error:
      type: object
      additionalProperties: false
      required:
        - message
        - code
      properties:
        message:
          type: string
        code:
          type: string
        details:
          type: object
          additionalProperties: true
          description: >-
            Optional structured details specific to the error code, such as
            userIds for invalid bulk members.
    ModeMismatchError:
      type: object
      additionalProperties: false
      required:
        - message
        - code
        - details
      properties:
        message:
          type: string
        code:
          type: string
          enum:
            - BILLING_MODE_MISMATCH
        details:
          type: object
          additionalProperties: false
          required:
            - mode
          properties:
            mode:
              type: string
              enum:
                - ai-models-included
                - bring-your-own-keys
  responses:
    BadRequest:
      description: >-
        Invalid body/query, unknown fields, empty PATCH, invalid limit, invalid
        bulk member IDs, or a cursor outside this workspace (INVALID_CURSOR).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid authentication.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >-
        Missing Billing scope, personal key, unavailable feature, missing active
        service-account Admin authority, or email filter without the
        USER_MANAGEMENT_API scope.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: >-
        Resource not in this workspace, inactive/non-human user, privacy-hidden
        agent, usage request not found for that member, or endpoint unavailable
        in this mode.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    MethodNotAllowed:
      description: Unsupported HTTP method.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ModeMismatch:
      description: >-
        Workspace mode differs from the requested mode. details.mode identifies
        the workspace mode.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ModeMismatchError'
    TooManyRequests:
      description: API rate limit exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"

````

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