SBProduct

Products

This object represents a product of your business. Use it to track receipts that belong to the same product.

products:read products:write

Core principles

A product should be unique by email or by phone number.

SBProduct

Create a product

Create a new product. Requires scope products:write

POST https://api.smartbills.io/v1/products

Request Body

Requires body of type ProductCreateRequest ProductCreateRequest

ParameterDescriptionTypeRequired
firstNameFirst name of the productstringrequired
lastNameLast name of the productstringrequired
localeLocale the productstringrequired
emailEmail of the productstringrequired if no phone
phonePhone of the productstringrequired if no email
ProductCreateRequest
{
    "firstName": "John",
    "lastName": "Doe",
    "email": "[email protected]",
    "taxExempt": true,
    "phone": "(555) 555-5555",
	"locale": "fr-CA",
	"acceptsMarketing": true,
}

Response

Returns a SBProduct

SBProduct
{
	"id": 1,
    "firstName": "John",
    "lastName": "Doe",
    "email": "[email protected]",
    "taxExempt": true,
    "phone": "(555) 555-5555",
	"locale": "fr-CA",
	"acceptsMarketing": true,
}

Code example

import { SBClient, SBProduct, ProductCreateRequest} from "@smartbills/sdk"
 
const client: SBClient = new SBClient();
const request: ProductCreateRequest = {
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
};
 
const product: SBProduct = await client.product.create(request);

Retrieve product

Retrieve a product by ID. Requires scope products:read

GET https://api.smartbills.io/v1/products/:id

Path parameters

ParameterDescriptionTypeRequired
idID of the product to retrievelongrequired

Response

Returns a SBProduct

SBProduct
{
	"id": 1,
    "firstName": "John",
    "lastName": "Doe",
    "email": "[email protected]",
    "taxExempt": true,
    "phone": "(555) 555-5555",
	"locale": "fr-CA",
	"acceptsMarketing": true,
}

Code example

import { SBClient, SBProduct, ProductCreateRequest} from "@smartbills/sdk"
 
const client:SBClient = new SBClient();
const product: SBProduct = await client.product.getByIdAsync(1);

List products

Retrieve a list of products. Requires scope products:read

GET https://api.smartbills.io/v1/products?page=1&pageSize=100

Query parameters

Requires query parameters of type ProductListRequest

ParameterDescriptionTypeRequiredDefault
pageCurrent pagelongrequired1
pageSizeNumber of records to returnlongrequired100
orderByOrder the results by a key of SBProductkeyof SBProductcreatedAt
sortOrderOrder of the sortasc or descdesc
ProductListRequest
{
    "page": 1,
    "pageSize": 100,
	"orderBy": "createdAt",
	"sortOrder": "desc",
}

Response

Returns a SBList<SBProduct>

SBList<SBProduct>
{
	"data": [{
		"id": 1,
		"firstName": "John",
		"lastName": "Doe",
		"email": "[email protected]",
		"taxExempt": true,
		"phone": "(555) 555-5555",
		"locale": "fr-CA",
		"acceptsMarketing": true,
	}],
	"metadata": {
		"page":1,
		"pageSize":100,
		"totalPages":1,
		"count":1,
	},
	
}

Code example

import { SBClient, SBProduct, SBList, ProductListRequest} from "@smartbills/sdk"
 
const client = new SBClient();
const request: ProductListRequest = {
"page": 1,
"pageSize": 100,
"orderBy": "createdAt",
"sortOrder": "desc",
};
 
const products: SBList<SBProduct> = await client.product.list(request);

Update a product

Update information about a product. Requires scope products:write

PUT https://api.smartbills.io/v1/products/:id

Path parameters

ParameterDescriptionTypeRequired
idID of the product to updatelongrequired

Body parameters

Requires a body of type ProductUpdateRequest

ParameterDescriptionTypeRequired
firstNameFirst name of the productstringrequired
lastNameLast name of the productstringrequired
emailEmail of the productstringrequired
phonePhone of the productstringrequired
localeLocale the productstringrequired
ProductUpdateRequest
{
    "firstName": "John",
    "lastName": "Doe",
    "email": "[email protected]",
    "taxExempt": true,
    "phone": "(555) 555-5555",
	"locale": "fr-CA",
	"acceptsMarketing": true,
}

Response

Returns a SBProduct

SBProduct
{
	"id": 1,
    "firstName": "John",
    "lastName": "Doe",
    "email": "[email protected]",
    "taxExempt": true,
    "phone": "(555) 555-5555",
	"locale": "fr-CA",
	"acceptsMarketing": true,
}

Code example

 
import { SBClient, SBProduct, ProductUpdateRequest} from "@smartbills/sdk"
	
	const client:SBClient = new SBClient();
	const request: ProductUpdateRequest = {
		"firstName": "John",
		"lastName": "Doe",
		"email": "[email protected]",
		"taxExempt": true,
		"phone": "(555) 555-5555",
		"locale": "fr-CA",
		"acceptsMarketing": true,
	}
	const product:SBProduct = await client.products.updateAsync(1, request);
 

Delete a product

Delete a product. Requires scope products:write

DELETE https://api.smartbills.io/v1/products/:id

Path parameters

ParameterDescriptionTypeRequired
idID of the product to deletelongrequired

Response

Returns a SBProduct

SBProduct
{
	"id": 1,
    "firstName": "John",
    "lastName": "Doe",
    "email": "[email protected]",
    "taxExempt": true,
    "phone": "(555) 555-5555",
	"locale": "fr-CA",
	"acceptsMarketing": true,
}

Code example

 
import { SBClient, SBProduct} from "@smartbills/sdk"
	
	const client:SBClient = new SBClient();
	const product:SBProduct = await client.products.deleteAsync(1);