curl -X POST \
/subscription-measurements \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <token>" \
--data '{
"subscriptionItem": "1QEHKTJY9097X91J78YRJEA9E8",
"measurementCode": "used_traffic"
}'import requests
url = "https://coreapi.io/subscription-measurements"
payload = {
"quantity": "10.239",
"measuredAt": "2021-01-01T00:00:00Z",
"subscription": "1QEHKTJY9097X91J78YRJEA9E8",
"subscriptionItem": "1QEHKTJY9097X91J78YRJEA9E8",
"measurementCode": "used_traffic"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
quantity: '10.239',
measuredAt: '2021-01-01T00:00:00Z',
subscription: '1QEHKTJY9097X91J78YRJEA9E8',
subscriptionItem: '1QEHKTJY9097X91J78YRJEA9E8',
measurementCode: 'used_traffic'
})
};
fetch('https://coreapi.io/subscription-measurements', 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://coreapi.io/subscription-measurements",
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([
'quantity' => '10.239',
'measuredAt' => '2021-01-01T00:00:00Z',
'subscription' => '1QEHKTJY9097X91J78YRJEA9E8',
'subscriptionItem' => '1QEHKTJY9097X91J78YRJEA9E8',
'measurementCode' => 'used_traffic'
]),
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;
}Add a subscription measurement.
Add a subscription measurement. This could be a quantity change, or a metered usage. On an organisation with subscription changes enabled, a quantity value of a recurring item is written as a quantity change step (the update_quantity of POST /api/subscriptions//changes), settled with the next invoice, also on a subscription that is cancelled as a whole and has not ended yet. Where the subscription change refuses the item, the request answers 422 with the type SUBSCRIPTION_CHANGE__INVALID_CHANGE and the violation subscription_change.item.not_found at steps[0].operations[0].item and writes nothing: an item of a paused subscription, an item cancelled on its own, an item of a contract created with a fixed end, and an ended item. A value of an item that is not activated yet is stored as before and billed with the activation.
curl -X POST \
/subscription-measurements \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <token>" \
--data '{
"subscriptionItem": "1QEHKTJY9097X91J78YRJEA9E8",
"measurementCode": "used_traffic"
}'import requests
url = "https://coreapi.io/subscription-measurements"
payload = {
"quantity": "10.239",
"measuredAt": "2021-01-01T00:00:00Z",
"subscription": "1QEHKTJY9097X91J78YRJEA9E8",
"subscriptionItem": "1QEHKTJY9097X91J78YRJEA9E8",
"measurementCode": "used_traffic"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
quantity: '10.239',
measuredAt: '2021-01-01T00:00:00Z',
subscription: '1QEHKTJY9097X91J78YRJEA9E8',
subscriptionItem: '1QEHKTJY9097X91J78YRJEA9E8',
measurementCode: 'used_traffic'
})
};
fetch('https://coreapi.io/subscription-measurements', 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://coreapi.io/subscription-measurements",
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([
'quantity' => '10.239',
'measuredAt' => '2021-01-01T00:00:00Z',
'subscription' => '1QEHKTJY9097X91J78YRJEA9E8',
'subscriptionItem' => '1QEHKTJY9097X91J78YRJEA9E8',
'measurementCode' => 'used_traffic'
]),
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;
}Autorisierungen
Body
The new MeasurementValue resource
The date the value was measured. If none is given, the current date is used. A date-time with an offset or a zone (2026-11-01T10:00:00+01:00, 2026-11-01T09:00:00Z) is taken as given; a date-time without a zone (2026-11-01T10:00:00) is read in the organisation's time zone; a date alone (2026-11-01) is 00:00 in the organisation's time zone. Stored as an instant and returned as an ISO-8601 date-time with offset.
"2021-01-01T00:00:00Z"
Antwort
MeasurementValue resource created
War diese Seite hilfreich?