Accepts details of two subscription
objects that you want to connect.
Connect subscriptions using
data_source_uuid
andexternal_id
.If you want to connect two subscriptions with the same subscription external id from the same data source (e.g. cancelled and reactivated subscription), use
data_source_uuid
anduuid
. Theuuid
of the subscription can be found via List Customer Subscriptions API query. The endpoint will return a 400 HTTP error when usingdata_source_uuid
andexternal_id
.
# Using data_source_uuid and subscription external_id to connect two subscriptions
curl -X POST "https://api.chartmogul.com/v1/customers/cus_f466e33d-ff2b-4a11-8f85-417eb02157a7/connect_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 connect two subscriptions
curl -X POST "https://api.chartmogul.com/v1/customers/cus_f466e33d-ff2b-4a11-8f85-417eb02157a7/connect_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.connect(customer.uuid, [second_sub])
ChartMogul.Customer.connectSubscriptions(
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::connectSubscriptions("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.ConnectSubscriptions("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.connectSubscriptions(
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{}>
Once a valid request is received by the API, it will respond with 202 - Accepted
, and the subscriptions will be connected asynchronously.
Connecting recently created subscriptions
If a subscription with the specified identifiers cannot be found, this endpoint will return an HTTP status
404
. In this context, it is important to note that invoices that have been imported recently, may not have been fully processed, and related subscriptions not yet generated. It is thus recommended to wait for all imported invoices to be completely processed and reported in the dashboard, before placing API requests for connecting subscriptions.