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
Parameter | Description | Type | Required |
---|---|---|---|
firstName | First name of the merchant | string | required |
lastName | Last name of the merchant | string | required |
locale | Locale the merchant | string | required |
email | Email of the merchant | string | required if no phone |
phone | Phone of the merchant | string | required if no email |
{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Response
Returns a 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
Parameter | Description | Type | Required |
---|---|---|---|
id | ID of the merchant to retrieve | long | required |
Response
Returns a 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
Parameter | Description | Type | Required | Default |
---|---|---|---|---|
page | Current page | long | required | 1 |
pageSize | Number of records to return | long | required | 100 |
orderBy | Order the results by a key of SBMerchant | keyof SBMerchant | createdAt | |
sortOrder | Order of the sort | asc or desc | desc |
{
"page": 1,
"pageSize": 100,
"orderBy": "createdAt",
"sortOrder": "desc",
}
Response
Returns a 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
Parameter | Description | Type | Required |
---|---|---|---|
id | ID of the merchant to update | long | required |
Body parameters
Requires a body of type MerchantUpdateRequest
Parameter | Description | Type | Required |
---|---|---|---|
firstName | First name of the merchant | string | required |
lastName | Last name of the merchant | string | required |
email | Email of the merchant | string | required |
phone | Phone of the merchant | string | required |
locale | Locale the merchant | string | required |
{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Response
Returns a 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
Parameter | Description | Type | Required |
---|---|---|---|
id | ID of the merchant to delete | long | required |
Response
Returns a 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);