Move a subscription to another plan
curl --request POST \
--url https://api.cope.com/v1/commerce/subscriptions/{id}/plan \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"plan_id": "plan_A1b2C3d4"
}
'import requests
url = "https://api.cope.com/v1/commerce/subscriptions/{id}/plan"
payload = { "plan_id": "plan_A1b2C3d4" }
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({plan_id: 'plan_A1b2C3d4'})
};
fetch('https://api.cope.com/v1/commerce/subscriptions/{id}/plan', 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.cope.com/v1/commerce/subscriptions/{id}/plan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'plan_id' => 'plan_A1b2C3d4'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$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.cope.com/v1/commerce/subscriptions/{id}/plan"
payload := strings.NewReader("{\n \"plan_id\": \"plan_A1b2C3d4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.post("https://api.cope.com/v1/commerce/subscriptions/{id}/plan")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"plan_id\": \"plan_A1b2C3d4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cope.com/v1/commerce/subscriptions/{id}/plan")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"plan_id\": \"plan_A1b2C3d4\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"effective_at": "<string>",
"effective_confirmed_at": "<string>",
"failure": {
"code": "<string>",
"message": "<string>"
},
"from": {
"amount_cents": 123,
"currency": "<string>",
"plan_id": "<string>"
},
"reason": "<string>",
"requested_by": {
"actor_id": "<string>",
"actor_type": "<string>",
"business_id": "<string>",
"initiated_by": "<string>"
},
"status": "<string>",
"subscription_id": "<string>",
"to": {
"amount_cents": 123,
"currency": "<string>",
"plan_id": "<string>"
},
"type": "<string>"
}
}
Move a subscription to another plan
POST
/
v1
/
commerce
/
subscriptions
/
{id}
/
plan
Move a subscription to another plan
curl --request POST \
--url https://api.cope.com/v1/commerce/subscriptions/{id}/plan \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"plan_id": "plan_A1b2C3d4"
}
'import requests
url = "https://api.cope.com/v1/commerce/subscriptions/{id}/plan"
payload = { "plan_id": "plan_A1b2C3d4" }
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({plan_id: 'plan_A1b2C3d4'})
};
fetch('https://api.cope.com/v1/commerce/subscriptions/{id}/plan', 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.cope.com/v1/commerce/subscriptions/{id}/plan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'plan_id' => 'plan_A1b2C3d4'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$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.cope.com/v1/commerce/subscriptions/{id}/plan"
payload := strings.NewReader("{\n \"plan_id\": \"plan_A1b2C3d4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.post("https://api.cope.com/v1/commerce/subscriptions/{id}/plan")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"plan_id\": \"plan_A1b2C3d4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cope.com/v1/commerce/subscriptions/{id}/plan")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"plan_id\": \"plan_A1b2C3d4\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"effective_at": "<string>",
"effective_confirmed_at": "<string>",
"failure": {
"code": "<string>",
"message": "<string>"
},
"from": {
"amount_cents": 123,
"currency": "<string>",
"plan_id": "<string>"
},
"reason": "<string>",
"requested_by": {
"actor_id": "<string>",
"actor_type": "<string>",
"business_id": "<string>",
"initiated_by": "<string>"
},
"status": "<string>",
"subscription_id": "<string>",
"to": {
"amount_cents": 123,
"currency": "<string>",
"plan_id": "<string>"
},
"type": "<string>"
}
}
Authorizations
Bearer credential for the public API. Vendor integrations should send a live COPE API key (ck_live_*; keys issued earlier as cope_sk_live_* keep working). Clerk bearer tokens are also accepted when paired with X-Cope-Business-Id.
Headers
Required. At most 255 characters of valid UTF-8 with no NUL byte. The change attempt is recorded against this key for this subscription: a retry that carries the same key and the same body returns the original response instead of changing the subscription twice, and the same key with a different body is refused with 409 idempotency_conflict.
Maximum string length:
255Path Parameters
id public identifier.
Pattern:
^sub_[A-Za-z0-9]{8,32}$Example:
"sub_A1b2C3d4E5f6G7h8"
Body
application/json
Pattern:
^plan_[A-Za-z0-9]{8,32}$Example:
"plan_A1b2C3d4"
Response
Successful response
Show child attributes
Show child attributes