Programatically Subscribing a Subscriber to a Free Trial Plan

To subscribe a subscriber to a free trial plan via the API, just do an HTTP POST like so:

[ ~ ] $ curl -u 2dac9d3d93326f97da4845d407789da232514b48:X -H 'Content-Type: application/xml' -d '<subscription-plan><id>2</id></subscription-plan>' https://spreedly.com/api/v4/meresheep/subscribers/444/subscribe_to_free_trial.xml

Here is the response:

<?xml version="1.0" encoding="UTF-8"?>
<subscriber>
  <active type="boolean">true</active>
  <active-until type="datetime">2008-02-21T19:04:28Z</active-until>
  <billing-first-name></billing-first-name>
  <billing-last-name></billing-last-name>
  <card-expires-before-next-auto-renew type="boolean">false</card-expires-before-next-auto-renew>
  <created-at type="datetime">2007-12-21T18:54:24Z</created-at>
  <customer-id>444</customer-id>
  <eligible-for-free-trial type="boolean">false</eligible-for-free-trial>
  <email></email>
  <feature-level type="string">Pro</feature-level>
  <lifetime-subscription type="boolean">false</lifetime-subscription>
  <on-trial type="boolean">true</on-trial>
  <recurring type="boolean">false</recurring>
  <screen-name>freddy</screen-name>
  <store-credit type="decimal">0.0</store-credit>
  <subscription-plan-name>Super Pro Account</subscription-plan-name>
  <token>1c08af7ef78f1a4b51127cf0ddfe7b2b24681b6c</token>
  <updated-at type="datetime">2007-12-21T19:04:28Z</updated-at>
</subscriber>

If successful, a 200 (OK) status code is returned.

The xml of the subscriber is returned in the response body. In addition, the Location header in the response will be set to the url of the subscriber.

Errors:

A 404 (Not Found) status code is returned if there is no subscriber with the customer id or if there is no subscription plan with the ID you specified. You can create a subscriber programatically if you need to.

A 422 (Unprocessable Entity) is returned if you don't specify a subscription plan id.

A 403 (Forbidden) is returned if the subscription plan isn't a free trial or if the subscriber is not eligible for a free trial or if the subscription plan is not enabled.

Return to the Integration Reference ↑

Olark Livehelp