Subscriptions
Update or swap a subscription
Updates the status of a subscription, allowing actions such as cancelation, immediate cancelation, resumption, or executing a swap (upgrade/downgrade). To execute a swap, set action to swap and provide variant_id or product_id in the body.
PATCH
/
subscriptions
/
{id}
Update or swap a subscription
curl --request PATCH \
--url https://api.blink.store/v1/subscriptions/{id} \
--header 'Content-Type: application/json' \
--header 'x-store-id: <x-store-id>' \
--data '
{
"variant_id": "<string>",
"product_id": "<string>"
}
'import requests
url = "https://api.blink.store/v1/subscriptions/{id}"
payload = {
"variant_id": "<string>",
"product_id": "<string>"
}
headers = {
"x-store-id": "<x-store-id>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'x-store-id': '<x-store-id>', 'Content-Type': 'application/json'},
body: JSON.stringify({variant_id: '<string>', product_id: '<string>'})
};
fetch('https://api.blink.store/v1/subscriptions/{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.blink.store/v1/subscriptions/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'variant_id' => '<string>',
'product_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-store-id: <x-store-id>"
],
]);
$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.blink.store/v1/subscriptions/{id}"
payload := strings.NewReader("{\n \"variant_id\": \"<string>\",\n \"product_id\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("x-store-id", "<x-store-id>")
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.patch("https://api.blink.store/v1/subscriptions/{id}")
.header("x-store-id", "<x-store-id>")
.header("Content-Type", "application/json")
.body("{\n \"variant_id\": \"<string>\",\n \"product_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.blink.store/v1/subscriptions/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["x-store-id"] = '<x-store-id>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"variant_id\": \"<string>\",\n \"product_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"store_id": "<string>",
"product_id": "<string>",
"variant_id": "<string>",
"status": "<string>",
"current_period_end": "2023-11-07T05:31:56Z",
"cancel_at_period_end": true,
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"stripe_subscription_id": "<string>",
"stripe_customer_id": "<string>",
"product": {
"id": "<string>",
"name": "<string>"
},
"variant": {
"id": "<string>",
"name": "<string>",
"price": 123
}
}
}Headers
Path Parameters
Body
application/json
Response
Subscription updated successfully
Show child attributes
Show child attributes
Previous
Create Blink Billing Portal SessionCreates a Stripe billing portal session. Note: This endpoint does not take a request body because the customer ID is derived from the required Customer Bearer token (JWT).
Next
āI
Update or swap a subscription
curl --request PATCH \
--url https://api.blink.store/v1/subscriptions/{id} \
--header 'Content-Type: application/json' \
--header 'x-store-id: <x-store-id>' \
--data '
{
"variant_id": "<string>",
"product_id": "<string>"
}
'import requests
url = "https://api.blink.store/v1/subscriptions/{id}"
payload = {
"variant_id": "<string>",
"product_id": "<string>"
}
headers = {
"x-store-id": "<x-store-id>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'x-store-id': '<x-store-id>', 'Content-Type': 'application/json'},
body: JSON.stringify({variant_id: '<string>', product_id: '<string>'})
};
fetch('https://api.blink.store/v1/subscriptions/{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.blink.store/v1/subscriptions/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'variant_id' => '<string>',
'product_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-store-id: <x-store-id>"
],
]);
$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.blink.store/v1/subscriptions/{id}"
payload := strings.NewReader("{\n \"variant_id\": \"<string>\",\n \"product_id\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("x-store-id", "<x-store-id>")
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.patch("https://api.blink.store/v1/subscriptions/{id}")
.header("x-store-id", "<x-store-id>")
.header("Content-Type", "application/json")
.body("{\n \"variant_id\": \"<string>\",\n \"product_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.blink.store/v1/subscriptions/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["x-store-id"] = '<x-store-id>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"variant_id\": \"<string>\",\n \"product_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"store_id": "<string>",
"product_id": "<string>",
"variant_id": "<string>",
"status": "<string>",
"current_period_end": "2023-11-07T05:31:56Z",
"cancel_at_period_end": true,
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"stripe_subscription_id": "<string>",
"stripe_customer_id": "<string>",
"product": {
"id": "<string>",
"name": "<string>"
},
"variant": {
"id": "<string>",
"name": "<string>",
"price": 123
}
}
}