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.credits.consumption.consumeAsync({
consumptions: [
{
amount: 1,
currencyId: 'currencyId',
customerId: 'customerId',
idempotencyKey: 'x',
},
],
});
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.credits.consumption.consume_async(
consumptions=[{
"amount": 1,
"currency_id": "currencyId",
"customer_id": "customerId",
"idempotency_key": "x",
}],
)
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.Credits.Consumption.ConsumeAsync(context.TODO(), stigg.V1CreditConsumptionConsumeAsyncParams{
Consumptions: []stigg.V1CreditConsumptionConsumeAsyncParamsConsumption{{
Amount: 1,
CurrencyID: "currencyId",
CustomerID: "customerId",
IdempotencyKey: "x",
}},
})
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.credits.consumption.ConsumptionConsumeAsyncParams;
import io.stigg.models.v1.credits.consumption.ConsumptionConsumeAsyncResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
ConsumptionConsumeAsyncParams params = ConsumptionConsumeAsyncParams.builder()
.addConsumption(ConsumptionConsumeAsyncParams.Consumption.builder()
.amount(1.0)
.currencyId("currencyId")
.customerId("customerId")
.idempotencyKey("x")
.build())
.build();
ConsumptionConsumeAsyncResponse response = client.v1().credits().consumption().consumeAsync(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v1.credits.consumption.consume_async(
consumptions: [{amount: 1, currencyId: "currencyId", customerId: "customerId", idempotencyKey: "x"}]
)
puts(response)using System;
using System.Collections.Generic;
using Stigg.Client;
using Stigg.Client.Models.V1.Credits.Consumption;
StiggClient client = new();
ConsumptionConsumeAsyncParams parameters = new()
{
Consumptions =
[
new()
{
Amount = 1,
CurrencyID = "currencyId",
CustomerID = "customerId",
IdempotencyKey = "x",
CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
Dimensions = new Dictionary<string, ConsumptionConsumeAsyncParamsConsumptionDimension>(
)
{
{ "foo", "string" }
},
ResourceID = "resourceId",
},
],
};
var response = await client.V1.Credits.Consumption.ConsumeAsync(parameters);
Console.WriteLine(response);stigg v1:credits:consumption consume-async \
--api-key 'My API Key' \
--consumption '{amount: 1, currencyId: currencyId, customerId: customerId, idempotencyKey: x}'curl --request POST \
--url https://api.stigg.io/api/v1/credits/consumption/async \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"consumptions": [
{
"customerId": "<string>",
"currencyId": "<string>",
"amount": 1,
"idempotencyKey": "<string>",
"resourceId": "<string>",
"dimensions": {},
"createdAt": "2023-11-07T05:31:56Z"
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v1/credits/consumption/async",
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([
'consumptions' => [
[
'customerId' => '<string>',
'currencyId' => '<string>',
'amount' => 1,
'idempotencyKey' => '<string>',
'resourceId' => '<string>',
'dimensions' => [
],
'createdAt' => '2023-11-07T05:31:56Z'
]
]
]),
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": {}
}{
"message": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Consume credits asynchronously
Consumes credits directly from customer wallets asynchronously. Consumptions are reconciled asynchronously into the credit balances.
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.credits.consumption.consumeAsync({
consumptions: [
{
amount: 1,
currencyId: 'currencyId',
customerId: 'customerId',
idempotencyKey: 'x',
},
],
});
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.credits.consumption.consume_async(
consumptions=[{
"amount": 1,
"currency_id": "currencyId",
"customer_id": "customerId",
"idempotency_key": "x",
}],
)
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.Credits.Consumption.ConsumeAsync(context.TODO(), stigg.V1CreditConsumptionConsumeAsyncParams{
Consumptions: []stigg.V1CreditConsumptionConsumeAsyncParamsConsumption{{
Amount: 1,
CurrencyID: "currencyId",
CustomerID: "customerId",
IdempotencyKey: "x",
}},
})
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.credits.consumption.ConsumptionConsumeAsyncParams;
import io.stigg.models.v1.credits.consumption.ConsumptionConsumeAsyncResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
ConsumptionConsumeAsyncParams params = ConsumptionConsumeAsyncParams.builder()
.addConsumption(ConsumptionConsumeAsyncParams.Consumption.builder()
.amount(1.0)
.currencyId("currencyId")
.customerId("customerId")
.idempotencyKey("x")
.build())
.build();
ConsumptionConsumeAsyncResponse response = client.v1().credits().consumption().consumeAsync(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v1.credits.consumption.consume_async(
consumptions: [{amount: 1, currencyId: "currencyId", customerId: "customerId", idempotencyKey: "x"}]
)
puts(response)using System;
using System.Collections.Generic;
using Stigg.Client;
using Stigg.Client.Models.V1.Credits.Consumption;
StiggClient client = new();
ConsumptionConsumeAsyncParams parameters = new()
{
Consumptions =
[
new()
{
Amount = 1,
CurrencyID = "currencyId",
CustomerID = "customerId",
IdempotencyKey = "x",
CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
Dimensions = new Dictionary<string, ConsumptionConsumeAsyncParamsConsumptionDimension>(
)
{
{ "foo", "string" }
},
ResourceID = "resourceId",
},
],
};
var response = await client.V1.Credits.Consumption.ConsumeAsync(parameters);
Console.WriteLine(response);stigg v1:credits:consumption consume-async \
--api-key 'My API Key' \
--consumption '{amount: 1, currencyId: currencyId, customerId: customerId, idempotencyKey: x}'curl --request POST \
--url https://api.stigg.io/api/v1/credits/consumption/async \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"consumptions": [
{
"customerId": "<string>",
"currencyId": "<string>",
"amount": 1,
"idempotencyKey": "<string>",
"resourceId": "<string>",
"dimensions": {},
"createdAt": "2023-11-07T05:31:56Z"
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v1/credits/consumption/async",
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([
'consumptions' => [
[
'customerId' => '<string>',
'currencyId' => '<string>',
'amount' => 1,
'idempotencyKey' => '<string>',
'resourceId' => '<string>',
'dimensions' => [
],
'createdAt' => '2023-11-07T05:31:56Z'
]
]
]),
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": {}
}{
"message": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Authorizations
Server API Key
Headers
Account ID — optional when authenticating with a user JWT (Bearer token); falls back to the user's first membership. Ignored for API-key auth.
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
Request body for consuming credits directly from wallets asynchronously
The credit consumptions to report (up to 1000)
1 - 1000 elementsShow child attributes
Show child attributes
Response
Confirmation that the credit consumptions were accepted for processing.
Response object
Confirmation that the credit consumptions were accepted for processing
Related topics
Consume creditsUsage, billing & creditsCustomer creditsAdjust credit balancePython SDK