Locations API

Locations

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

Scopes

locations:write locations.read

Core principles

A location should be unique by address.

Create a location

Create a new location. Requires scope locations:write

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

Request Body

Requires body of type LocationCreateRequest

ParameterDescriptionTypeRequired
nameName of the locationstringrequired
addressAddress of the locationAddressRequestrequired
websiteWebsite of the locationstringoptional
descriptionDescription of the locationstringoptional
merchantCategoryCodeMerchant category codestringrequired
currencyCurrency usedstringoptional
timezoneTimezone of the locationstringoptional
phoneNumberPhone number of the locationstringoptional
facebookUrlFacebook URL of the locationstringoptional
instagramUsernameInstagram username of the locationstringoptional
twitterUsernameTwitter username of the locationstringoptional
isActiveIndicates if the location is activebooloptional
localeLocale of the locationstringoptional
emailEmail of the locationstringoptional
logoLogo URL of the locationstringoptional
imagesList of images associated with the locationList<ImageCreateRequest>optional
LocationCreateRequest
{
    "name": "Main Store",
    "address": {
        "street": "123 Main St",
        "city": "Anytown",
        "state": "California",
        "stateCode": "CA",
        "postalCode": "12345",
        "country": "USA",
        "countryCode": "US",
        "location": {
			"longitude": -122.4194,
			"latitude": 37.7749
		}
    },
    "merchantCategoryCode": "1234",
    "currency": "USD",
    "timezone": "America/Los_Angeles",
    "phoneNumber": "(555) 555-5555",
    "email": "[email protected]",
    "locale": "en-CA",
    "isActive": true
}

Response

Returns a SBLocation

SBLocation
{
    "id": 1,
    "name": "Main Store",
    "address": {
        "street": "123 Main St",
        "city": "Anytown",
        "state": "California",
        "stateCode": "CA",
        "postalCode": "12345",
        "country": "USA",
        "countryCode": "US",
        "location": {
			"longitude": -122.4194,
			"latitude": 37.7749
		}
    },
    "merchantCategoryCode": "1234",
    "currency": "USD",
    "timezone": "America/Los_Angeles",
    "phoneNumber": "(555) 555-5555",
    "email": "[email protected]",
    "locale": "en-CA",
    "isActive": true
}

Code example

import { SBClient, SBLocation, LocationCreateRequest} from "@smartbills/sdk"
 
const client: SBClient = new SBClient();
const request: LocationCreateRequest = {
    "name": "Main Store",
    "address": {
        "street": "123 Main St",
        "city": "Anytown",
        "state": "California",
        "stateCode": "CA",
        "postalCode": "12345",
        "country": "USA",
        "countryCode": "US",
        "longitude": -122.4194,
        "latitude": 37.7749
    },
    "merchantCategoryCode": "1234",
    "currency": "USD",
    "timezone": "America/Los_Angeles",
    "phoneNumber": "(555) 555-5555",
    "email": "[email protected]",
    "locale": "en-CA",
    "isActive": 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,
    "name": "Main Store",
    "address": {
        "street": "123 Main St",
        "city": "Anytown",
        "state": "California",
        "stateCode": "CA",
        "postalCode": "12345",
        "country": "USA",
        "countryCode": "US",
        "location": {
			"longitude": -122.4194,
			"latitude": 37.7749
		}
    },
    "merchantCategoryCode": "1234",
    "currency": "USD",
    "timezone": "America/Los_Angeles",
    "phoneNumber": "(555) 555-5555",
    "email": "[email protected]",
    "locale": "en-CA",
    "isActive": true
}

Code example

import { SBClient, SBLocation } 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,
        "name": "Main Store",
        "address": {
            "street": "123 Main St",
            "city": "Anytown",
            "state": "California",
            "stateCode": "CA",
            "postalCode": "12345",
            "country": "USA",
            "countryCode": "US",
            "longitude": -122.4194,
            "latitude": 37.7749
        },
        "merchantCategoryCode": "1234",
        "currency": "USD",
        "timezone": "America/Los_Angeles",
        "phoneNumber": "(555) 555-5555",
        "email": "[email protected]",
        "locale": "en-CA",
        "isActive": 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.write

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
nameName of the locationstringrequired
addressAddress of the locationAddressRequestrequired
websiteWebsite of the locationstringoptional
descriptionDescription of the locationstringoptional
merchantCategoryCodeMerchant category codestringrequired
currencyCurrency usedstringoptional
timezoneTimezone of the locationstringoptional
phoneNumberPhone number of the locationstringoptional
facebookUrlFacebook URL of the locationstringoptional
instagramUsernameInstagram username of the locationstringoptional
twitterUsernameTwitter username of the locationstringoptional
isActiveIndicates if the location is activebooloptional
localeLocale of the locationstringoptional
emailEmail of the locationstringoptional
logoLogo URL of the locationstringoptional
imagesList of images associated with the locationList<ImageCreateRequest>optional
LocationUpdateRequest
{
    "name": "Main Store",
    "address": {
        "street": "123 Main St",
        "city": "Anytown",
        "state": "California",
        "stateCode": "CA",
        "postalCode": "12345",
        "country": "USA",
        "countryCode": "US",
        "location": {
			"longitude": -122.4194,
			"latitude": 37.7749
		}
    },
    "merchantCategoryCode": "1234",
    "currency": "USD",
    "timezone": "America/Los_Angeles",
    "phoneNumber": "(555) 555-5555",
    "email": "[email protected]",
    "locale": "en-CA",
    "isActive": true
}

Response

Returns a SBLocation

SBLocation
{
    "id": 1,
    "name": "Main Store",
    "address": {
        "street": "123 Main St",
        "city": "Anytown",
        "state": "California",
        "stateCode": "CA",
        "postalCode": "12345",
        "country": "USA",
        "countryCode": "US",
        "location": {
			"longitude": -122.4194,
			"latitude": 37.7749
		}
    },
    "merchantCategoryCode": "1234",
    "currency": "USD",
    "timezone": "America/Los_Angeles",
    "phoneNumber": "(555) 555-5555",
    "email": "[email protected]",
    "locale": "en-CA",
    "isActive": true
}

Code example

 
import { SBClient, SBLocation, LocationUpdateRequest} from "@smartbills/sdk"
    
    const client:SBClient = new SBClient();
    const request: LocationUpdateRequest = {
        "name": "Main Store",
        "address": {
            "street": "123 Main St",
            "city": "Anytown",
            "state": "California",
            "stateCode": "CA",
            "postalCode": "12345",
            "country": "USA",
            "countryCode": "US",
            "longitude": -122.4194,
            "latitude": 37.7749
        },
        "merchantCategoryCode": "1234",
        "currency": "USD",
        "timezone": "America/Los_Angeles",
        "phoneNumber": "(555) 555-5555",
        "email": "[email protected]",
        "locale": "en-CA",
        "isActive": true
    }
    const location:SBLocation = await client.locations.updateAsync(1, request);
 

Delete a location

Delete a location. Requires scope locations:write

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

Path parameters

ParameterDescriptionTypeRequired
idID of the location to deletelongrequired

Response

Returns a SBLocation

SBLocation
{
    "id": 1,
    "name": "Main Store",
    "address": {
        "street": "123 Main St",
        "city": "Anytown",
        "state": "California",
        "stateCode": "CA",
        "postalCode": "12345",
        "country": "USA",
        "countryCode": "US",
        "location": {
			"longitude": -122.4194,
			"latitude": 37.7749
		}
    },
    "merchantCategoryCode": "1234",
    "currency": "USD",
    "timezone": "America/Los_Angeles",
    "phoneNumber": "(555) 555-5555",
    "email": "[email protected]",
    "locale": "en-CA",
    "isActive": true
}

Code example

 
import { SBClient, SBLocation} from "@smartbills/sdk"
    
    const client:SBClient = new SBClient();
    const location:SBLocation = await client.locations.deleteAsync(1);