Cost Centres
Locomote Team avatar
Written by Locomote Team
Updated over a week ago

Cost Centres are departments within a business to which costs can be allocated. Much like Departments, a Cost Centre is a division that helps to deal with a specific area of activity, setup so the costs for those activities can be tracked and reported on by the Company Administrator and/or Finance department.

Within the Locomote Corporate Travel Platform, a Cost Centre might be Travel, Facilities, Administration etc. Any Cost Centre structure (ie. same as a general ledger setup) that is already utilised within your own company configuration can be replicated in Locomote.

Cost Centres are setup at a company level by the company administrator, to ensure that reflects their own company configuration. A Cost Centre is not required to be set for a profile to be considered complete & valid, however a traveller/arranger can set a preferred Cost Centre for the profile, so that any trips booked will be allocated to the correct Cost Centre.

Cost Centres are a Dependency for Users and share a relationship with Departments.

Using the API, we can retrieve a list of departments setup for the company via the GET function. We can also create (POST) without requiring a specific code. Using the "find all" function (GET) we can identify specific cost centre code(s) and either update (PATCH) or remove (DELETE). When specifying a relationship to Cost Centre, PATCH & DELETE options are available for the relationship. And just in case we mistakenly delete the record, we can get it back using a different URL to restore (POST).

Secured by auth_token.

Authorisation via "X-USER-USERNAME" and "X-USER-TOKEN"

All Cost Centres

Get Cost Centres

Get a list of cost_centres resources

GET https://locomotetmp.com/api/cost_centres

Request Parameters

Parameter Name

Description

Required

Valid Values

page[number]

The page number to fetch

No

Any Integer

page[size]

The number of items that appear on each page

No

Any Integer

Example Request

curl -i -H X-USER_TOKEN\:\ [your API key] -H X-USER-USERNAME\:\ [Company Admin email] -H Content-Type\:\ application/json -XGET https\://[your subdomain].locomotetmp.com/api/cost_centres/
No request fields required for GET

Example Response

Status Code: 200 - OK

{ "data": [ { "id": "Admin", "type": "cost_centres", "attributes": { "code": "Admin", "name": "Admin" }, "relationships": { "departments": { "data": [] } } }, { "id": "Marketing", "type": "cost_centres", "attributes": { "code": "Marketing", "name": null }, "relationships": { "departments": { "data": [ { "id": "Demo", "type": "departments" } ] } } },

Response Fields

Field Name

Description

Valid Values

id

Identifier used to reference a given record

Read only

type

Type of resource

cost_centres

code

Unique identifier of the Cost Centre

Character length: <= 50
Valid characters: A-z 0-9
%&'()[]*,-./\:_ and whitespace

name

Name of the Cost Centre

Character length: <= 50
Valid characters: A-z 0-9
%&'()[]*,-./\:_ and whitespace

id

Unique identifier of the Department linked by relationship

Character length: <= 50
Valid characters: A-z 0-9
%&'()[]*,-./\:_ and whitespace

type

Type of resource linked by relationship

departments

Create Cost Centres

Create a new cost_centres resource

POST https://locomotetmp.com/api/cost_centres

Request Parameters

Parameter Name

Description

Required

Valid Values

page[number]

The page number to fetch

No

Any Integer

page[size]

The number of items that appear on each page

No

Any Integer

Example Request

curl -i -H X-USER_TOKEN\:\ [your API key] -H X-USER-USERNAME\:\ [Company Admin email] -H Content-Type\:\ application/json -XPOST https\://[your subdomain].locomotetmp.com/api/cost_centres/
{ "data": { "type": "cost_centres", "attributes": { "code": "Travel", "name": "Travel Costs" } } }

Example Response

Status code 201 - Created

{ "data": { "id": "Travel", "type": "cost_centres", "attributes": { "code": "Travel", "name": "Travel Costs" }, "relationships": { "departments": { "data": [] } } },

Response Fields

Field Name

Description

Valid Values

id

Identifier used to reference a given record

Read only

type*

Type of resource

cost_centres

code*

Identifier of the Cost Centre

Character length: <= 50
Valid characters: A-z 0-9

name*

Name of the Cost Centre

Character length: <= 50
Valid characters: A-z 0-9
%&'()[]*,-./\:_ and whitespace

id

Unique identifier of the Department linked by relationship

Character length: <= 50
Valid characters: A-z 0-9
%&'()[]*,-./\:_ and whitespace

type

Type of resource linked by relationship

departments

Remember

You don't need the resource id as the system will assign code as the unique identifier record.

Single Cost Centres

Get a Cost Centre

Get a single "cost_centres" resource

GET https://locomotetmp.com/api/cost_centres{code}

Request Parameters

Parameter Name

Description

Required

Valid Values

page[number]

The page number to fetch

No

Any Integer

page[size]

The number of items that appear on each page

No

Any Integer

Example Request

curl -i -H X-USER_TOKEN\:\ [your API key] -H X-USER-USERNAME\:\ [Company Admin email] -H Content-Type\:\ application/json -XGET https\://[your subdomain].locomotetmp.com/api/cost_centres/{code}
No request fields required for GET

Example Response

Status Code: 200 - OK

{ "data": { "id": "Admin", "type": "cost_centres", "attributes": { "code": "Admin", "name": "Admin" }, "relationships": { "departments": { "data": [] } } },

Response Fields

Field Name

Description

Valid Values

id

Identifier used to reference a given record

Read only

type

Type of resource

cost_centres

code

Unique identifier of the Cost Centre

Character length: <= 50
Valid characters: A-z 0-9
%&'()[]*,-./\:_ and whitespace

name

Name of the Cost Centre

Character length: <= 50
Valid characters: A-z 0-9
%&'()[]*,-./\:_ and whitespace

id

Unique identifier of the Department linked by relationship

Character length: <= 50
Valid characters: A-z 0-9
%&'()[]*,-./\:_ and whitespace

type

Type of resource linked by relationship

departments

Update a Cost Centre

Update a "cost_centres" resource

PATCH https://locomotetmp.com/api/cost_centres/{code}

Request Parameters

Parameter Name

Description

Required

Valid Values

page[number]

The page number to fetch

No

Any Integer

page[size]

The number of items that appear on each page

No

Any Integer

Example Request

curl -i -H X-USER_TOKEN\:\ [your API key] -H X-USER-USERNAME\:\ [Company Admin email] -H Content-Type\:\ application/json -XPATCH https\://[your subdomain].locomotetmp.com/api/cost_centres/{code}
{ "data": { "id": "Travel", "type": "cost_centres", "attributes": { "code": "Travel", "name": "Travel Office Department" } }}

Example Response

Status Code: 200 - OK

{ "data": { "id": "Travel", "type": "cost_centres", "attributes": { "code": "Travel", "name": "Travel Office Department" }, "relationships": { "departments": { "data": [] } } },

Response Fields

Field Name

Description

Valid Values

id*

Identifier used to reference a given record

Read only

type*

Type of resource

cost_centres

code*

Unique identifier of the Cost Centre

Character length: <= 50
Valid characters: A-z 0-9
%&'()[]*,-./\:_ and whitespace

name*

Name of the Cost Centre

Character length: <= 50
Valid characters: A-z 0-9
%&'()[]*,-./\:_ and whitespace

Delete a Cost Centre

Delete a "cost_centres" resource

DELETE https://locomotetmp.com/api/cost_centres/{code}

Request Parameters

Parameter Name

Description

Required

Valid Values

page[number]

The page number to fetch

No

Any Integer

page[size]

The number of items that appear on each page

No

Any Integer

Example Request

curl -i -H X-USER_TOKEN\:\ [your API key] -H X-USER-USERNAME\:\ [Company Admin email] -H Content-Type\:\ application/json -XDELETE https\://[your subdomain].locomotetmp.com/api/cost_centres/{code}
No request fields required for DELETE

Example Response

Status Code: 204 - No content

No body returned for response

Response Fields

No response fields required as no content is returned after deletion.

Remember

You don't need any response fields entered (eg. type, code, name) to delete a record. The unique resource id (or {code}) is already identified in the URL, so the API knows which specific record to delete.

Update a Cost Centre/Department Relationship

Assigns "departments" to a "cost_centres" resource

PATCH https://locomotetmp.com/api/cost_centres/{code}/relationships/departments

Request Parameters

Parameter Name

Description

Required

Valid Values

page[number]

The page number to fetch

No

Any Integer

page[size]

The number of items that appear on each page

No

Any Integer

Example Request

curl -i -H X-USER_TOKEN\:\ [your API key] -H X-USER-USERNAME\:\ [Company Admin email] -H Content-Type\:\ application/json -XPATCH https\://[your subdomain].locomotetmp.com/api/cost_centres/{code}/relationships/departments
{ "data": [ { "id": "Demo", "type": "departments" }, { "id": "Trav", "type": "departments" } ]}

Example Response

Status Code: 200 - OK

{ "data": [ { "id": "Demo", "type": "departments" }, { "id": "TRAV", "type": "departments" } ],

Response Fields

Field Name

Description

Valid Values

id*

Identifier used to reference a given Department record

Read only

type*

Type of resource

departments

Delete a Cost Centre/Department Relationship

Removes "departments" from a "cost_centres" resource

DELETE https://locomotetmp.com/api/cost_centres/{code}/relationships/departments

Request Parameters

Parameter Name

Description

Required

Valid Values

page[number]

The page number to fetch

No

Any Integer

page[size]

The number of items that appear on each page

No

Any Integer

Example Request

curl -i -H X-USER_TOKEN\:\ [your API key] -H X-USER-USERNAME\:\ [Company Admin email] -H Content-Type\:\ application/json -XDELETE https\://[your subdomain].locomotetmp.com/api/cost_centres/{code}/relationships/departments
{ "data": [ { "id": "demo", "type": "departments" } ]}

Example Response

Status Code: 200 - OK

{ "data": [ { "id": "TRAV", "type": "departments" } ],

Response Fields

No response fields required as no content is returned after deletion.

Remember

You can PATCH or DELETE as many relationships as needed. You can also specify what relationship you would like to update/delete. If all relationships are removed, then a 200 - OK will be displayed instead of a 204 - No content response.

Restore a Cost Centre

Restore a single resource

POST https://locomotetmp.com/api/cost_centres/{code}/actions/restore

Request Parameters

Parameter Name

Description

Required

Valid Values

page[number]

The page number to fetch

No

Any Integer

page[size]

The number of items that appear on each page

No

Any Integer

Example Request

curl -i -H X-USER_TOKEN\:\ [your API key] -H X-USER-USERNAME\:\ [Company Admin email] -H Content-Type\:\ application/json -XPOST https\://[your subdomain].locomotetmp.com/api/cost_centres/{code}/actions/restore
No request fields required for RESTORE

Example Response

Status Code: 200 - OK

The resource was successfully restored. The updated resource is returned.
{ "data": { "id": "Admin", "type": "cost_centres", "attributes": { "code": "Admin", "name": "Admin" }, "relationships": { "departments": { "data": [] } } },

Response Fields

Field Name

Description

Valid Values

type*

Type of resource

cost_centres

code*

Identifier of the Cost Centres

Character length: <= 50
Valid characters: A-z 0-9

Need to Know

*= Denotes mandatory field.

Troubleshooting

If you got a response code other than the code listed in the article, please refer to this page.

Did this answer your question?