# Commerce

> Products and samples.

Source: https://www.onlucra.com/docs/api-commerce

Products are what a brand promotes; samples get them into creators' hands.

## Products

A brand's catalog comes from its [Shopify connection](https://www.onlucra.com/docs/api-connections) or is added by hand with `POST /v1/products`. Prices are in cents. Set an `accessCode` to let creators redeem a product with a code instead of an order.

Attach products to a program in its `promoted.products`. Acting as a creator, `GET /v1/products` lists the products of the programs they're approved in; those are the ones they can request.

## Samples

A creator requests a sample with `{ "product", "program" }`. The brand approves or rejects it with `PATCH /v1/samples/:id`, and approving it places the order or shares the access code.

A brand can also send a sample directly:

```ts
await lucra.samples.create({
  body: {
    creator: "crtr_026UYfiw1Y6OvUpuKWiOpeL",
    product: "prod_04bst9MGXqblfqHhbR1iGGL",
    method: "order",
  },
})
```

`method` is `order` (a free Shopify order) or `access_code`. The creator reads the code with `GET /v1/samples/:id?expand=accessCode`.

## Endpoints

- `GET /v1/products` (read, SDK `lucra.products.list`): List products; as a creator, the ones attached to the programs you're approved in, which you can ask a sample of
- `POST /v1/products` (write, SDK `lucra.products.create`): Add a product to the catalog
- `GET /v1/products/:id` (read, SDK `lucra.products.retrieve`): Get a product
- `PATCH /v1/products/:id` (write, SDK `lucra.products.update`): Edit, archive or set the access code of a product
- `GET /v1/samples` (read, SDK `lucra.samples.list`): List samples
- `POST /v1/samples` (write, SDK `lucra.samples.create`): Request a sample as a creator, or send one to a creator as the brand
- `GET /v1/samples/:id` (read, SDK `lucra.samples.retrieve`): Get a sample; its creator can reveal an access code with expand=accessCode
- `PATCH /v1/samples/:id` (write, SDK `lucra.samples.update`): Approve or reject a sample request
