Merchants API

Merchants

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

merchants:create merchants:read merchants:delete merchants:update

Core principles

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

SBMerchant

Create a merchant

Create a new merchant. Requires scope merchants:create

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

Request Body

Requires body of type MerchantCreateRequest MerchantCreateRequest

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

Response

Returns a SBMerchant

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

Code example

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

Retrieve merchant

Retrieve a merchant by ID. Requires scope merchants:read

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

Path parameters

ParameterDescriptionTypeRequired
idID of the merchant to retrievelongrequired

Response

Returns a SBMerchant

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

Code example

import { SBClient, SBMerchant, MerchantCreateRequest} from "@smartbills/sdk"
 
const client:SBClient = new SBClient();
const merchant: SBMerchant = await client.merchant.getByIdAsync(1);

List merchants

Retrieve a list of merchants. Requires scope merchants:read

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

Query parameters

Requires query parameters of type MerchantListRequest

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

Response

Returns a SBList<SBMerchant>

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

Update a merchant

Update information about a merchant. Requires scope merchants:update

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

Path parameters

ParameterDescriptionTypeRequired
idID of the merchant to updatelongrequired

Body parameters

Requires a body of type MerchantUpdateRequest

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

Response

Returns a SBMerchant

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

Code example

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

Delete a merchant

Delete a merchant. Requires scope merchants:delete

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

Path parameters

ParameterDescriptionTypeRequired
idID of the merchant to deletelongrequired

Response

Returns a SBMerchant

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

Code example

 
import { SBClient, SBMerchant} from "@smartbills/sdk"
	
	const client:SBClient = new SBClient();
	const merchant:SBMerchant = await client.merchants.deleteAsync(1);