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

# Set the seat count

> Raise or lower the seats of a license the customer bought.

Sets the total seats of the customer's license of the seat plan `planId`, included seats counted, and needs an `Idempotency-Key`. Raising bills the paid seats added on the seat price, prorated to the period end, on its own invoice; the seats are added once it's paid, and a new seat's holder gets the seat plan's allowance for what was left of the period. Lowering is `scheduled` for the period end, whose renewal bills fewer, and never goes below the assigned seats (`409 seats_assigned`). The same total, and seats that cost nothing, bill nothing.

The answer is `{ itemChangeId, status, paymentUrl, license }`: `applied`, `scheduled`, `pending_payment` (pay at `paymentUrl`), `processing` (retry with the same key) or `closed`. See [Seats and licenses](https://docs.integrateledger.com/pricing/seat-licenses.md#change-the-seat-count).

Needs the **Billing** permission.


## OpenAPI

````yaml openapi.json POST /v1/licenses
openapi: 3.1.0
info:
  title: Ledger API
  version: 0.1.0
servers:
  - url: https://api.integrateledger.com
    description: Hosted Ledger API
security: []
paths:
  /v1/licenses:
    post:
      tags:
        - Licenses
      summary: Set a license's seat count
      operationId: setLicenseSeats
      parameters:
        - schema:
            type: string
            description: >-
              Required. The same key answers the same change, so a retry never
              bills twice.
          required: false
          description: >-
            Required. The same key answers the same change, so a retry never
            bills twice.
          name: idempotency-key
          in: header
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LicenseSeatCountInput'
      responses:
        '200':
          description: >-
            The seat change: applied (the license holds the new total), waiting
            on payment, or still settling. A raise bills the paid seats added on
            the seat price, a credit at the old paid seats and a charge at the
            new, prorated to the period end.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseSeatCount'
        '400':
          description: >-
            Invalid request, no Idempotency-Key (idempotency_key_required), more
            than the license's maxSeats (max_purchase_exceeded), or fewer than
            its includedSeats (below_included_seats)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseError'
        '401':
          description: Invalid Ledger API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseError'
        '402':
          description: >-
            The saved card was declined (payment_failed). Nothing changed; retry
            with the same Idempotency-Key once the card works.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseError'
        '403':
          $ref: '#/components/responses/InsufficientPermissions'
        '404':
          description: >-
            Customer not found, no live license of the seat plan
            (license_not_found), or no such entity (entity_not_found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseError'
        '409':
          description: >-
            Fewer seats than are assigned (seats_assigned, with assigned),
            another change waiting on the bill, a period-end one included
            (subscription_change_pending), or the key used for another request
            (idempotency_key_mismatch)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseError'
        '413':
          $ref: '#/components/responses/PayloadTooLarge'
        '429':
          $ref: '#/components/responses/RateLimited'
        '502':
          description: Stripe isn't connected or refused the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseError'
        '503':
          description: >-
            Stripe's state doesn't explain the change; retry with the same
            Idempotency-Key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseError'
      security:
        - ApiKey: []
      x-codeSamples:
        - lang: python
          label: Python SDK
          source: >-
            import os

            from integrateledger import ledger


            client = ledger(api_key=os.environ["LEDGER_API_KEY"])

            client.set_license_seats(customer_id="user_123", plan_id="seat",
            seats=5, idempotency_key="seats_123")
        - lang: bash
          label: cURL
          source: |-
            curl --request POST 'https://api.integrateledger.com/v1/licenses' \
              -H "Authorization: Bearer $LEDGER_API_KEY" \
              -H 'Content-Type: application/json' \
              --data '{"customerId":"user_123","planId":"seat","seats":5}'
        - lang: typescript
          label: TypeScript SDK
          source: >-
            import ledger from "integrateledger";


            const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? ""
            });

            await client.setLicenseSeats({ idempotencyKey: "seats_123", body: {
            customerId: "user_123", planId: "seat", seats: 5 } });
components:
  schemas:
    LicenseSeatCountInput:
      type: object
      properties:
        customerId:
          type: string
          minLength: 1
          maxLength: 255
          description: Your ID for the customer, such as your user ID.
        planId:
          type: string
          minLength: 1
          maxLength: 255
          description: >-
            The seat plan whose license to set: a plan the customer's plan sells
            seats of (its licenses).
          example: seat
        seats:
          type: integer
          exclusiveMinimum: 0
          maximum: 100000
          description: >-
            The license's new total seats, the included ones counted. Raising it
            bills the paid seats added, prorated for the rest of the period; the
            same total changes nothing.
          example: 5
      required:
        - customerId
        - planId
        - seats
      additionalProperties: false
    LicenseSeatCount:
      type: object
      properties:
        itemChangeId:
          type:
            - integer
            - 'null'
          exclusiveMinimum: 0
          description: >-
            The billing change a paid raise made, the same on every retry with
            its Idempotency-Key. Null when nothing was billed: the same total,
            or seats that cost nothing.
        status:
          type: string
          enum:
            - applied
            - pending_payment
            - processing
            - closed
          description: >-
            applied: the license holds the new total. pending_payment: the
            invoice needs the customer at paymentUrl, and nothing changes until
            it's paid. processing: Stripe is still settling it; retry with the
            same key. closed: the invoice was voided and nothing changed.
        paymentUrl:
          type:
            - string
            - 'null'
        license:
          $ref: '#/components/schemas/License'
      required:
        - itemChangeId
        - status
        - paymentUrl
        - license
    LicenseError:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
        assigned:
          type: integer
          minimum: 0
          description: >-
            On seats_assigned: the seats assigned now, the lowest total the
            license can go to.
        itemChangeId:
          type: integer
          exclusiveMinimum: 0
      required:
        - error
    License:
      type:
        - object
        - 'null'
      properties:
        planId:
          type: string
          description: The seat plan sold.
        parentPlanId:
          type: string
          description: The customer's plan that sells the seats.
        seats:
          type: integer
          exclusiveMinimum: 0
          description: >-
            Seats the customer holds, the included ones counted. Only seats
            above includedSeats are billed.
        includedSeats:
          type: integer
          minimum: 0
        assigned:
          type: integer
          minimum: 0
        available:
          type: integer
          minimum: 0
        assignments:
          type: array
          items:
            $ref: '#/components/schemas/LicenseAssignment'
          description: Who holds which seat, by slot.
      required:
        - planId
        - parentPlanId
        - seats
        - includedSeats
        - assigned
        - available
        - assignments
      description: The license as it stands now.
    InsufficientPermissionsError:
      type: object
      properties:
        error:
          type: string
          example: insufficient_permissions
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
        requiredScope:
          type: string
          example: customers:read
      required:
        - error
        - requiredScope
    PayloadTooLargeError:
      type: object
      properties:
        error:
          type: string
          example: payload_too_large
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
      required:
        - error
    RateLimitError:
      type: object
      properties:
        error:
          type: string
          example: rate_limited
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
      required:
        - error
    LicenseAssignment:
      type: object
      properties:
        slot:
          type: integer
          exclusiveMinimum: 0
        entityId:
          type: string
      required:
        - slot
        - entityId
  responses:
    InsufficientPermissions:
      description: >-
        The API key works but lacks the permission this endpoint needs, named in
        requiredScope. See the API keys guide.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/InsufficientPermissionsError'
    PayloadTooLarge:
      description: 'The request body is over the limit: 1 MiB, or 5 MiB for a webhook.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PayloadTooLargeError'
    RateLimited:
      description: >-
        Too many requests. Wait Retry-After seconds, then retry. See the rate
        limits guide.
      headers:
        Retry-After:
          description: Seconds until a request is allowed again
          schema:
            type: integer
        RateLimit-Limit:
          description: 'The burst: requests allowed at once'
          schema:
            type: integer
        RateLimit-Remaining:
          description: Requests left right now
          schema:
            type: integer
        RateLimit-Reset:
          description: Seconds until the full burst is back
          schema:
            type: integer
        RateLimit-Policy:
          description: >-
            The sustained rate per second and the burst, such as
            200;w=1;burst=1000
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer

````

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