Skip to main content
POST
/
api
/
v1
/
usage
/
estimate
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.v1.usage.estimateCost({
  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.v1.usage.estimate_cost(
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.V1.Usage.EstimateCost(context.TODO(), stigg.V1UsageEstimateCostParams{
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.v1.usage.UsageEstimateCostParams;
import io.stigg.models.v1.usage.UsageEstimateCostResponse;

public final class Main {
private Main() {}

public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();

UsageEstimateCostParams params = UsageEstimateCostParams.builder()
.customerId("customerId")
.featureId("featureId")
.value(-9007199254740991L)
.build();
UsageEstimateCostResponse response = client.v1().usage().estimateCost(params);
}
}
require "stigg"

stigg = Stigg::Client.new(api_key: "My API Key")

response = stigg.v1.usage.estimate_cost(customer_id: "customerId", feature_id: "featureId", value: -9007199254740991)

puts(response)
using System;
using Stigg.Client;
using Stigg.Client.Models.V1.Usage;

StiggClient client = new();

UsageEstimateCostParams parameters = new()
{
CustomerID = "customerId",
FeatureID = "featureId",
Value = -9007199254740991,
};

var response = await client.V1.Usage.EstimateCost(parameters);

Console.WriteLine(response);
stigg v1:usage estimate-cost \
--api-key 'My API Key' \
--customer-id customerId \
--feature-id featureId \
--value -9007199254740991
curl --request POST \
--url https://api.stigg.io/api/v1/usage/estimate \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"value": -9007199254740990,
"featureId": "<string>",
"customerId": "<string>",
"resourceId": "<string>",
"updateBehavior": "DELTA",
"dimensions": {}
}
'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v1/usage/estimate",
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([
'value' => -9007199254740990,
'featureId' => '<string>',
'customerId' => '<string>',
'resourceId' => '<string>',
'updateBehavior' => 'DELTA',
'dimensions' => [

]
]),
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": {
    "estimates": [
      {
        "currencyId": "<string>",
        "estimatedCost": 123,
        "currentBalance": 123,
        "balanceAfterEstimate": 123,
        "wouldOverdraft": true,
        "breakdown": [
          {
            "featureId": "<string>",
            "cost": 123,
            "warningCode": "UNSUPPORTED_AGGREGATION"
          }
        ]
      }
    ],
    "warnings": []
  }
}
{
"message": "<string>"
}
{
"message": "<string>",
"code": "Unauthenticated"
}
{
"message": "<string>"
}
{
"message": "<string>"
}
{
"message": "<string>",
"code": "RateLimitExceeded"
}

Authorizations

X-API-KEY
string
header
required

Server API Key

Headers

X-ACCOUNT-ID
string

Account ID — optional when authenticating with a user JWT (Bearer token); falls back to the user's first membership. Ignored for API-key auth.

X-ENVIRONMENT-ID
string

Environment ID — required when authenticating with a user JWT (Bearer token) on environment-scoped endpoints. Ignored for API-key auth (env is intrinsic to the key).

Body

application/json

Estimate the credit cost of a usage report before reporting it

value
integer
required

The value to report for usage

Required range: x >= -9007199254740991
featureId
string
required

Feature id

Required string length: 1 - 255
Pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.-]*$
customerId
string
required

Customer id

Required string length: 1 - 255
Pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.@-]*$
resourceId
string | null

Resource id

Required string length: 1 - 255
Pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.-]*$
updateBehavior
enum<string>
default:DELTA

The method by which the usage value should be updated

Available options:
DELTA,
SET
dimensions
object

Additional dimensions for the usage report

Response

The credit cost estimation, including per-currency costs, balances, and warnings.

Response object

data
CreditCostEstimation · object
required

Estimated credit cost, current balance and balance after