Create a Plan

POST https://api.chartmogul.com/v1/plans

Creates a plan object in ChartMogul under the specified data_source.

curl -X POST "https://api.chartmogul.com/v1/import/plans" \
     -u YOUR_API_KEY: \
     -H "Content-Type: application/json" \
     -d '{ 
            "data_source_uuid": "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
            "name": "Bronze Plan",
            "interval_count": 1,
            "interval_unit": "month",
            "external_id": "plan_0001"
         }'
ChartMogul::Import::Plan.create!(
  data_source_uuid: "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
  name: "Bronze Plan",
  interval_count: 1,
  interval_unit: "month",
  external_id: "plan_0001",
)
ChartMogul.Plan.create(config, {
  data_source_uuid: "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
  name: "Bronze Plan",
  interval_count: 1,
  interval_unit: "month",
  external_id: "plan_0001",
});
ChartMogul\Import\Plan::create([
  "data_source_uuid" => "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
  "name" => "Bronze Plan",
  "interval_count" => 1,
  "interval_unit" => "month",
  "external_id" => "plan_0001"
]);
api.CreatePlan(&cm.Plan{
  DataSourceUUID: "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
  Name:           "Bronze Plan",
  IntervalCount:  1,
  IntervalUnit:   "month",
  ExternalID:     "plan_0001",
})
chartmogul.Plan.create(
  config,
  data={
    "data_source_uuid": "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
    "name": "Bronze Plan",
    "interval_count": 1,
    "interval_unit": "month",
    "external_id": "plan_0001",
  },
)
{
  "uuid": "pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
  "data_source_uuid": "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
  "name": "Bronze Plan",
  "interval_count": 1,
  "interval_unit": "month",
  "external_id": "plan_0001"
}
#<ChartMogul::Import::Plan:0x007fb4993f25a0 
  @uuid="pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
  @data_source_uuid="ds_fef05d54-47b4-431b-aed2-eb6b9e545430", 
  @name="Bronze Plan", 
  @interval_count=1, 
  @interval_unit="month", 
  @external_id="plan_0001"
>
{
  uuid: "pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
  data_source_uuid: "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
  name: "Bronze Plan",
  interval_count: 1,
  interval_unit: "month",
  external_id: "plan_0001"
}
ChartMogul\Import\Plan::__set_state(array(
  "uuid" => "pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
  "name" => "Bronze Plan",
  "interval_count" => 1,
  "interval_unit" => "month",
  "external_id" => "plan_0001",
  "data_source_uuid" => "ds_fef05d54-47b4-431b-aed2-eb6b9e545430"
));
(*chartmogul.Plan)(0xc04203e5a0)({
  UUID: (string) (len=39) "pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
  DataSourceUUID: (string) (len=39) "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
  ExternalID: (string) (len=9) "plan_0001",
  Name: (string) (len=11) "Bronze Plan",
  IntervalCount: (uint32) 1,
  IntervalUnit: (string) (len=5) "month"
 })
<Plan{
  data_source_uuid="ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
  external_id="plan_0001",
  interval_count=1,
  interval_unit="month",
  name="Bronze Plan",
  uuid="pl_eed05d54-75b4-431b-adb2-eb6b9e543206"
}>

Body parameters

data_source_uuid string required
The ChartMogul UUID of the data source for this subscription plan.
name string required
Display name of the plan. Accepts alphanumeric characters.
interval_count integer required
The frequency of billing interval. Accepts integers greater than 0. eg. 6 for a half-yearly plan.
interval_unit string required
The unit of billing interval. One of day, month, or year. eg. month for the above half-yearly plan.
external_id string
A unique identifier specified by you for the plan. Typically an identifier from your internal system. Accepts alphanumeric characters. If not provided, ChartMogul will automatically generate one.

Response

In the response, the JSON object contains the following data:

uuid
The UUID of the plan object generated by ChartMogul.
data_source_uuid
The UUID of the data source that this subscription plan belongs to.
name
Name of this plan, as specified by you.
interval_count
The number of intervals (specified in the interval_unit attribute) between each billing date.
interval_unit
The frequency with which a subscription for this plan is billed. For example, if you bill your customer every 3 months for a subscription with this plan, then interval_count would be 3 and interval_unit would be month.
external_id
The unique external identifier for this plan, as specified by you.