Skip to main content

Products

Product objects represent the goods, services, or digital credits you offer to your customers. You can think of them as the items in your catalog. Each product can have one or more associated prices.

This API allows you to create and manage your product catalog programmatically.

For details on managing the cost and billing schemes for these products, see the Prices API Reference.

The Product Object

A Product object contains details about a single item you sell.

AttributeTypeDescription
idstringUnique identifier for the product object.
namestringThe product's name, meant to be displayable to the customer.
typestringThe type of the product. Can be service, good, or credit. Defaults to service.
activebooleanWhether the product is currently available for purchase.
descriptionstringAn arbitrary string that you can use to describe the product.
imagesstring[]A list of URL strings for images of the product.
metadataobjectA set of key-value pairs that you can attach to an object. Useful for storing additional information.
statement_descriptorstringAn optional descriptor that appears on your customer's credit card statement.
unit_labelstringA label that represents a single unit of this product (e.g., 'user', 'license').
nft_factorystringThe address of an NFT factory, if the product is linked to an NFT.
featuresobject[]A list of features associated with the product. Each feature object has a name property.
pricesPrice[]A list of Price objects associated with this product. This is only included when retrieving a single product or in expanded lists.
default_price_idstringThe ID of the default price for this product.
created_atstringTimestamp of when the object was created.
updated_atstringTimestamp of the last update.

Create a Product

Creates a new product object. You can also create one or more prices for the product at the same time.

Create Product

javascript
const product = await payment.products.create({
  name: 'Premium Subscription',
  description: 'Monthly access to premium features.',
  type: 'service',
  prices: [
    {
      unit_amount: 1500, // e.g., 15.00 USD
      currency_id: 'usd_xxxx',
      type: 'recurring',
      recurring: {
        interval: 'month',
        interval_count: 1,
        usage_type: 'licensed'
      },
    },
  ],
});

Parameters

NameTypeDescription
namestringRequired. The product's name.
typestringThe product type. One of service, good, or credit. Defaults to service.
descriptionstringAn optional, user-facing description of the product.
imagesstring[]A list of URLs for product images.
metadataobjectKey-value data to store with the product.
statement_descriptorstringA short descriptor for credit card statements. Must contain at least one letter and cannot include <, >, ", , or \. Max 22 characters.
unit_labelstringA label for a single unit of the product (e.g., 'seat', 'GB'). Max 12 characters.
nft_factorystringThe address of an associated NFT factory contract.
featuresobject[]A list of feature objects, where each object has a name property.
pricesobject[]An array of Price objects to create and attach to this product. See the Price Object Properties table below.

Price Object Properties

When creating a product, you can include an array of prices. Each object in the prices array can have the following properties:

NameTypeDescription
unit_amountnumberRequired. The price in the smallest currency unit (e.g., cents for USD). Must be greater than 0.
currency_idstringRequired. The ID of the currency for this price.
nicknamestringAn internal-facing name for the price.
typestringone_time or recurring. Defaults to one_time.
recurringobjectRequired if type is recurring. An object with an interval (day, week, month, or year) and optional interval_count.
custom_unit_amountobjectDefines a price where the customer can choose the amount. See the Prices API for details.

Returns

Returns the newly created Product object, including the list of any prices that were created.

Response Example

json
{
  "id": "prod_12345",
  "name": "Premium Subscription",
  "type": "service",
  "active": true,
  "description": "Monthly access to premium features.",
  "images": [],
  "metadata": {},
  "statement_descriptor": null,
  "unit_label": null,
  "nft_factory": null,
  "features": [],
  "default_price_id": "price_67890",
  "created_at": "2023-10-27T10:00:00.000Z",
  "updated_at": "2023-10-27T10:00:00.000Z",
  "prices": [
    {
      "id": "price_67890",
      "product_id": "prod_12345",
      "active": true,
      "type": "recurring",
      "unit_amount": "1500",
      "currency_id": "usd_xxxx",
      "recurring": {
        "interval": "month",
        "interval_count": 1
      }
    }
  ]
}

Retrieve a Product

Retrieves the details of an existing product.

Retrieve Product

javascript
const product = await payment.products.retrieve('prod_12345');

Parameters

NameTypeDescription
idstringRequired. The unique identifier of the product to retrieve.

Returns

Returns a Product object if a valid ID was provided. Otherwise, this call returns an error.

Response Example

json
{
  "id": "prod_12345",
  "name": "Premium Subscription",
  "type": "service",
  "active": true,
  "description": "Monthly access to premium features.",
  // ... other product fields
  "prices": [
    // ... list of associated price objects
  ]
}

Update a Product

Updates the specified product by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Update Product

javascript
const product = await payment.products.update('prod_12345', {
  description: 'Updated: Monthly access to all premium features and priority support.',
  metadata: { 'tier': 'premium' }
});

Parameters

NameTypeDescription
idstringRequired. The ID of the product to update.
namestringThe product's name.
descriptionstringAn optional, user-facing description of the product.
imagesstring[]A list of URLs for product images.
metadataobjectKey-value data to store with the product.
statement_descriptorstringA short descriptor for credit card statements.
default_price_idstringThe ID of the price to set as the default for this product.
unit_labelstringA label for a single unit of the product.
featuresobject[]A list of feature objects.

Returns

Returns the updated Product object.

List all Products

Returns a paginated list of your products. The products are returned sorted by creation date, with the most recently created products appearing first.

List Products

javascript
const products = await payment.products.list({
  active: true,
  limit: 10
});

Parameters

NameTypeDescription
activebooleanOnly return products with this active status.
namestringOnly return products with this name.
descriptionstringOnly return products with this description.
typestringOnly return products of this type (e.g., credit).
metadata.{key}stringFilter by a specific key-value pair in the metadata. For example, metadata.tier: 'premium'.
pagenumberThe page number to retrieve. Defaults to 1.
pageSizenumberThe number of objects to return per page. Defaults to 20.

Returns

A paginated list of Product objects.

Response Example

json
{
  "count": 50,
  "list": [
    {
      "id": "prod_12345",
      "name": "Premium Subscription",
      // ... other product fields
    },
    {
      "id": "prod_67890",
      "name": "Standard Plan",
      // ... other product fields
    }
  ],
  "paging": {
    "page": 1,
    "pageSize": 20
  }
}

Search Products

Returns a list of products that match a search query.

Search Products

javascript
const products = await payment.products.search({ query: 'Premium' });

Parameters

NameTypeDescription
querystringThe search query string. The search is performed on fields like name and description.
pagenumberThe page number to retrieve. Defaults to 1.
pageSizenumberThe number of objects to return per page. Defaults to 20.

Returns

A paginated list of Product objects that match the search query.

Archive a Product

Archives a product, making it unavailable for new purchases. This action toggles the active status of the product. Archiving a product will not affect existing subscriptions or purchases.

Archive Product

javascript
const product = await payment.products.archive('prod_12345');

Parameters

NameTypeDescription
idstringRequired. The ID of the product to archive.

Returns

Returns the updated Product object with its active status set to false (or true if it was already archived).

Delete a Product

Permanently deletes a product. This action cannot be undone. A product can only be deleted if it has no prices or if none of its prices have been used in any transactions.

Delete Product

javascript
const deletedProduct = await payment.products.del('prod_12345');

Parameters

NameTypeDescription
idstringRequired. The ID of the product to delete.

Returns

Returns the deleted Product object.