Replace all line item attributes in bulk across subscription contracts
Replaces the custom attributes (line item properties) of every line in each contract you choose with the one list you send. You can’t choose lines: every line gets exactly this list, and any attribute you leave out is removed from every line, Appstle’s own included. That also removes the five attributes that hold a Build-A-Box line’s box (products, _appstle-bb-id, __appstle-bb-name, _appstle-bb-product-sku and __appstle-bb-variants) and a one-time line’s _appstle-one-time-product, so that line is no longer removed after the next order. To give lines different attributes, or to change one line, use PUT /api/external/v2/subscription-contracts-update-multiple-line-item-attributes instead. The call returns 200 once it has accepted the request and updates the contracts afterwards, one line at a time, so how long it takes depends on how many contracts and lines there are. It doesn’t report the outcome: a contract ID that isn’t your store’s is skipped, a line that fails is skipped while the others are still updated, and if any contract ID isn’t a number, no contract is updated. To check the result, read each contract (GET /api/external/v2/subscription-contracts/contract-external/{contractId}) and look at lines.nodes[].customAttributes. Authenticate with the X-API-Key header.
curl --request PUT \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-bulk-update-line-item-attributes \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
[
{
"key": "gift_note",
"value": "For Sam"
}
]
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-bulk-update-line-item-attributes"
payload = [
{
"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([{key: 'gift_note', value: 'For Sam'}])
};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-bulk-update-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-bulk-update-line-item-attributes';
const options = {
method: 'PUT',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([{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-bulk-update-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([
[
'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-bulk-update-line-item-attributes"
payload := strings.NewReader("[\n {\n \"key\": \"gift_note\",\n \"value\": \"For Sam\"\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-bulk-update-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 {\n \"key\": \"gift_note\",\n \"value\": \"For Sam\"\n }\n]"
response = http.request(request)
puts response.read_bodyQuery Parameters
Body
The attributes, as key and value pairs, that replace the attributes of every line in each contract. Any attribute you leave out is removed from every line. The list can't be empty.
Response
The request was accepted. The contracts are updated after this response: read a contract to see the result.
curl --request PUT \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-bulk-update-line-item-attributes \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
[
{
"key": "gift_note",
"value": "For Sam"
}
]
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-bulk-update-line-item-attributes"
payload = [
{
"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([{key: 'gift_note', value: 'For Sam'}])
};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-bulk-update-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-bulk-update-line-item-attributes';
const options = {
method: 'PUT',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([{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-bulk-update-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([
[
'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-bulk-update-line-item-attributes"
payload := strings.NewReader("[\n {\n \"key\": \"gift_note\",\n \"value\": \"For Sam\"\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-bulk-update-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 {\n \"key\": \"gift_note\",\n \"value\": \"For Sam\"\n }\n]"
response = http.request(request)
puts response.read_body