API Documentation

Integrate SmartSell with your existing systems using our comprehensive RESTful API

Getting Started

Learn how to authenticate and make your first API request

Authentication

SmartSell API uses API key authentication. Include your API key in the Authorization header of all requests.

# Example request with authentication
curl -X GET "https://api.smartsell.africa/v1/businesses" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"

Note: Keep your API key secure and never expose it in client-side code.

Base URL

All API requests should be made to the following base URL:

https://api.smartsell.africa/v1/

Response Format

All responses are returned in JSON format with the following structure:

{
"success": true,
"data": { ... },
"message": "Request successful",
"timestamp": "2024-01-15T10:30:00Z"
}

API Endpoints

Comprehensive list of available endpoints organized by resource type

Businesses

Method Endpoint Description
GET /businesses List all businesses
POST /businesses Create a new business
GET /businesses/{id} Get business details
PUT /businesses/{id} Update business information

Products

Method Endpoint Description
GET /businesses/{business_id}/products List all products
POST /businesses/{business_id}/products Create a new product
GET /products/{id} Get product details
PUT /products/{id} Update product information
DELETE /products/{id} Delete a product

Sales

Method Endpoint Description
GET /businesses/{business_id}/sales List all sales transactions
POST /businesses/{business_id}/sales Create a new sale
GET /sales/{id} Get sale details
GET /sales/{id}/receipt Get sale receipt

Code Examples

Real-world examples to help you integrate SmartSell API quickly

Create a New Product

curl -X POST "https://api.smartsell.africa/v1/businesses/123/products" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Wireless Headphones",
"sku": "WH-001",
"price": 89.99,
"category": "Electronics",
"stock_quantity": 50
}'

Create a New Product

const
createProduct
=
async
() => {
const
response =
await
fetch
(
'https://api.smartsell.africa/v1/businesses/123/products'
, {

method:
'POST'
,

headers: {

'Authorization'
:
'Bearer YOUR_API_KEY'
,

'Content-Type'
:
'application/json'

},

body:
JSON.stringify
({

name:
'Wireless Headphones'
,

sku:
'WH-001'
,

price: 89.99,

category:
'Electronics'
,

stock_quantity: 50

})

});

const
data =
await
response.
json
();

console.log
(data);

};

Create a New Product

import requests

import json


url = "https://api.smartsell.africa/v1/businesses/123/products"

headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}

data = {
"name": "Wireless Headphones",
"sku": "WH-001",
"price": 89.99,
"category": "Electronics",
"stock_quantity": 50
}

response = requests.post(url, headers=headers, json=data)
print(response.json())

Create a New Product

<?php

$url = "https://api.smartsell.africa/v1/businesses/123/products";

$data = array(
"name" => "Wireless Headphones",
"sku" => "WH-001",
"price" => 89.99,
"category" => "Electronics",
"stock_quantity" => 50
);

$options = array(
'http' => array(
'header' => "Authorization: Bearer YOUR_API_KEY\r\n" .
"Content-Type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($data)
)
);

$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

?>

Error Codes

Understanding API error responses and how to handle them

Code Status Description
200 OK Request successful
201 Created Resource created successfully
400 Bad Request Invalid request parameters
401 Unauthorized Invalid or missing API key
403 Forbidden Insufficient permissions
404 Not Found Resource not found
429 Rate Limited Too many requests
500 Server Error Internal server error

Need API Support?

Our developer support team is here to help you integrate SmartSell API successfully.