Disconnect Subscriptions

POST https://api.chartmogul.com/v1/customers/CUSTOMER_UUID/disconnect_subscriptions

Accepts details of two subscription objects that you want to disconnect.

# Using data_source_uuid and subscription external_id to disconnect two subscriptions
curl -X POST "https://api.chartmogul.com/v1/customers/cus_f466e33d-ff2b-4a11-8f85-417eb02157a7/disconnect_subscriptions" \
     -u YOUR_API_KEY: \
     -H "Content-Type: application/json" \
     -d '{
            "subscriptions": [
              {
                "data_source_uuid": "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
                "external_id": "sub_0001"
              },
              {
                "data_source_uuid": "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
                "external_id": "sub_0002"
              }
            ]
        }'

# Or using data_source_uuid and subscriptions uuid to disconnect two subscriptions

curl -X POST "https://api.chartmogul.com/v1/customers/cus_f466e33d-ff2b-4a11-8f85-417eb02157a7/disconnect_subscriptions" \
     -u YOUR_API_KEY: \
     -H "Content-Type: application/json" \
     -d '{
            "subscriptions": [
              {
                "data_source_uuid": "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
                "uuid": "sub_d1c0c885-add0-48db-8fa9-0bdf5017d6b0"
              },
              {
                "data_source_uuid": "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
                "uuid": "sub_9db5f4a1-1695-44c0-8bd4-de7ce4d0f1d4"
              }
            ]
        }'
customer = ChartMogul::Customer.retrieve("cus_f466e33d-ff2b-4a11-8f85-417eb02157a7")

first_sub = customer.subscriptions.find { |e| e.external_id == "sub_0001" }

second_sub = customer.subscriptions.find { |e| e.external_id == "sub_0002" }

first_sub.disconnect(customer.uuid, [second_sub])
ChartMogul.Customer.disconnectSubscriptions(
  config,
  "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7",
  {
    subscriptions: [
      {
        data_source_uuid: "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
        external_id: "sub_0001",
      },
      {
        data_source_uuid: "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
        external_id: "sub_0002",
      },
    ],
  }
);
ChartMogul\Customer::disconnectSubscriptions("cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", [
  "subscriptions" => [
    [
      "data_source_uuid" => "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
      "external_id" => "sub_0001",
    ],
    [
      "data_source_uuid" => "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
      "external_id" => "sub_0002",
    ],
  ]
]);
api.DisonnectSubscriptions("cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", []cm.Subscription{
  {
    DataSourceUUID: "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
    ExternalID:     "sub_0001",
  },
  {
    DataSourceUUID: "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
    ExternalID:     "sub_0002",
  },
})
chartmogul.Customer.disconnectSubscriptions(
  config,
  uuid="cus_f466e33d-ff2b-4a11-8f85-417eb02157a7",
  data={
    "subscriptions": [
        {
            "data_source_uuid": "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
            "external_id": "sub_0001",
        },
        {
            "data_source_uuid": "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
            "external_id": "sub_0002",
        },
    ]
  },
)
{}
true
{}
true
None
<Customer{}>

Disconnect subscriptions using data_source_uuid and external_id.

If you want to disconnect two subscriptions with the same subscription external id from the same data source (e.g. canceled and reactivated subscription), use data_source_uuid and uuid. The uuid of the subscription can be found via List Customer Subscriptions API query. The endpoint will return a 400 HTTP error when using data_source_uuid and external_id.

Query parameters

customer_uuid string
The ChartMogul UUID of the Customer whose subscriptions you need to disconnect.

Body parameters

subscriptions array(object) required
Identifiers for two or more subscriptions that you want to disconnect.

Response

Once a valid request is received by the API, it will respond with 202 - Accepted, and the subscriptions will be disconnected asynchronously.