Site provisioning

Creating a Site

POST /api/sites.xml

Sometimes you may want to create a site by itself and manually associate it with an existing account or business. You can do that by submitting POST data to our site API controller.

Note: The business-category, address, city, state, postal-code, and primary-target-country fields are technically optional, but may be required for additional local targeting and reputation management features.

Form Parameters:
 
  • name – The name of the site (typically a business name)
  • account_id – Account ID to associate the site to
  • domain_attributes – Hash containing at minimum the name of the domain for this site
  • business_id – Business ID to associate the site to
  • add_ons – An array of add-ons to apply to the site

Expected Request Body:

<?xml version="1.0" encoding="UTF-8"?>
<site>
    <account-id type="integer">5</account-id>
    <business-id type="integer">9</business-id>
    <name>Business Name</name>
    <specialty-name>Computer Services</specialty-name>
    <address>123 Main St.</address>
    <city>Chicago</city>
    <state>IL</state>
    <postal-code>60606</postal-code>
    <primary-target-country>Unites States</primary-target-country>
    <plan-key>upcity_basic</plan-key>
    <domain-attributes>
        <name type="string">domain.com</name>
    </domain-attributes>
    <add-ons>
      <add-on>reputation-management</add-on>
    </add-ons>
</site>

Expected Response:

<?xml version="1.0" encoding="UTF-8"?>
<site>
    <account-id type="integer">5</account-id>
    <business-id type="integer">9</business-id>
    <address>123 Main St.</address>
    <cached-slug>domain-com-4</cached-slug>
    <city>Chicago</city>
    <cms-id type="integer" nil="true"></cms-id>
    <cms-other nil="true"></cms-other>
    <created-at type="datetime">2012-09-27T12:10:23-05:00</created-at>
    <deleted-at type="datetime" nil="true"></deleted-at>
    <description nil="true"></description>
    <domain-id type="integer">13105</domain-id>
    <enable-reputation-management type="boolean">false</enable-reputation-management>
    <id type="integer">393</id>
    <is-local type="boolean">true</is-local>
    <is-self-maintained type="boolean" nil="true"></is-self-maintained>
    <keyword-idea nil="true"></keyword-idea>
    <last-dashboard-email-delivery type="datetime" nil="true"></last-dashboard-email-delivery>
    <last-seo-progress-report-delivery type="datetime" nil="true"></last-seo-progress-report-delivery>
    <name>Business Name</name>
    <phone nil="true"></phone>
    <plan-id type="integer">1</plan-id>
    <postal-code>60606</postal-code>
    <primary-target-country>Unites States</primary-target-country>
    <specialty-id type="integer" nil="true"></specialty-id>
    <state>IL</state>
    <time-per-week nil="true"></time-per-week>
    <top-performer nil="true"></top-performer>
    <top-performer-added-at type="datetime" nil="true"></top-performer-added-at>
    <twitter-account nil="true"></twitter-account>
    <type-id type="integer">0</type-id>
    <updated-at type="datetime">2012-09-27T12:10:28-05:00</updated-at>
    <domain-name>domain.com</domain-name>
    <add-ons>
      <add-on>reputation-management</add-on>
    </add-ons>
</site>

Example Ruby Code:

require 'net/http'

site_data=<<XML
  <?xml version="1.0" encoding="UTF-8"?>
  <site>
    <name type="string">Business Name</name>
    <account-id type="integer">5</account-id>
    <domain-attributes>
      <name type="string">domain.com</name>
    </domain-attributes>
  </site>
XML

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

Updating a Site

PUT /api/sites/(int: site_id).xml

It might occasionally be useful to manually update the details of a Site. You can do that by submitting PUT data to our site API controller. The URL for this is:

Expected Request Body:

<?xml version="1.0" encoding="UTF-8"?>
<site>
    <name type="string">Business Name</name>
    <account-id type="integer">5</account-id>
    <business-id type="integer">9</business-id>
    <domain-attributes>
        <name type="string">domain.com</name>
    </domain-attributes>
</site>

Expected Response:

<?xml version="1.0" encoding="UTF-8"?>
<site>
    <account-id type="integer">5</account-id>
    <business-id type="integer">9</business-id>
    <address nil="true"></address>
    <cached-slug>domain-com-5</cached-slug>
    <city nil="true"></city>
    <cms-id type="integer" nil="true"></cms-id>
    <cms-other nil="true"></cms-other>
    <created-at type="datetime">2012-09-27T12:10:23-05:00</created-at>
    <deleted-at type="datetime" nil="true"></deleted-at>
    <description nil="true"></description>
    <domain-id type="integer">13105</domain-id>
    <enable-reputation-management type="boolean">false</enable-reputation-management>
    <id type="integer">5</id>
    <is-local type="boolean">true</is-local>
    <is-self-maintained type="boolean" nil="true"></is-self-maintained>
    <keyword-idea nil="true"></keyword-idea>
    <last-dashboard-email-delivery type="datetime" nil="true"></last-dashboard-email-delivery>
    <last-seo-progress-report-delivery type="datetime" nil="true"></last-seo-progress-report-delivery>
    <name>Business Name</name>
    <phone nil="true"></phone>
    <plan-id type="integer">1</plan-id>
    <postal-code nil="true"></postal-code>
    <primary-target-country nil="true"></primary-target-country>
    <specialty-id type="integer" nil="true"></specialty-id>
    <state nil="true"></state>
    <time-per-week nil="true"></time-per-week>
    <top-performer nil="true"></top-performer>
    <top-performer-added-at type="datetime" nil="true"></top-performer-added-at>
    <twitter-account nil="true"></twitter-account>
    <type-id type="integer">0</type-id>
    <updated-at type="datetime">2012-09-27T12:10:28-05:00</updated-at>
    <domain-name>domain.com</domain-name>
    <add-ons>
    </add-ons>
</site>

Example Ruby Code:

require 'net/http'

site_data=<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <site>
        <name type="string">Business Name</name>
        <account-id type="integer">5</account-id>
        <business-id type="integer">9</business-id>
        <domain-attributes>
            <name type="string">domain.com</name>
        </domain-attributes>
    </site>
XML

Net::HTTP.start('https://api.upcity.com') { |http|
    req = Net::HTTP::Put.new('/api/sites/5.xml')
    req.basic_auth 'partner_key', nil
    req.body = site_data
    response = http.request(req)
    print response.body
}

Deactivating a Site

GET /api/sites/(int: site_id)/deactivate.xml

Note that when a site is deactivated, the “deleted-at” property has been updated to the time of deactivation. The site is no longer in an active state, will no longer be billed, and cannot be retrieved via the API until it is reactivated (see below).

Example request:

GET /api/sites/1234/deactivate.xml

Expected response: Same as site creation.

Reactivating a Site

GET /api/sites/(int: site_id)/reactivate.xml

Note that when a site is reactivated, the “deleted-at” property has been updated to nil. The site is once again in an active state, and can be retrieved normally via the API.

Example request:

GET /api/sites/1234/reactivate.xml

Expected response: Same as site creation.