Locations
This object represents a location of your business. Use it to track receipts that belong to the same location.
Scopes
locations:create
locations:read
locations:delete
locations:update
Core principles
A location should be unique by email or by phone number.
SBLocation
Create a location
Create a new location. Requires scope locations:create
POST https://api.smartbills.io/v1/locations
Request Body
Requires body of type LocationCreateRequest
LocationCreateRequest
Parameter | Description | Type | Required |
---|---|---|---|
firstName | First name of the location | string | required |
lastName | Last name of the location | string | required |
locale | Locale the location | string | required |
email | Email of the location | string | required if no phone |
phone | Phone of the location | 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 SBLocation
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Code example
import { SBClient, SBLocation, LocationCreateRequest} from "@smartbills/sdk"
const client: SBClient = new SBClient();
const request: LocationCreateRequest = {
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
};
const location: SBLocation = await client.location.create(request);
Retrieve location
Retrieve a location by ID. Requires scope locations:read
GET https://api.smartbills.io/v1/locations/:id
Path parameters
Parameter | Description | Type | Required |
---|---|---|---|
id | ID of the location to retrieve | long | required |
Response
Returns a SBLocation
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Code example
import { SBClient, SBLocation, LocationCreateRequest} from "@smartbills/sdk"
const client:SBClient = new SBClient();
const location: SBLocation = await client.location.getByIdAsync(1);
List locations
Retrieve a list of locations. Requires scope locations:read
GET https://api.smartbills.io/v1/locations?page=1&pageSize=100
Query parameters
Requires query parameters of type LocationListRequest
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 SBLocation | keyof SBLocation | createdAt | |
sortOrder | Order of the sort | asc or desc | desc |
{
"page": 1,
"pageSize": 100,
"orderBy": "createdAt",
"sortOrder": "desc",
}
Response
Returns a SBList<SBLocation>
{
"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, SBLocation, SBList, LocationListRequest} from "@smartbills/sdk"
const client = new SBClient();
const request: LocationListRequest = {
"page": 1,
"pageSize": 100,
"orderBy": "createdAt",
"sortOrder": "desc",
};
const locations: SBList<SBLocation> = await client.location.list(request);
Update a location
Update information about a location. Requires scope locations:update
PUT https://api.smartbills.io/v1/locations/:id
Path parameters
Parameter | Description | Type | Required |
---|---|---|---|
id | ID of the location to update | long | required |
Body parameters
Requires a body of type LocationUpdateRequest
Parameter | Description | Type | Required |
---|---|---|---|
firstName | First name of the location | string | required |
lastName | Last name of the location | string | required |
email | Email of the location | string | required |
phone | Phone of the location | string | required |
locale | Locale the location | string | required |
{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Response
Returns a SBLocation
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Code example
import { SBClient, SBLocation, LocationUpdateRequest} from "@smartbills/sdk"
const client:SBClient = new SBClient();
const request: LocationUpdateRequest = {
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
const location:SBLocation = await client.locations.updateAsync(1, request);
Delete a location
Delete a location. Requires scope locations:delete
DELETE https://api.smartbills.io/v1/locations/:id
Path parameters
Parameter | Description | Type | Required |
---|---|---|---|
id | ID of the location to delete | long | required |
Response
Returns a SBLocation
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"taxExempt": true,
"phone": "(555) 555-5555",
"locale": "fr-CA",
"acceptsMarketing": true,
}
Code example
import { SBClient, SBLocation} from "@smartbills/sdk"
const client:SBClient = new SBClient();
const location:SBLocation = await client.locations.deleteAsync(1);