Skip to content

Cost Centers

José Ignacio Amelivia Santiago edited this page Aug 8, 2021 · 2 revisions

List of cost centers

List of cost centers endpoint reference on the official TravelPerk documentation.

This function will return the list of all cost centers.

travelperk.cost_centers().cost_centers().all()

Creating a cost center

Creating a cost center reference on the official TravelPerk documentation.

This function will create a cost center with the provided name.

travelperk.cost_centers.cost_centers.create('your-new-cost-center-name')

Details of a cost center

Details of a cost center reference on the official TravelPerk documentation.

This function will return the details of a cost center with its assigned users.

travelperk.cost_centers().cost_centers().get('your-cost-center-id')

Update a cost center

Update a cost center reference on the official TravelPerk documentation.

This function will update the name and/or the archive status of a cost center.

travelperk.cost_centers().cost_centers().modify('your-cost-center-id').set_name(
    'New name'
).set_archive(False).save()

Bulk update of cost centers

Bulk update of cost centers reference on the official TravelPerk documentation.

This function will archive/unarchive a list of cost centers defined in the input.

travelperk.cost_centers().cost_centers().bulk_update().set_ids(
    ['one-cost-center-id', 'another-cost-center-id']
).set_archive(False).save()

Set users to a cost center

Set users to a cost center reference on the official TravelPerk documentation.

This function will replace the users associated with the cost center with the list in the input.

travelperk.cost_centers().cost_centers().set_users('your-cost-center-id').set_ids(
    ['one-user-id', 'another-user-id']
).save()