Update multiple line item attributes for a subscription contract
Replaces the custom attributes (line item properties) of each line you list in a subscription contract with exactly the list you send for that line. Each key in the request body is a line’s id from the contract’s lines.nodes, in the form gid://shopify/SubscriptionLine/<uuid>. Any attribute you leave out of a line’s list is removed, Appstle’s own included. To change one attribute, read the line’s current customAttributes first (GET /api/external/v2/subscription-contracts/contract-external/{contractId} returns them in lines.nodes), then send the complete list with your change. An empty list removes all of a line’s attributes, and the attributes of lines you don’t list aren’t changed. If any line is rejected, the call returns 400 and no line changes. A Build-A-Box line stores the box in five attributes (products, _appstle-bb-id, __appstle-bb-name, _appstle-bb-product-sku and __appstle-bb-variants), and a one-time line carries _appstle-one-time-product: leave that out and the line is no longer removed after the next order. The call acts as the merchant, so none of the customer portal’s rules apply: not the editing setting, the product-change window, the minimum-cycle freeze or the box’s limits. Authenticate with the X-API-Key header. The api_key query parameter is deprecated.
curl --request PUT \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f": [
{
"key": "license_key",
"value": "AAA-111"
},
{
"key": "gift_note",
"value": "For Sam"
}
]
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes"
payload = { "gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f": [
{
"key": "license_key",
"value": "AAA-111"
},
{
"key": "gift_note",
"value": "For Sam"
}
] }
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
'gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f': [{key: 'license_key', value: 'AAA-111'}, {key: 'gift_note', value: 'For Sam'}]
})
};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes';
const options = {
method: 'PUT',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
'gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f': [{key: 'license_key', value: 'AAA-111'}, {key: 'gift_note', value: 'For Sam'}]
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f' => [
[
'key' => 'license_key',
'value' => 'AAA-111'
],
[
'key' => 'gift_note',
'value' => 'For Sam'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-api-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://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes"
payload := strings.NewReader("{\n \"gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f\": [\n {\n \"key\": \"license_key\",\n \"value\": \"AAA-111\"\n },\n {\n \"key\": \"gift_note\",\n \"value\": \"For Sam\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
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))
}require 'uri'
require 'net/http'
url = URI("https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f\": [\n {\n \"key\": \"license_key\",\n \"value\": \"AAA-111\"\n },\n {\n \"key\": \"gift_note\",\n \"value\": \"For Sam\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyQuery Parameters
Body
A JSON object. Each key is a line's id from the contract's lines.nodes, as gid://shopify/SubscriptionLine/<uuid>. Each value is that line's complete list of attributes as key and value pairs, and it replaces all of the line's attributes: include every attribute the line should keep, because any you leave out are removed. Send an empty list to remove them all. The attributes of lines you don't list aren't changed.
Response
The contract after the change, with each line's attributes in lines.nodes[].customAttributes. The example is shortened: the response also has the contract's other fields, such as billingPolicy, deliveryPolicy, discounts and the contract's own customAttributes (which this call doesn't change), and more fields on each line and on the customer.
curl --request PUT \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f": [
{
"key": "license_key",
"value": "AAA-111"
},
{
"key": "gift_note",
"value": "For Sam"
}
]
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes"
payload = { "gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f": [
{
"key": "license_key",
"value": "AAA-111"
},
{
"key": "gift_note",
"value": "For Sam"
}
] }
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
'gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f': [{key: 'license_key', value: 'AAA-111'}, {key: 'gift_note', value: 'For Sam'}]
})
};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes';
const options = {
method: 'PUT',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
'gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f': [{key: 'license_key', value: 'AAA-111'}, {key: 'gift_note', value: 'For Sam'}]
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f' => [
[
'key' => 'license_key',
'value' => 'AAA-111'
],
[
'key' => 'gift_note',
'value' => 'For Sam'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-api-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://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes"
payload := strings.NewReader("{\n \"gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f\": [\n {\n \"key\": \"license_key\",\n \"value\": \"AAA-111\"\n },\n {\n \"key\": \"gift_note\",\n \"value\": \"For Sam\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
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))
}require 'uri'
require 'net/http'
url = URI("https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-update-multiple-line-item-attributes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"gid://shopify/SubscriptionLine/2f8c1d4e-7a3b-4c19-9d5e-6b0a1c2d3e4f\": [\n {\n \"key\": \"license_key\",\n \"value\": \"AAA-111\"\n },\n {\n \"key\": \"gift_note\",\n \"value\": \"For Sam\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body