SBLocation

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

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

Response

Returns a SBLocation

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

ParameterDescriptionTypeRequired
idID of the location to retrievelongrequired

Response

Returns a SBLocation

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

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

Response

Returns a SBList<SBLocation>

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

ParameterDescriptionTypeRequired
idID of the location to updatelongrequired

Body parameters

Requires a body of type LocationUpdateRequest

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

Response

Returns a SBLocation

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

ParameterDescriptionTypeRequired
idID of the location to deletelongrequired

Response

Returns a SBLocation

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);