SBCustomer

Customers

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

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

Request Body

Requires body of type CustomerCreateRequest CustomerCreateRequest

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

Response

Returns a SBCustomer

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

Code example

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

Retrieve customer

Retrieve a customer by ID. Requires scope customers:read

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

Path parameters

ParameterDescriptionTypeRequired
idID of the customer to retrievelongrequired

Response

Returns a SBCustomer

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

Code example

import { SBClient, SBCustomer, CustomerCreateRequest} from "@smartbills/sdk"
 
const client:SBClient = new SBClient();
const customer: SBCustomer = await client.customer.getByIdAsync(1);

List customers

Retrieve a list of customers. Requires scope customers:read

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

Query parameters

Requires query parameters of type CustomerListRequest

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

Response

Returns a SBList<SBCustomer>

SBList<SBCustomer>
{
	"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, SBCustomer, SBList, CustomerListRequest} from "@smartbills/sdk"
 
const client = new SBClient();
const request: CustomerListRequest = {
"page": 1,
"pageSize": 100,
"orderBy": "createdAt",
"sortOrder": "desc",
};
 
const customers: SBList<SBCustomer> = await client.customer.list(request);

Update a customer

Update information about a customer. Requires scope customers:update

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

Path parameters

ParameterDescriptionTypeRequired
idID of the customer to updatelongrequired

Update body parameters

Requires a body of type CustomerUpdateRequest

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

Update response

Returns a SBCustomer

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

Update code example

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

Delete a customer

Delete a customer. Requires scope customers:delete

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

Delete path parameters

ParameterDescriptionTypeRequired
idID of the customer to deletelongrequired

Delete response

Returns a SBCustomer

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

Delete code example

 
import { SBClient, SBCustomer} from "@smartbills/sdk"
	
	const client:SBClient = new SBClient();
	const customer:SBCustomer = await client.customers.deleteAsync(1);