Skip to content

Products API

Manage your product catalog with the Products API. Create, update, list, and retrieve products programmatically.

The Products API supports multiple product types including physical products, digital services, and subscription plans. Each product can have pricing information, inventory tracking, images, and can be assigned to categories for better organization.

Use Cases

  • E-commerce Stores: Sync products from your inventory management system
  • SaaS Platforms: Create service plans and pricing tiers
  • Marketplaces: Enable vendors to manage their catalogs via API

Endpoints

MethodEndpointDescription
GET/business/product/listList all products
GET/business/product/details/:idGet product details
POST/business/product/createCreate a new product
PATCH/business/product/update/:idUpdate a product

List Products

Retrieve a paginated list of products.

http
GET /business/product/list

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger10Items per page (max: 100)
statusstring-Filter by status: published, draft, archived
typestring-Filter by type: product, service, plan
categoryidstring-Filter by category ID

Example Request

bash
curl -X GET "https://api.cashfin.africa/business/product/list?page=1&limit=10&status=published" \
  -H "Authorization: cs_your_client_secret"
javascript
const response = await fetch(
  "https://api.cashfin.africa/business/product/list?page=1&limit=10&status=published",
  {
    headers: {
      Authorization: "cs_your_client_secret",
    },
  }
);

const data = await response.json();
php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cashfin.africa/business/product/list?page=1&limit=10&status=published",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: cs_your_client_secret"
  ],
]);

$response = curl_exec($curl);
$data = json_decode($response, true);
python
import requests

response = requests.get(
    'https://api.cashfin.africa/business/product/list',
    params={'page': 1, 'limit': 10, 'status': 'published'},
    headers={'Authorization': 'cs_your_client_secret'}
)

data = response.json()

Example Response

json
{
  "success": true,
  "data": [
    {
      "_id": "507f1f77bcf86cd799439011",
      "title": "Premium Widget",
      "description": "High-quality widget with advanced features",
      "price": 1999.99,
      "stock": 100,
      "sku": "WDG-001",
      "type": "product",
      "status": "published",
      "featured": true,
      "featuredimage": "https://cdn.cashfin.africa/images/widget.jpg",
      "categoryid": "507f191e810c19729de860ea",
      "variants": [],
      "createdat": "2024-01-15T10:30:00.000Z",
      "updatedat": "2024-01-16T14:45:00.000Z"
    }
  ],
  "meta": {
    "total": 45,
    "page": 1,
    "limit": 10,
    "pages": 5
  }
}

Get Product Details

Retrieve details of a specific product.

http
GET /business/product/details/:id

Path Parameters

ParameterTypeRequiredDescription
idstringYesProduct ID (MongoDB ObjectID)

Example Request

bash
curl -X GET "https://api.cashfin.africa/business/product/details/507f1f77bcf86cd799439011" \
  -H "Authorization: cs_your_client_secret"
javascript
const productId = "507f1f77bcf86cd799439011";

const response = await fetch(
  `https://api.cashfin.africa/business/product/details/${productId}`,
  {
    headers: {
      Authorization: "cs_your_client_secret",
    },
  }
);

const data = await response.json();

Example Response

json
{
  "success": true,
  "data": {
    "_id": "507f1f77bcf86cd799439011",
    "title": "Premium Widget",
    "description": "High-quality widget with advanced features",
    "price": 1999.99,
    "stock": 100,
    "sku": "WDG-001",
    "type": "product",
    "status": "published",
    "featured": true,
    "featuredimage": "https://cdn.cashfin.africa/images/widget.jpg",
    "categoryid": "507f191e810c19729de860ea",
    "variants": [
      {
        "_id": "507f1f77bcf86cd799439012",
        "attributetitle": "Size",
        "valuetitle": "Large",
        "valueprice": 2199.99,
        "valuestock": 30,
        "active": true
      },
      {
        "_id": "507f1f77bcf86cd799439013",
        "attributetitle": "Size",
        "valuetitle": "Small",
        "valueprice": 1799.99,
        "valuestock": 70,
        "active": true
      }
    ],
    "active": true,
    "sourceorigin": "api",
    "createdat": "2024-01-15T10:30:00.000Z",
    "updatedat": "2024-01-16T14:45:00.000Z"
  }
}

Create Product

Create a new product in your catalog.

http
POST /business/product/create

Request Body

FieldTypeRequiredDescription
titlestringYesProduct name
descriptionstringNoProduct description
pricenumberYesBase price (must be > 0)
stockintegerNoAvailable quantity (default: 0)
skustringNoStock Keeping Unit (auto-generated if not provided)
typestringNoProduct type: product, service, or plan (default: product)
statusstringNoStatus: published, draft, or archived (default: published)
featuredbooleanNoWhether to feature this product (default: false)
featuredimagestringNoURL to product image
categoryidstringNoCategory ID to assign the product
variantsarrayNoProduct variants (see below)

Variant Object

FieldTypeRequiredDescription
attributetitlestringYesAttribute name (e.g., "Size", "Color")
valuetitlestringYesAttribute value (e.g., "Large", "Blue")
valuepricenumberYesPrice for this variant
valuestockintegerYesStock for this variant

Example Request

bash
curl -X POST "https://api.cashfin.africa/business/product/create" \
  -H "Authorization: cs_your_client_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Premium Widget Pro",
    "description": "Our best-selling widget with advanced features",
    "price": 2999.99,
    "stock": 50,
    "type": "product",
    "status": "published",
    "featured": true,
    "categoryid": "507f191e810c19729de860ea",
    "variants": [
      {
        "attributetitle": "Color",
        "valuetitle": "Blue",
        "valueprice": 2999.99,
        "valuestock": 25
      },
      {
        "attributetitle": "Color",
        "valuetitle": "Red",
        "valueprice": 3099.99,
        "valuestock": 25
      }
    ]
  }'
javascript
const response = await fetch(
  "https://api.cashfin.africa/business/product/create",
  {
    method: "POST",
    headers: {
      Authorization: "cs_your_client_secret",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      title: "Premium Widget Pro",
      description: "Our best-selling widget with advanced features",
      price: 2999.99,
      stock: 50,
      type: "product",
      status: "published",
      featured: true,
      categoryid: "507f191e810c19729de860ea",
      variants: [
        {
          attributetitle: "Color",
          valuetitle: "Blue",
          valueprice: 2999.99,
          valuestock: 25,
        },
        {
          attributetitle: "Color",
          valuetitle: "Red",
          valueprice: 3099.99,
          valuestock: 25,
        },
      ],
    }),
  }
);

const data = await response.json();
php
<?php
$curl = curl_init();

$data = [
  'title' => 'Premium Widget Pro',
  'description' => 'Our best-selling widget with advanced features',
  'price' => 2999.99,
  'stock' => 50,
  'type' => 'product',
  'status' => 'published',
  'featured' => true,
  'categoryid' => '507f191e810c19729de860ea',
  'variants' => [
    [
      'attributetitle' => 'Color',
      'valuetitle' => 'Blue',
      'valueprice' => 2999.99,
      'valuestock' => 25
    ]
  ]
];

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cashfin.africa/business/product/create",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode($data),
  CURLOPT_HTTPHEADER => [
    "Authorization: cs_your_client_secret",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$result = json_decode($response, true);
python
import requests

data = {
    'title': 'Premium Widget Pro',
    'description': 'Our best-selling widget with advanced features',
    'price': 2999.99,
    'stock': 50,
    'type': 'product',
    'status': 'published',
    'featured': True,
    'categoryid': '507f191e810c19729de860ea',
    'variants': [
        {
            'attributetitle': 'Color',
            'valuetitle': 'Blue',
            'valueprice': 2999.99,
            'valuestock': 25
        }
    ]
}

response = requests.post(
    'https://api.cashfin.africa/business/product/create',
    headers={
        'Authorization': 'cs_your_client_secret',
        'Content-Type': 'application/json'
    },
    json=data
)

result = response.json()

Example Response

json
{
  "success": true,
  "message": "Product created successfully",
  "data": {
    "_id": "507f1f77bcf86cd799439011",
    "title": "Premium Widget Pro",
    "sku": "PRD-2024-001",
    "price": 2999.99,
    "stock": 50
  }
}

Update Product

Update an existing product.

http
PATCH /business/product/update/:id

Path Parameters

ParameterTypeRequiredDescription
idstringYesProduct ID (MongoDB ObjectID)

Request Body

All fields are optional. Only provided fields will be updated.

FieldTypeDescription
titlestringProduct name
descriptionstringProduct description
pricenumberBase price
stockintegerAvailable quantity
skustringStock Keeping Unit
typestringProduct type
statusstringProduct status
featuredbooleanFeatured flag
featuredimagestringProduct image URL
categoryidstringCategory ID
variantsarrayProduct variants

Example Request

bash
curl -X PATCH "https://api.cashfin.africa/business/product/update/507f1f77bcf86cd799439011" \
  -H "Authorization: cs_your_client_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "price": 3499.99,
    "stock": 75,
    "status": "published"
  }'
javascript
const productId = "507f1f77bcf86cd799439011";

const response = await fetch(
  `https://api.cashfin.africa/business/product/update/${productId}`,
  {
    method: "PATCH",
    headers: {
      Authorization: "cs_your_client_secret",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      price: 3499.99,
      stock: 75,
      status: "published",
    }),
  }
);

const data = await response.json();

Example Response

json
{
  "success": true,
  "message": "Product updated successfully",
  "data": {
    "_id": "507f1f77bcf86cd799439011",
    "modified": 1
  }
}

Error Responses

Product Not Found

json
{
  "success": false,
  "error": "Product not found"
}

Invalid Product ID

json
{
  "success": false,
  "error": "Invalid product ID format"
}

Validation Error

json
{
  "success": false,
  "error": "Title is required"
}

Product Object Reference

FieldTypeDescription
_idstringUnique product identifier
titlestringProduct name
descriptionstringProduct description
pricenumberBase price
stockintegerAvailable quantity
skustringStock Keeping Unit
typestringproduct, service, or plan
statusstringpublished, draft, or archived
featuredbooleanWhether product is featured
featuredimagestringProduct image URL
categoryidstringAssociated category ID
variantsarrayProduct variants
activebooleanWhether product is active
sourceoriginstringOrigin of creation (api, dashboard)
createdatstringISO 8601 creation timestamp
updatedatstringISO 8601 last update timestamp

Cashfin Business API Documentation