curl --request DELETE \
--url https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cancel_at": "period_end",
"cancellation_details": {
"comment": "Switching plans",
"feedback": "switched_service"
}
}
'import requests
url = "https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}"
payload = {
"cancel_at": "period_end",
"cancellation_details": {
"comment": "Switching plans",
"feedback": "switched_service"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cancel_at: 'period_end',
cancellation_details: {comment: 'Switching plans', feedback: 'switched_service'}
})
};
fetch('https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'cancel_at' => 'period_end',
'cancellation_details' => [
'comment' => 'Switching plans',
'feedback' => 'switched_service'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}"
payload := strings.NewReader("{\n \"cancel_at\": \"period_end\",\n \"cancellation_details\": {\n \"comment\": \"Switching plans\",\n \"feedback\": \"switched_service\"\n }\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cancel_at\": \"period_end\",\n \"cancellation_details\": {\n \"comment\": \"Switching plans\",\n \"feedback\": \"switched_service\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cancel_at\": \"period_end\",\n \"cancellation_details\": {\n \"comment\": \"Switching plans\",\n \"feedback\": \"switched_service\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"config_id": "test_config_id",
"provider_account_id": "test_account_id",
"payment_provider": "stripe",
"subscription": {
"provider_customer_id": "test_customer_id",
"provider_subscription_id": "test_subscription_id",
"status": "canceled",
"description": null,
"items": [],
"cancellation_details": {
"comment": "no longer needed",
"feedback": "unused",
"reason": "cancellation_requested"
},
"discounts": [],
"cancel_at_period_end": false,
"cancel_at": null,
"canceled_at": 2000,
"ended_at": 2000,
"paused": false,
"resumes_at": null,
"metadata": {},
"start_date": 1300,
"trial_start": null,
"trial_end": null,
"collection_method": "charge_automatically",
"created": 1300,
"last_invoice": {
"provider_invoice_id": "test_invoice_id",
"created": 1300
},
"provider_payment_method_id": "test_payment_method_id",
"billing_cycle_anchor": 1300
}
}
}Cancel Subscription
Cancels a subscription. Supports three cancellation timing modes selected by the request body’s cancel_at field: immediate ("now"), at the end of the current billing period ("period_end"), or at a specific future timestamp (<unix-seconds>). The body is optional: without one, or without cancel_at, the subscription cancels at the end of the current billing period. Returns the resulting subscription in the same shape as GET /subscriptions/{provider_subscription_id}.
Cancellations are never prorated: no credit for unused time is created, whichever cancel_at you send.
/v0.1 of this operation is deprecated and stops working on 2027-01-17.
curl --request DELETE \
--url https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cancel_at": "period_end",
"cancellation_details": {
"comment": "Switching plans",
"feedback": "switched_service"
}
}
'import requests
url = "https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}"
payload = {
"cancel_at": "period_end",
"cancellation_details": {
"comment": "Switching plans",
"feedback": "switched_service"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cancel_at: 'period_end',
cancellation_details: {comment: 'Switching plans', feedback: 'switched_service'}
})
};
fetch('https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'cancel_at' => 'period_end',
'cancellation_details' => [
'comment' => 'Switching plans',
'feedback' => 'switched_service'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}"
payload := strings.NewReader("{\n \"cancel_at\": \"period_end\",\n \"cancellation_details\": {\n \"comment\": \"Switching plans\",\n \"feedback\": \"switched_service\"\n }\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cancel_at\": \"period_end\",\n \"cancellation_details\": {\n \"comment\": \"Switching plans\",\n \"feedback\": \"switched_service\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openloophealth.com/v0.2/subscriptions/{provider_subscription_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cancel_at\": \"period_end\",\n \"cancellation_details\": {\n \"comment\": \"Switching plans\",\n \"feedback\": \"switched_service\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"config_id": "test_config_id",
"provider_account_id": "test_account_id",
"payment_provider": "stripe",
"subscription": {
"provider_customer_id": "test_customer_id",
"provider_subscription_id": "test_subscription_id",
"status": "canceled",
"description": null,
"items": [],
"cancellation_details": {
"comment": "no longer needed",
"feedback": "unused",
"reason": "cancellation_requested"
},
"discounts": [],
"cancel_at_period_end": false,
"cancel_at": null,
"canceled_at": 2000,
"ended_at": 2000,
"paused": false,
"resumes_at": null,
"metadata": {},
"start_date": 1300,
"trial_start": null,
"trial_end": null,
"collection_method": "charge_automatically",
"created": 1300,
"last_invoice": {
"provider_invoice_id": "test_invoice_id",
"created": 1300
},
"provider_payment_method_id": "test_payment_method_id",
"billing_cycle_anchor": 1300
}
}
}Authorizations
Path Parameters
Body
"now" to cancel immediately, "period_end" to cancel at the end of the current billing period, or a future Unix timestamp (integer seconds), no later than the end of the current billing period, to cancel at that time. Defaults to "period_end" when omitted or null.
now, period_end 
