Creá y administrá clientes con los SDKs actuales de Commet y el dashboard.
Instalá la Skill de Commet para que tu agente integre clientes usando el contrato actual de la API.
npx skills add commet-labs/skills --skill commetUn customer representa a la empresa o persona que vas a cobrar. Cada customer puede tener una relación de suscripción activa a la vez.
Entrá a Customers para buscar clientes, revisar su estado de facturación, asignar un plan y administrar la suscripción.
import { Commet } from "@commet/node";const commet = new Commet({ apiKey: "ck_xxx" });const customer = await commet.customers.create({ email: "user@example.com" });from commet import Commetcommet = Commet("ck_xxx")customer = commet.customers.create(email="user@example.com")client, err := commet.New("ck_xxx")if err != nil { log.Fatal(err)}ctx := context.Background()customer, err := client.Customers.Create(ctx, &commet.CreateCustomerParams{ Email: "user@example.com",})if err != nil { log.Fatal(err)}import co.commet.Commet;import co.commet.params.CreateCustomerParams;var commet = Commet.builder().apiKey("ck_xxx").build();var customer = commet.customers().create( CreateCustomerParams.builder("user@example.com").build());use Commet\Commet;$commet = new Commet('ck_xxx');$customer = $commet->customers->create(email: 'user@example.com');create es idempotente cuando enviás tu propio id: un reintento con el mismo ID devuelve el customer existente.
Usá:
id para el identificador estable de tu aplicación.email para comunicaciones de facturación.address y taxDocument para el contexto de facturación e impuestos.metadata para valores propios de tu aplicación que no controlen comportamiento de billing.import { Commet } from "@commet/node";const commet = new Commet({ apiKey: "ck_xxx" });const customerBatch = await commet.customers.createBatch({ customers: [{ email: "user@example.com" }] });from commet import Commetcommet = Commet("ck_xxx")customer_batch = commet.customers.create_batch(customers=[{"email": "user@example.com"}])client, err := commet.New("ck_xxx")if err != nil { log.Fatal(err)}ctx := context.Background()customerBatch, err := client.Customers.CreateBatch(ctx, &commet.BatchCreateCustomersParams{ Customers: []commet.BatchCreateCustomersParamsCustomersItem{{ Email: "user@example.com", }},})if err != nil { log.Fatal(err)}import co.commet.Commet;import co.commet.models.BatchCreateCustomersParamsCustomersItem;import co.commet.params.BatchCreateCustomersParams;import java.util.List;var commet = Commet.builder().apiKey("ck_xxx").build();var customerBatch = commet.customers().createBatch( BatchCreateCustomersParams.builder(List.of(new BatchCreateCustomersParamsCustomersItem("user@example.com", null, null, null, null, null, null, null))).build());use Commet\Commet;$commet = new Commet('ck_xxx');$customerBatch = $commet->customers->createBatch( customers: [['email' => 'user@example.com']],);Un batch acepta hasta 100 customers y devuelve por separado los elementos exitosos y fallidos.
import { Commet } from "@commet/node";const commet = new Commet({ apiKey: "ck_xxx" });const customer = await commet.customers.get({ id: "cus_xxx" });from commet import Commetcommet = Commet("ck_xxx")customer = commet.customers.get("cus_xxx")client, err := commet.New("ck_xxx")if err != nil { log.Fatal(err)}ctx := context.Background()customer, err := client.Customers.Get(ctx, "cus_xxx")if err != nil { log.Fatal(err)}import co.commet.Commet;var commet = Commet.builder().apiKey("ck_xxx").build();var customer = commet.customers().get("cus_xxx");use Commet\Commet;$commet = new Commet('ck_xxx');$customer = $commet->customers->get(id: 'cus_xxx');import { Commet } from "@commet/node";const commet = new Commet({ apiKey: "ck_xxx" });const customer = await commet.customers.update({ id: "cus_xxx" });from commet import Commetcommet = Commet("ck_xxx")customer = commet.customers.update("cus_xxx")client, err := commet.New("ck_xxx")if err != nil { log.Fatal(err)}ctx := context.Background()customer, err := client.Customers.Update(ctx, "cus_xxx", nil)if err != nil { log.Fatal(err)}import co.commet.Commet;import co.commet.params.UpdateCustomerParams;var commet = Commet.builder().apiKey("ck_xxx").build();var customer = commet.customers().update( "cus_xxx", UpdateCustomerParams.builder().build());use Commet\Commet;$commet = new Commet('ck_xxx');$customer = $commet->customers->update(id: 'cus_xxx');Las actualizaciones usan semántica PATCH: enviá solamente los campos que deben cambiar.
import { Commet } from "@commet/node";const commet = new Commet({ apiKey: "ck_xxx" });const response = await commet.customers.list();from commet import Commetcommet = Commet("ck_xxx")customers_list_result = commet.customers.list()client, err := commet.New("ck_xxx")if err != nil { log.Fatal(err)}ctx := context.Background()customersListResult, err := client.Customers.List(ctx, nil)if err != nil { log.Fatal(err)}import co.commet.Commet;import co.commet.params.ListCustomersParams;var commet = Commet.builder().apiKey("ck_xxx").build();var customersListResult = commet.customers().list(ListCustomersParams.builder().build());use Commet\Commet;$commet = new Commet('ck_xxx');$customersListResult = $commet->customers->list();Las listas devuelven { object, data, hasMore, nextCursor }. Enviá nextCursor como cursor para pedir la siguiente página. Las operaciones individuales devuelven el customer directamente.
Consultá la referencia de Customers para ver los campos exactos de request y response generados.
¿Cómo está esta guía?