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

# Gestión de Licencias

> Gestiona licencias por usuario con el SDK de Commet.

Las licencias permiten cobrar según el tamaño del equipo de tu cliente. Commet trackea los cambios y los cobra automáticamente — las licencias incluidas al inicio del período, las adicionales prorrateadas.

## Componentes de la licencia

| Componente | Descripción | Ejemplo |
| - | - | - |
| **Feature Code** | Categoría de licencia de usuario | `editor`, `admin`, `viewer` |
| **Count** | Cantidad de licencias a agregar, quitar o setear | `5`, `10`, `50` |
| **Billing** | Las licencias se cobran por unidad en el plan | \$25/licencia/mes |

## Dashboard

Las features de licencias se crean desde **Features** → **Create Feature** con tipo **Seats** — el código de la feature es lo que pasas como `featureCode`. Los feature codes deben crearse en el dashboard antes de usarse. La página **Seats** muestra los balances y eventos de licencias por cliente; los balances también aparecen en la página de detalle de suscripción de cada cliente.

## Agregar licencias

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    await commet.seats.add({
      customerId: 'user_123',
      featureCode: 'editor',
      count: 5,
    })
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    commet.seats.add(
        feature_code='editor',
        count=5,
        customer_id='user_123',
    )
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    client.Seats.Add(ctx, &commet.AddSeatsParams{
        FeatureCode: "editor",
        Count:       5,
        CustomerID:  "user_123",
    })
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    commet.seats().add("editor", 5, "user_123", null);
    ```
  </Tab>

  <Tab title="PHP">
    ```php theme={null}
    $commet->seats->add(
        featureCode: 'editor',
        count: 5,
        customerId: 'user_123',
    );
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST https://commet.co/api/v1/seats \
      -H "x-api-key: $COMMET_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "customerId": "user_123",
        "featureCode": "editor",
        "count": 5
      }'
    ```
  </Tab>
</Tabs>

## Quitar licencias

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    await commet.seats.remove({
      customerId: 'user_123',
      featureCode: 'editor',
      count: 2,
    })
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    commet.seats.remove(
        feature_code='editor',
        count=2,
        customer_id='user_123',
    )
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    client.Seats.Remove(ctx, &commet.RemoveSeatsParams{
        FeatureCode: "editor",
        Count:       2,
        CustomerID:  "user_123",
    })
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    commet.seats().remove("editor", 2, "user_123", null);
    ```
  </Tab>

  <Tab title="PHP">
    ```php theme={null}
    $commet->seats->remove(
        featureCode: 'editor',
        count: 2,
        customerId: 'user_123',
    );
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X DELETE https://commet.co/api/v1/seats \
      -H "x-api-key: $COMMET_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "customerId": "user_123",
        "featureCode": "editor",
        "count": 2
      }'
    ```
  </Tab>
</Tabs>

Las licencias no pueden bajar de cero — quitar más que la cantidad actual falla.

## Setear cantidad exacta

Usa `set` cuando sincronizas las cantidades de licencias desde tu sistema.

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    await commet.seats.set({
      customerId: 'user_123',
      featureCode: 'editor',
      count: 10,
    })
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    commet.seats.set(
        feature_code='editor',
        count=10,
        customer_id='user_123',
    )
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    client.Seats.Set(ctx, &commet.SetSeatsParams{
        FeatureCode: "editor",
        Count:       10,
        CustomerID:  "user_123",
    })
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    commet.seats().set("editor", 10, "user_123", null);
    ```
  </Tab>

  <Tab title="PHP">
    ```php theme={null}
    $commet->seats->set(
        featureCode: 'editor',
        count: 10,
        customerId: 'user_123',
    );
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X PUT https://commet.co/api/v1/seats \
      -H "x-api-key: $COMMET_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "customerId": "user_123",
        "featureCode": "editor",
        "count": 10
      }'
    ```
  </Tab>
</Tabs>

## Setear todos los tipos de licencia

Usa `setAll` para sincronizar múltiples tipos de licencia en una sola llamada. Útil cuando tu sistema trackea todos los roles y querés reconciliar con un solo request.

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    await commet.seats.setAll({
      customerId: 'user_123',
      seats: { editor: 5, viewer: 20, admin: 2 },
    })
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    commet.seats.set_all(
        seats={'editor': 5, 'viewer': 20, 'admin': 2},
        customer_id='user_123',
    )
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    client.Seats.SetAll(ctx, &commet.BulkSetSeatsParams{
        Seats:      map[string]int{"editor": 5, "viewer": 20, "admin": 2},
        CustomerID: "user_123",
    })
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    commet.seats().setAll(Map.of("editor", 5, "viewer", 20, "admin", 2), "user_123", null);
    ```
  </Tab>

  <Tab title="PHP">
    ```php theme={null}
    $commet->seats->setAll(
        seats: ['editor' => 5, 'viewer' => 20, 'admin' => 2],
        customerId: 'user_123',
    );
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X PUT https://commet.co/api/v1/seats/bulk \
      -H "x-api-key: $COMMET_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "customerId": "user_123",
        "seats": { "editor": 5, "viewer": 20, "admin": 2 }
      }'
    ```
  </Tab>
</Tabs>

## Obtener balance

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const balance = await commet.seats.getBalance({
      customerId: 'user_123',
      featureCode: 'editor',
    })
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    balance = commet.seats.get_balance(
        feature_code='editor',
        customer_id='user_123',
    )
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    balance, err := client.Seats.GetBalance(ctx, &commet.GetSeatBalanceParams{
        FeatureCode: "editor",
        CustomerID:  "user_123",
    })
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    var balance = commet.seats().getBalance("editor", "user_123");
    ```
  </Tab>

  <Tab title="PHP">
    ```php theme={null}
    $balance = $commet->seats->getBalance(
        featureCode: 'editor',
        customerId: 'user_123',
    );
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl "https://commet.co/api/v1/seats/balance?customerId=user_123&featureCode=editor" \
      -H "x-api-key: $COMMET_API_KEY"
    ```
  </Tab>
</Tabs>

Pasa un ID de Commet (`cus_xxx`) o tu ID externo como `customerId`. Se requiere una suscripción activa por cliente.

## Obtener todos los balances

Devuelve los balances de cada tipo de licencia en la suscripción activa del cliente.

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const balances = await commet.seats.getAllBalances({
      customerId: 'user_123',
    })
    // { editor: { included: 5, used: 3, ... }, viewer: { ... } }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    balances = commet.seats.get_all_balances(
        customer_id='user_123',
    )
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    balances, err := client.Seats.GetAllBalances(ctx, &commet.GetAllSeatBalancesParams{
        CustomerID: "user_123",
    })
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    var balances = commet.seats().getAllBalances("user_123");
    ```
  </Tab>

  <Tab title="PHP">
    ```php theme={null}
    $balances = $commet->seats->getAllBalances(
        customerId: 'user_123',
    );
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl "https://commet.co/api/v1/seats/balances?customerId=user_123" \
      -H "x-api-key: $COMMET_API_KEY"
    ```
  </Tab>
</Tabs>

## Aprende más

* [Cómo funciona el cobro por licencias](/docs/es/how-does-seat-based-billing-work)

## Relacionado

* [Configurar Features](/docs/es/configure-features) — Crea features de licencias en tus planes
* [Gestionar Planes](/docs/es/create-plans) — Planes que incluyen pricing por licencias
* [Gestionar Suscripciones](/docs/es/manage-subscriptions) — Asigna planes con licencias iniciales


## Related topics

- [Better Auth](/docs/es/better-auth.md)
- [Gestión de Quota](/docs/es/quota-management.md)
- [Licencias](/docs/es/how-does-seat-based-billing-work.md)
- [Cambios de precio](/docs/es/what-happens-when-you-change-your-prices.md)
- [Recibos y ciclos de cobro](/docs/es/invoices-and-billing-cycles.md)


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