Business provisioning

The Business Provisioning API provides an interface for creation of businesses, as well as deactivation and re-activation of existing businesses.

Creating a business with the API is simple, it requires you are sufficiently set up per the instructions on the API main page.

Business creation is done by submitting POST data to our business API controller. Businesses will automatically be provisioned to your partner account based on the API token you are given.

Creating a business

POST /businesses.xml

Create an Business object in the system. Returned is an XML description of the object created.

Form Parameters:
 
  • name – The name of the business
  • account_id – Account ID to associate the business to
Status Codes:

Example request:

<?xml version="1.0" encoding="UTF-8"?>
<business>
  <account-id>123</account-id>
  <name>Business Name</name>
</business>

Expected Response:

<?xml version="1.0" encoding="UTF-8"?>
<business>
  <id type="integer">1234</id>
  <created-at type="datetime">2009-12-28T14:45:30-06:00</created-at>
  <updated-at type="datetime">2011-01-20T01:32:13-06:00</updated-at>
  <account-id type="integer">123</account-id>
  <name>Business Name</name>
  <aasm-state>active</aasm-state>
</business>

Example Ruby Code:

require 'net/http'

business_data =<<XML
  <?xml version="1.0" encoding="UTF-8"?>
  <business>
    <name>Business Name</name>
  </business>
XML

Net::HTTP.start('https://api.upcity.com') { |http|
  req = Net::HTTP::Post.new('/api/businesses.xml')
  req.basic_auth 'partner_key', 'password'
  req.body = business_data
  response = http.request(req)
  print response.body
}

Deactivating A Business

GET /api/businesses/(int: business_id)/deactivate.xml
Status Codes:

Example request:

GET /api/businesses/1234/deactivate.xml
Host: upcity.com

Expected Response:

<?xml version="1.0" encoding="UTF-8"?>
<business>
  <id type="integer">1234</id>
  <created-at type="datetime">2009-12-28T14:45:30-06:00</created-at>
  <updated-at type="datetime">2011-01-20T01:32:13-06:00</updated-at>
  <account-id type="integer">123</account-id>
  <name>Business Name</name>
  <aasm-state>deactivated</aasm-state>
</business>

Re-activating A Business

GET /api/businesses/(int: business_id)/reactivate.xml
Status Codes:

Example request:

GET /api/businesses/1234/reactivate.xml
Host: upcity.com

Expected Response:

<?xml version="1.0" encoding="UTF-8"?>
<business>
  <id type="integer">1234</id>
  <created-at type="datetime">2009-12-28T14:45:30-06:00</created-at>
  <updated-at type="datetime">2011-01-20T01:32:13-06:00</updated-at>
  <account-id type="integer">123</account-id>
  <name>Business Name</name>
  <aasm-state>active</aasm-state>
</business>