curl --request POST \
--url https://api.statisfy.com/v1/products/{product_id}/usage \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"rows": [
{
"account": "<string>",
"date": "2023-12-25",
"values": {}
}
]
}
'import requests
url = "https://api.statisfy.com/v1/products/{product_id}/usage"
payload = { "rows": [
{
"account": "<string>",
"date": "2023-12-25",
"values": {}
}
] }
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({rows: [{account: '<string>', date: '2023-12-25', values: {}}]})
};
fetch('https://api.statisfy.com/v1/products/{product_id}/usage', 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.statisfy.com/v1/products/{product_id}/usage",
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([
'rows' => [
[
'account' => '<string>',
'date' => '2023-12-25',
'values' => [
]
]
]
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.statisfy.com/v1/products/{product_id}/usage"
payload := strings.NewReader("{\n \"rows\": [\n {\n \"account\": \"<string>\",\n \"date\": \"2023-12-25\",\n \"values\": {}\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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.statisfy.com/v1/products/{product_id}/usage")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rows\": [\n {\n \"account\": \"<string>\",\n \"date\": \"2023-12-25\",\n \"values\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.statisfy.com/v1/products/{product_id}/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rows\": [\n {\n \"account\": \"<string>\",\n \"date\": \"2023-12-25\",\n \"values\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"failed": 123,
"rows": [
{
"date": "2023-12-25",
"index": 123,
"status": "written",
"account": "<string>",
"error": {
"code": "<string>",
"message": "<string>",
"details": [
{}
]
}
}
],
"written": 123
}Write a product's usage values
Writes up to 1000 rows, each one account’s values for one date: values maps the product’s dimension keys to values (null deletes one; keys not sent are kept). match says what account is: id (default), crm_account_id (either Salesforce form) or domain (an account’s domain or alias). Each row is checked on its own: a row with a problem (for example, an account not found; a domain several accounts share, or a CRM id a deleted account holds, whose details list the accounts; a key that is not one of the product’s dimensions, or whose type this API does not write; a value of the wrong kind; an account and period an earlier row names, the earlier row being written) is not written and carries its error, and the others are written in one transaction. Answers 200 listing every row. A whole call is one write against the rate limits, and sending it again is safe. A product the app shows by pillar is a 409, as is a write that waited too long on another write to the product or its dates (send it again). Usage values are what a product’s dimensions measure, per account and date, at the product’s period (its period; the app shows usage at no other, and a product with none set shows at MONTHLY). A write moves a date to its period’s first day: for WEEKLY, the weekday the product’s latest weekly row falls on (Monday when it has none); the 1st for MONTHLY; the first day of the quarter for QUARTERLY (in the product’s quarter cycle; calendar quarters when it has no rows), and January 1 for YEARLY; DAILY and SINGLE keep the date sent. An account has one row per date here: where data feeds stored several (older rows, or a CSV feed set to allow multiple rows per customer), the one written and listed is the row the feeds write today, else the oldest, while the app shows them all. A product with no display settings, or a period this API does not know, is a 409.
curl --request POST \
--url https://api.statisfy.com/v1/products/{product_id}/usage \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"rows": [
{
"account": "<string>",
"date": "2023-12-25",
"values": {}
}
]
}
'import requests
url = "https://api.statisfy.com/v1/products/{product_id}/usage"
payload = { "rows": [
{
"account": "<string>",
"date": "2023-12-25",
"values": {}
}
] }
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({rows: [{account: '<string>', date: '2023-12-25', values: {}}]})
};
fetch('https://api.statisfy.com/v1/products/{product_id}/usage', 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.statisfy.com/v1/products/{product_id}/usage",
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([
'rows' => [
[
'account' => '<string>',
'date' => '2023-12-25',
'values' => [
]
]
]
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.statisfy.com/v1/products/{product_id}/usage"
payload := strings.NewReader("{\n \"rows\": [\n {\n \"account\": \"<string>\",\n \"date\": \"2023-12-25\",\n \"values\": {}\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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.statisfy.com/v1/products/{product_id}/usage")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rows\": [\n {\n \"account\": \"<string>\",\n \"date\": \"2023-12-25\",\n \"values\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.statisfy.com/v1/products/{product_id}/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rows\": [\n {\n \"account\": \"<string>\",\n \"date\": \"2023-12-25\",\n \"values\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"failed": 123,
"rows": [
{
"date": "2023-12-25",
"index": 123,
"status": "written",
"account": "<string>",
"error": {
"code": "<string>",
"message": "<string>",
"details": [
{}
]
}
}
],
"written": 123
}Authorizations
An API key, sent as Authorization: Bearer stfy_live_…. See Authentication for how to get one and which scopes it needs.
Query Parameters
Body
Was this page helpful?