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