> ## 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.

# Assign a seat

> Put an entity in a free seat of a license the customer bought.

Puts the [entity](https://docs.integrateledger.com/customers/entities.md) in the lowest free seat of the customer's license of the seat plan `planId`, and answers `{ planId, entityId, slot }`. The entity then spends the seat plan's credits as its own for the rest of the billing period, before the shared pool; the customer and other entities can't spend them. A seat another entity held earlier this period carries what was left of it, so releasing and assigning again never resets the allowance.

An entity that already holds a seat of this license gets the same seat back, and nothing more is granted. Every seat held: `409 no_seats_available`. No live license of the seat plan: `404 license_not_found`. An unknown or deleted entity: `404 entity_not_found`. Assigning changes nothing the customer pays.

Needs the **Billing** permission.


## OpenAPI

````yaml openapi.json POST /v1/licenses/assign
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/assign:
    post:
      tags:
        - Licenses
      summary: Assign a license seat to an entity
      operationId: assignLicenseSeat
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LicenseSeatInput'
      responses:
        '200':
          description: >-
            The seat the entity holds: a free one now, or the one it already
            held. Its seat plan's credits and metered allowances are the
            entity's to spend this period, less what earlier holders spent of
            this seat.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseSeatAssignment'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseError'
        '401':
          description: Invalid Ledger API key
          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: Every seat of the license is held (no_seats_available)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseError'
        '413':
          $ref: '#/components/responses/PayloadTooLarge'
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          description: >-
            The customer is busy with another billing change. Nothing was
            changed; retry the same request.
          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.assign_license_seat(customer_id="user_123", plan_id="seat",
            entity_id="alice")
        - lang: bash
          label: cURL
          source: >-
            curl --request POST
            'https://api.integrateledger.com/v1/licenses/assign' \
              -H "Authorization: Bearer $LEDGER_API_KEY" \
              -H 'Content-Type: application/json' \
              --data '{"customerId":"user_123","planId":"seat","entityId":"alice"}'
        - lang: typescript
          label: TypeScript SDK
          source: >-
            import ledger from "integrateledger";


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

            await client.assignLicenseSeat({ customerId: "user_123", planId:
            "seat", entityId: "alice" });
components:
  schemas:
    LicenseSeatInput:
      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 seat to assign or release: a plan the customer's
            plan sells seats of (its licenses).
          example: seat
        entityId:
          type: string
          minLength: 1
          maxLength: 255
          description: Your ID for the user, seat or workspace inside the customer.
          example: alice
      required:
        - customerId
        - planId
        - entityId
      additionalProperties: false
    LicenseSeatAssignment:
      type: object
      properties:
        planId:
          type: string
          description: The seat plan.
        entityId:
          type: string
        slot:
          type: integer
          exclusiveMinimum: 0
          description: >-
            Which of the license's seats, numbered from 1. An entity keeps its
            slot until it's released.
      required:
        - planId
        - entityId
        - slot
    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
    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
  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.