JavaScript
import Stigg from '@stigg/typescript';
const client = new Stigg({
apiKey: process.env['STIGG_API_KEY'], // This is the default and can be omitted
});
const response = await client.v2.usage.report({
usages: [
{
customerId: 'customerId',
featureId: 'featureId',
value: -9007199254740991,
},
],
});
console.log(response.data);import os
from stigg import Stigg
client = Stigg(
api_key=os.environ.get("STIGG_API_KEY"), # This is the default and can be omitted
)
response = client.v2.usage.report(
usages=[{
"customer_id": "customerId",
"feature_id": "featureId",
"value": -9007199254740991,
}],
)
print(response.data)package main
import (
"context"
"fmt"
"github.com/stiggio/stigg-go"
"github.com/stiggio/stigg-go/option"
)
func main() {
client := stigg.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.V2.Usage.Report(context.TODO(), stigg.V2UsageReportParams{
Usages: []stigg.V2UsageReportParamsUsage{{
CustomerID: "customerId",
FeatureID: "featureId",
Value: -9007199254740991,
}},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package io.stigg.example;
import io.stigg.client.StiggClient;
import io.stigg.client.okhttp.StiggOkHttpClient;
import io.stigg.models.v2.usage.UsageReportParams;
import io.stigg.models.v2.usage.UsageReportResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
UsageReportParams params = UsageReportParams.builder()
.addUsage(UsageReportParams.Usage.builder()
.customerId("customerId")
.featureId("featureId")
.value(-9007199254740991.0)
.build())
.build();
UsageReportResponse response = client.v2().usage().report(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v2.usage.report(
usages: [{customerId: "customerId", featureId: "featureId", value: -9007199254740991}]
)
puts(response)using System;
using System.Collections.Generic;
using Stigg.Client;
using Stigg.Client.Models.V2.Usage;
StiggClient client = new();
UsageReportParams parameters = new()
{
Usages =
[
new()
{
CustomerID = "customerId",
FeatureID = "featureId",
Value = -9007199254740991,
CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
Dimensions = new Dictionary<string, Dimension>()
{
{ "foo", "string" }
},
IdempotencyKey = "x",
ResourceID = "resourceId",
UpdateBehavior = UpdateBehavior.Delta,
},
],
};
var response = await client.V2.Usage.Report(parameters);
Console.WriteLine(response);stigg v2:usage report \
--api-key 'My API Key' \
--usage '{customerId: customerId, featureId: featureId, value: -9007199254740991}'curl --request POST \
--url https://api.stigg.io/api/v2/usage \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"usages": [
{
"value": 0,
"featureId": "<string>",
"customerId": "<string>",
"resourceId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updateBehavior": "DELTA",
"dimensions": {},
"idempotencyKey": "<string>"
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v2/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([
'usages' => [
[
'value' => 0,
'featureId' => '<string>',
'customerId' => '<string>',
'resourceId' => '<string>',
'createdAt' => '2023-11-07T05:31:56Z',
'updateBehavior' => 'DELTA',
'dimensions' => [
],
'idempotencyKey' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"data": {
"usages": [
{
"id": "<string>",
"value": 123,
"timestamp": "2023-11-07T05:31:56Z",
"featureId": "<string>",
"customerId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"currentUsage": 123,
"credit": {
"currencyId": "<string>",
"consumed": 123
},
"usagePeriodStart": "2023-11-07T05:31:56Z",
"usagePeriodEnd": "2023-11-07T05:31:56Z",
"nextResetDate": "2023-11-07T05:31:56Z",
"resourceId": "<string>"
}
],
"credits": [
{
"currencyId": "<string>",
"currentUsage": 123,
"usageLimit": 123,
"timestamp": "2023-11-07T05:31:56Z",
"customerId": "<string>",
"resourceId": "<string>",
"usagePeriodEnd": "2023-11-07T05:31:56Z"
}
],
"entities": [
{
"customerId": "<string>",
"resourceId": "<string>",
"entityId": "<string>",
"entitlementId": "<string>",
"scopeEntityIds": [
"<string>"
],
"currentUsage": 123,
"usageUpdatedAt": "2023-11-07T05:31:56Z",
"featureId": "<string>",
"currencyId": "<string>"
}
]
}
}{
"message": "<string>",
"code": "BadUserInput",
"reason": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>",
"code": "IdentityForbidden"
}{
"message": "<string>",
"code": "DuplicatedEntityNotAllowed"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Usage
Report usage measurements (v2)
Reports usage measurements for metered features. The reported usage is used to track, limit, and bill customer consumption. Credit balances are returned once per wallet in credits, not on each measurement.
POST
/
api
/
v2
/
usage
JavaScript
import Stigg from '@stigg/typescript';
const client = new Stigg({
apiKey: process.env['STIGG_API_KEY'], // This is the default and can be omitted
});
const response = await client.v2.usage.report({
usages: [
{
customerId: 'customerId',
featureId: 'featureId',
value: -9007199254740991,
},
],
});
console.log(response.data);import os
from stigg import Stigg
client = Stigg(
api_key=os.environ.get("STIGG_API_KEY"), # This is the default and can be omitted
)
response = client.v2.usage.report(
usages=[{
"customer_id": "customerId",
"feature_id": "featureId",
"value": -9007199254740991,
}],
)
print(response.data)package main
import (
"context"
"fmt"
"github.com/stiggio/stigg-go"
"github.com/stiggio/stigg-go/option"
)
func main() {
client := stigg.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.V2.Usage.Report(context.TODO(), stigg.V2UsageReportParams{
Usages: []stigg.V2UsageReportParamsUsage{{
CustomerID: "customerId",
FeatureID: "featureId",
Value: -9007199254740991,
}},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package io.stigg.example;
import io.stigg.client.StiggClient;
import io.stigg.client.okhttp.StiggOkHttpClient;
import io.stigg.models.v2.usage.UsageReportParams;
import io.stigg.models.v2.usage.UsageReportResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
UsageReportParams params = UsageReportParams.builder()
.addUsage(UsageReportParams.Usage.builder()
.customerId("customerId")
.featureId("featureId")
.value(-9007199254740991.0)
.build())
.build();
UsageReportResponse response = client.v2().usage().report(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v2.usage.report(
usages: [{customerId: "customerId", featureId: "featureId", value: -9007199254740991}]
)
puts(response)using System;
using System.Collections.Generic;
using Stigg.Client;
using Stigg.Client.Models.V2.Usage;
StiggClient client = new();
UsageReportParams parameters = new()
{
Usages =
[
new()
{
CustomerID = "customerId",
FeatureID = "featureId",
Value = -9007199254740991,
CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
Dimensions = new Dictionary<string, Dimension>()
{
{ "foo", "string" }
},
IdempotencyKey = "x",
ResourceID = "resourceId",
UpdateBehavior = UpdateBehavior.Delta,
},
],
};
var response = await client.V2.Usage.Report(parameters);
Console.WriteLine(response);stigg v2:usage report \
--api-key 'My API Key' \
--usage '{customerId: customerId, featureId: featureId, value: -9007199254740991}'curl --request POST \
--url https://api.stigg.io/api/v2/usage \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"usages": [
{
"value": 0,
"featureId": "<string>",
"customerId": "<string>",
"resourceId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updateBehavior": "DELTA",
"dimensions": {},
"idempotencyKey": "<string>"
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v2/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([
'usages' => [
[
'value' => 0,
'featureId' => '<string>',
'customerId' => '<string>',
'resourceId' => '<string>',
'createdAt' => '2023-11-07T05:31:56Z',
'updateBehavior' => 'DELTA',
'dimensions' => [
],
'idempotencyKey' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"data": {
"usages": [
{
"id": "<string>",
"value": 123,
"timestamp": "2023-11-07T05:31:56Z",
"featureId": "<string>",
"customerId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"currentUsage": 123,
"credit": {
"currencyId": "<string>",
"consumed": 123
},
"usagePeriodStart": "2023-11-07T05:31:56Z",
"usagePeriodEnd": "2023-11-07T05:31:56Z",
"nextResetDate": "2023-11-07T05:31:56Z",
"resourceId": "<string>"
}
],
"credits": [
{
"currencyId": "<string>",
"currentUsage": 123,
"usageLimit": 123,
"timestamp": "2023-11-07T05:31:56Z",
"customerId": "<string>",
"resourceId": "<string>",
"usagePeriodEnd": "2023-11-07T05:31:56Z"
}
],
"entities": [
{
"customerId": "<string>",
"resourceId": "<string>",
"entityId": "<string>",
"entitlementId": "<string>",
"scopeEntityIds": [
"<string>"
],
"currentUsage": 123,
"usageUpdatedAt": "2023-11-07T05:31:56Z",
"featureId": "<string>",
"currencyId": "<string>"
}
]
}
}{
"message": "<string>",
"code": "BadUserInput",
"reason": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>",
"code": "IdentityForbidden"
}{
"message": "<string>",
"code": "DuplicatedEntityNotAllowed"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Headers
Body
application/json
Response
The recorded usage measurements and the balance of each credit wallet they drew from.