BookingBug REST API: company
Purpose
Used for creating and editing companies within BookingBug. The company represents an abstract group of bookable services. In fact a company can have multiple companies underneath it that are either local offices, or specific departments at a larger location. Only a single company can be managed at a time within BookingBug. The user must switch between companies if they manage large or complex sets of businesses or locations.
URL
http://[site].bookingbug.com/api/company.format
Formats
json, xml
Authentication
Requires business API access
Parameters
| param | type | description | required? |
|---|---|---|---|
| name | string(50) | A company name | Yes |
| description | string(255) | A longer description of the business that appears in searches | No |
| address | address | An address for the company. Use as a default/home address | Yes |
| time_zone | string | An operating timezone for the business. If left blank the business is assumed to use the site timezone | No |
| template_id | integer | A template ID. This the ID of another company form which to copy configuration settings from and sets this new company using using the same settings of the template company and saves having to set up per-business configuration, cannot be used at the same time as settings | No |
| administrators | administrators | A list of admins for this business and their roles, at least one is required to create a user login for this business. Can include new users and existing users | Yes |
| settings | settings | An optional block of settings data that controls how this company is configured | No |
| api_ref | string(50) | A unique external reference for this company. This can be configured so that you do not accidentally create two instances of the same company. | |
| affiliates |
affiliates |
A list of affiliates with affiliate_id and its local reference for a company. |
No |
Examples
Get List
curl -basic --url http://[site].bookingbug.com/api/company.xml -uusername:password -H 'Content-type: text/xml' -X GET
curl -basic --url http://[site].bookingbug.com/api/company.json -uusername:password -H 'Content-type: application/json' -X GET
Get company
curl -basic --url http://[site].bookingbug.com/api/company/[id_of_company].xml -uusername:password -H 'Content-type: text/xml' -X GET
curl -basic --url http://[site].bookingbug.com/api/company/[id_of_company].json -uusername:password -H 'Content-type: application/json' -X GET
Create company
curl -basic --url http://[site].bookingbug.com/api/company.xml -uusername:password -H 'Content-type: text/xml' -X POST -d " <?xml version='1.0' encoding='UTF-8'?> <company> <name>Test company</name> <description>Description of test company</description> <address> <address1>address 1 of company</address1> <address2>address 2 of company</address2> <address3>address 3 of company</address3> <address4>address 4 of company</address4> <postcode>12345</postcode> <country>United Kingdom</country> <email>test@abc.com</email> <mobile>+44 1234567</mobile> <phone>+44 1234567</phone> <name>name of address</name> </address> <time_zone>GMT</time_zone> <administrators> <admin> <name>test_user</name> <role>1</role> <email>test_user@abc.com</email> </admin> <admin> <name>test_user_2</name> <role>1</role> <email>test_user_2@abc.com</email> </admin> </administrators> <template_id>10</template_id> <affiliates> <affiliate_id>123</affiliate_id> <reference>1</reference> </affiliates> <affiliates> <affiliate_id>1234</affiliate_id> <reference>2</reference> </affiliates> <affiliates> <affiliate_id>12345</affiliate_id> <reference>3</reference> </affiliates> </company> " OR curl -basic --url http://[site].bookingbug.com/api/company.xml -uusername:password -H 'Content-type: text/xml' -X POST -d " <?xml version='1.0' encoding='UTF-8'?> <company> <name>Test company</name> <description>Description of test company</description> <address> <address1>address 1 of company</address1> <address2>address 2 of company</address2> <address3>address 3 of company</address3> <address4>address 4 of company</address4> <postcode>12345</postcode> <country>United Kingdom</country> <email>test@abc.com</email> <mobile>+44 1234567</mobile> <phone>+44 1234567</phone> <name>name of address</name> </address> <time_zone>GMT</time_zone> <administrators> <admin> <name>test_user</name> <role>1</role> <email>test_user@abc.com</email> </admin> <admin> <name>test_user_2</name> <role>1</role> <email>test_user_2@abc.com</email> </admin> </administrators> <settings> <manage_people>1</manage_people> <manage_services>1</manage_services> <manage_resources>0</manage_resources> <has_classes>false</has_classes> <has_events>false</has_events> </settings> <affiliates> <affiliate_id>123</affiliate_id> <reference>1</reference> </affiliate> <affiliates> <affiliate_id>1234</affiliate_id> <reference>2</reference> </affiliates> <affiliates> <affiliate_id>12345</affiliate_id> <reference>3</reference> </affiliates> </company> "
curl -basic --url http://[site].bookingbug.com/api/company.json -uusername:password -H 'Content-type: application/json' -X POST -d {"company":{ "name":"Test company", "template_id":"10", "time_zone":"GMT", "description":"Description of test company", "administrators":[{ "admin":{ "name":"test_user", "role":"1", "email":"test_user@abc.com" } }, {"admin":{ "name":"test_user", "role":"1", "email":"test_user@abc.com" } }], "address":{"name":"name of address", "address1":"address 1 of resource", "address2":"address 2 of resource", "country":"United Kingdom", "postcode":"12345", "address3":"address 3 of resource", "address4":"address 4 of resource", "mobile":"+44 1234567", "phone":"+44 1234567", "email":"test@abc.com" }, "affiliates":[{ "affiliate_id":"123", "reference":"1" }, { "affiliate_id":"1234", "reference":"2" }, { "affiliate_id":"12345", "reference":"3" }] } } OR curl -basic --url http://[site].bookingbug.com/api/company.json -uusername:password -H 'Content-type: application/json' -X POST -d {"company":{ "name":"Test company", "time_zone":"GMT", "description":"Description of test company", "administrators":[{ "admin":{ "name":"test_user", "role":"1", "email":"test_user@abc.com" } }, {"admin":{ "name":"test_user", "role":"1", "email":"test_user@abc.com" } }], "address":{"name":"name of address", "address1":"address 1 of resource", "address2":"address 2 of resource", "country":"United Kingdom", "postcode":"12345", "address3":"address 3 of resource", "address4":"address 4 of resource", "mobile":"+44 1234567", "phone":"+44 1234567", "email":"test@abc.com" }, "settings":{"manage_people":1, "manage_services":1, "manage_resources":0, "has_classes":false, "has_events":false }, "affiliates":[{ "affiliate_id":"123", "reference":"1" }, { "affiliate_id":"1234", "reference":"2" }, { "affiliate_id":"12345", "reference":"3" }] } }
Note: You can only pass template_id or settings one at a time. Passing both options together will throw an error.
Edit company
curl -basic --url http://[site].bookingbug.com/api/company/[id of company].xml -uusername:password -H 'Content-type: text/xml' -X PUT -d " <?xml version='1.0' encoding='UTF-8'?> <company> <name>Test company</name> <description>Description of test company</description> <address> <address1>address 1 of company</address1> <address2>address 2 of company</address2> <address3>address 3 of company</address3> <address4>address 4 of company</address4> <postcode>12345</postcode> <country>United Kingdom</country> <email>test@abc.com</email> <mobile>+44 1234567</mobile> <phone>+44 1234567</phone> <name>name of address</name> </address> <time_zone>GMT</time_zone> <administrators> <admin> <name>test_user</name> <role>1</role> <email>test_user@abc.com</email> </admin> <admin> <name>test_user_2</name> <role>1</role> <email>test_user_2@abc.com</email> </admin> </administrators> <template_id>10</template_id> <affiliates> <affiliate_id>123</affiliate_id> <reference>1</reference> </affiliates> <affiliates> <affiliate_id>1234</affiliate_id> <reference>2</reference> </affiliates> <affiliates> <affiliate_id>12345</affiliate_id> <reference>3</reference> </affiliates> </company> " OR curl -basic --url http://[site].bookingbug.com/api/company/[id of company].xml -uusername:password -H 'Content-type: text/xml' -X PUT -d " <?xml version='1.0' encoding='UTF-8'?> <company> <name>Test company</name> <description>Description of test company</description> <address> <address1>address 1 of company</address1> <address2>address 2 of company</address2> <address3>address 3 of company</address3> <address4>address 4 of company</address4> <postcode>12345</postcode> <country>United Kingdom</country> <email>test@abc.com</email> <mobile>+44 1234567</mobile> <phone>+44 1234567</phone> <name>name of address</name> </address> <time_zone>GMT</time_zone> <administrators> <admin> <name>test_user</name> <role>1</role> <email>test_user@abc.com</email> </admin> <admin> <name>test_user_2</name> <role>1</role> <email>test_user_2@abc.com</email> </admin> </administrators> <settings> <manage_people>1</manage_people> <manage_services>1</manage_services> <manage_resources>0</manage_resources> <has_classes>false</has_classes> <has_events>false</has_events> </settings> <affiliates> <affiliate_id>123</affiliate_id> <reference>1</reference> </affiliate> <affiliates> <affiliate_id>1234</affiliate_id> <reference>2</reference> </affiliates> <affiliates> <affiliate_id>12345</affiliate_id> <reference>3</reference> </affiliates> </company> "
curl -basic --url http://[site].bookingbug.com/api/company/[id of company].json -uusername:password -H 'Content-type: application/json' -X PUT -d {"company":{ "name":"Test company", "template_id":"10", "time_zone":"GMT", "description":"Description of test company", "administrators":[{ "admin":{ "name":"test_user", "role":"1", "email":"test_user@abc.com" } }, {"admin":{ "name":"test_user", "role":"1", "email":"test_user@abc.com" } }], "address":{"name":"name of address", "address1":"address 1 of resource", "address2":"address 2 of resource", "country":"United Kingdom", "postcode":"12345", "address3":"address 3 of resource", "address4":"address 4 of resource", "mobile":"+44 1234567", "phone":"+44 1234567", "email":"test@abc.com" }, "affiliates":[{ "affiliate_id":"123", "reference":"1" }, { "affiliate_id":"1234", "reference":"2" }, { "affiliate_id":"12345", "reference":"3" }] } } OR curl -basic --url http://[site].bookingbug.com/api/company/[id of company].json -uusername:password -H 'Content-type: application/json' -X PUT -d {"company":{ "name":"Test company", "time_zone":"GMT", "description":"Description of test company", "administrators":[{ "admin":{ "name":"test_user", "role":"1", "email":"test_user@abc.com" } }, {"admin":{ "name":"test_user", "role":"1", "email":"test_user@abc.com" } }], "address":{"name":"name of address", "address1":"address 1 of resource", "address2":"address 2 of resource", "country":"United Kingdom", "postcode":"12345", "address3":"address 3 of resource", "address4":"address 4 of resource", "mobile":"+44 1234567", "phone":"+44 1234567", "email":"test@abc.com" }, "settings":{"manage_people":1, "manage_services":1, "manage_resources":0, "has_classes":false, "has_events":false }, "affiliates":[{ "affiliate_id":"123", "reference":"1" }, { "affiliate_id":"1234", "reference":"2" }, { "affiliate_id":"12345", "reference":"3" }] } }
Get Invoices
XML
curl -basic --url http://[site].bookingbug.com/api/company/invoices.xml -uusername:password -H 'Content-type: text/xml' -X GET
curl -basic --url http://[site].bookingbug.com/api/company/invoices.xml -uusername:password -H 'Content-type: text/xml' -X GET -d "
<company>
<company_id>
id_of_sub_company
</company_id>
</company>"
JSON
curl -basic --url http://[site].bookingbug.com/api/company/invoices.json -uusername:password -H 'Content-type: application/json' -X GET
curl -basic --url http://[site].bookingbug.com/api/company/invoices.json -uusername:password -H 'Content-type: application/json' -X GET -d {"company":{"company_id":id_of_sub_company}}