# Products
Source: https://docs.lomi.africa/build/billing/products

Manage products, prices, and subscription configurations.

***

title: Products
description: Manage products, prices, and subscription configurations.
----------------------------------------------------------------------

import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
import { Callout } from '@/components/docs/docs-callout';

The Products API allows you to manage your product catalog. Products represent items or services you sell, and each product can have up to **3 active prices**.

## Create a product

Create a product with one or more prices. At least one price is required.

**API reference (full request schema):** [Create product](/api/products/ProductsController_create)

**Essentials:**

* `name`, `product_type` (`one_time`, `recurring`, `usage_based`), and a `prices` array are required.
* Each price needs `amount` and `currency_code`. Recurring products also need `billing_interval` on the price.
* `amount` is what the customer pays in `currency_code`. `10000` is 10,000 with `USD`, `EUR`, or `XOF`. USD and EUR may use two decimal places, such as `9.99`. XOF is a whole number. Do not convert to cents.
* Recurring-only fields: `trial_enabled`, `trial_period_days`, `failed_payment_action`, `charge_day`, `first_payment_type`: see the API page.
* Usage packs: `amount` on the price is what the customer pays. `included_units` is how many units that payment buys. `usage_unit` is the unit label. lomi. sums `quantity` on one meter. Leave `billing_interval` empty. See [Usage billing](/build/billing/usage-billing).

<Callout type="info">
  **Optional metadata** for recurring products (via `metadata` on create/update): `subscription_length` (`"automatic"` by default) and `fixed_charges` (integer number of billing cycles before expiry). These are not top-level API fields; store them in `metadata`.
</Callout>

<Callout type="info">
  **Pay what you want** (`pricing_model: pay_what_you_want`, one-time only): `minimum_amount` is required; `amount` is the suggested unit price. The server enforces `amount >= minimum_amount` and optional `maximum_amount`. Full price fields: [Create product](/api/products/ProductsController_create).
</Callout>

<Tabs items={["TypeScript", "Python", "cURL"]}>
  <Tab value="TypeScript">
    ```typescript
    import { LomiSDK } from '@lomi./sdk';

    const lomi = new LomiSDK({
      apiKey: process.env.LOMI_SECRET_KEY!,
      environment: 'live',
    });

    // One-time product
    const product = await lomi.products.create({
      name: 'E-book Bundle',
      description: 'Complete guide collection',
      product_type: 'one_time',
      prices: [
        {
          amount: 25000,
          currency_code: 'XOF',
          is_default: true,
        },
      ],
      display_on_storefront: true,
    });

    // Subscription product with trial
    const subscription = await lomi.products.create({
      name: 'Premium Plan',
      description: 'Monthly premium access',
      product_type: 'recurring',
      prices: [
        {
          amount: 10000,
          currency_code: 'XOF',
          billing_interval: 'month',
          is_default: true,
        },
      ],
      trial_enabled: true,
      trial_period_days: 14,
      failed_payment_action: 'continue',
    });

    // Pay what you want (one-time only)
    const tipJar = await lomi.products.create({
      name: 'Community tip jar',
      product_type: 'one_time',
      prices: [
        {
          pricing_model: 'pay_what_you_want',
          amount: 1000,
          minimum_amount: 500,
          maximum_amount: 5000,
          currency_code: 'XOF',
          is_default: true,
        },
      ],
    });

    // Usage pack: amount is the pack price, included_units is what that payment buys
    const pack = await lomi.products.create({
      name: 'API calls',
      product_type: 'usage_based',
      usage_unit: 'call',
      prices: [
        {
          amount: 5000,
          currency_code: 'XOF',
          included_units: 1000,
          is_default: true,
        },
      ],
    });

    console.log(`Product created: ${product.product_id}`);
    ```
  </Tab>

  <Tab value="Python">
    ```python
    from lomi import LomiClient
    import os

    client = LomiClient(
        api_key=os.environ["LOMI_SECRET_KEY"],
        environment="test"
    )

    # One-time product
    product = client.products.create({
        "name": "E-book Bundle",
        "description": "Complete guide collection",
        "product_type": "one_time",
        "prices": [
            {
                "amount": 25000,
                "currency_code": "XOF",
                "is_default": True
            }
        ],
        "display_on_storefront": True
    })

    # Pay what you want (one-time only)
    tip_jar = client.products.create({
        "name": "Community tip jar",
        "product_type": "one_time",
        "prices": [
            {
                "pricing_model": "pay_what_you_want",
                "amount": 1000,
                "minimum_amount": 500,
                "maximum_amount": 5000,
                "currency_code": "XOF",
                "is_default": True
            }
        ]
    })

    # Usage pack: amount is the pack price, included_units is what that payment buys
    pack = client.products.create({
        "name": "API calls",
        "product_type": "usage_based",
        "usage_unit": "call",
        "prices": [
            {
                "amount": 5000,
                "currency_code": "XOF",
                "included_units": 1000,
                "is_default": True
            }
        ]
    })

    print(f"Product created: {product['product_id']}")
    ```
  </Tab>

  <Tab value="cURL">
    ```bash
    curl -X POST "https://api.lomi.africa/products" \
      -H "X-API-KEY: $LOMI_SECRET_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "E-book Bundle",
        "description": "Complete guide collection",
        "product_type": "one_time",
        "prices": [
          {
            "amount": 25000,
            "currency_code": "XOF",
            "is_default": true
          }
        ],
        "display_on_storefront": true
      }'

    # Pay what you want (one-time only)
    curl -X POST "https://api.lomi.africa/products" \
      -H "X-API-KEY: $LOMI_SECRET_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "Community tip jar",
        "product_type": "one_time",
        "prices": [
          {
            "pricing_model": "pay_what_you_want",
            "amount": 1000,
            "minimum_amount": 500,
            "maximum_amount": 5000,
            "currency_code": "XOF",
            "is_default": true
          }
        ]
      }'

    # Usage pack: amount is the pack price, included_units is what that payment buys
    curl -X POST "https://api.lomi.africa/products" \
      -H "X-API-KEY: $LOMI_SECRET_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "API calls",
        "product_type": "usage_based",
        "usage_unit": "call",
        "prices": [
          {
            "amount": 5000,
            "currency_code": "XOF",
            "included_units": 1000,
            "is_default": true
          }
        ]
      }'
    ```
  </Tab>
</Tabs>

***

## List products

**API reference:** [List products](/api/products/ProductsController_findAll), supports `isActive`, `limit`, and `offset`.

<Tabs items={["TypeScript", "Python", "cURL"]}>
  <Tab value="TypeScript">
    ```typescript
    const products = await lomi.products.list({
      isActive: true,
      limit: 20,
    });
    ```
  </Tab>

  <Tab value="Python">
    ```python
    products = client.products.list(isActive=True, limit=20)
    ```
  </Tab>

  <Tab value="cURL">
    ```bash
    curl -X GET "https://api.lomi.africa/products?isActive=true&limit=20" \
      -H "X-API-KEY: $LOMI_SECRET_KEY"
    ```
  </Tab>
</Tabs>

***

## Get a product

**API reference:** [Get product](/api/products/ProductsController_findOne), returns the product with all prices.

<Tabs items={["TypeScript", "Python", "cURL"]}>
  <Tab value="TypeScript">
    ```typescript
    const product = await lomi.products.get('prod_abc123...');
    console.log(`Default price: ${product.prices.find(p => p.is_default)?.amount}`);
    ```
  </Tab>

  <Tab value="Python">
    ```python
    product = client.products.get('prod_abc123...')
    ```
  </Tab>

  <Tab value="cURL">
    ```bash
    curl -X GET "https://api.lomi.africa/products/prod_abc123..." \
      -H "X-API-KEY: $LOMI_SECRET_KEY"
    ```
  </Tab>
</Tabs>

***

## Add a price to a product

**API reference:** [Add price](/api/products/ProductsController_addPrice)

<Callout type="warning">
  Products can have a maximum of **3 active prices**. You cannot modify existing prices, create a new one instead.
</Callout>

<Tabs items={["TypeScript", "Python", "cURL"]}>
  <Tab value="TypeScript">
    ```typescript
    const price = await lomi.products.addPrice('prod_abc123...', {
      amount: 50000,
      currency_code: 'XOF',
      billing_interval: 'year',
    });

    console.log(`New price added: ${price.price_id}`);

    // Pay what you want price
    const pwywPrice = await lomi.products.addPrice('prod_abc123...', {
      pricing_model: 'pay_what_you_want',
      amount: 1000,
      minimum_amount: 500,
      maximum_amount: 5000,
      currency_code: 'XOF',
    });
    ```
  </Tab>

  <Tab value="Python">
    ```python
    price = client.products.add_price('prod_abc123...', {
        "amount": 50000,
        "currency_code": "XOF",
        "billing_interval": "year"
    })
    ```
  </Tab>

  <Tab value="cURL">
    ```bash
    curl -X POST "https://api.lomi.africa/products/prod_abc123.../prices" \
      -H "X-API-KEY: $LOMI_SECRET_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "amount": 50000,
        "currency_code": "XOF",
        "billing_interval": "year"
      }'
    ```
  </Tab>
</Tabs>

***

## Set default price

**API reference:** [Set default price](/api/products/ProductsController_setDefaultPrice)

<Tabs items={["TypeScript", "Python", "cURL"]}>
  <Tab value="TypeScript">
    ```typescript
    const product = await lomi.products.setDefaultPrice('prod_abc123...', 'price_def456...');
    ```
  </Tab>

  <Tab value="Python">
    ```python
    product = client.products.set_default_price('prod_abc123...', 'price_def456...')
    ```
  </Tab>

  <Tab value="cURL">
    ```bash
    curl -X POST "https://api.lomi.africa/products/prod_abc123.../prices/price_def456.../default" \
      -H "X-API-KEY: $LOMI_SECRET_KEY"
    ```
  </Tab>
</Tabs>

***

## Related API

* [Create product](/api/products/ProductsController_create)
* [List products](/api/products/ProductsController_findAll)
* [Get product](/api/products/ProductsController_findOne)
* [Add price](/api/products/ProductsController_addPrice)
* [Set default price](/api/products/ProductsController_setDefaultPrice)
* [Checkout with a product](/build/accept/checkout)
