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.credits.consumption.consume({
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(
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.Consume(context.TODO(), stigg.V1CreditConsumptionConsumeParams{
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.ConsumptionConsumeParams;
import io.stigg.models.v1.credits.consumption.ConsumptionConsumeResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
ConsumptionConsumeParams params = ConsumptionConsumeParams.builder()
.amount(1.0)
.currencyId("currencyId")
.customerId("customerId")
.idempotencyKey("x")
.build();
ConsumptionConsumeResponse response = client.v1().credits().consumption().consume(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v1.credits.consumption.consume(
amount: 1,
currency_id: "currencyId",
customer_id: "customerId",
idempotency_key: "x"
)
puts(response)using System;
using Stigg.Client;
using Stigg.Client.Models.V1.Credits.Consumption;
StiggClient client = new();
ConsumptionConsumeParams parameters = new()
{
Amount = 1,
CurrencyID = "currencyId",
CustomerID = "customerId",
IdempotencyKey = "x",
};
var response = await client.V1.Credits.Consumption.Consume(parameters);
Console.WriteLine(response);stigg v1:credits:consumption consume \
--api-key 'My API Key' \
--amount 1 \
--currency-id currencyId \
--customer-id customerId \
--idempotency-key xcurl --request POST \
--url https://api.stigg.io/api/v1/credits/consumption \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"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",
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([
'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": {
"customerId": "customer-123",
"currencyId": "credits",
"resourceId": null,
"amount": 10,
"timestamp": "2024-01-01T00:00:00.000Z",
"credit": {
"currencyId": "credits",
"currentUsage": 10,
"usageLimit": 1000,
"timestamp": "2024-01-01T00:00:00.000Z",
"usagePeriodEnd": null
}
}
}{
"message": "<string>",
"code": "BadUserInput",
"reason": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>",
"code": "IdentityForbidden"
}{
"message": "<string>",
"code": "CustomerNotFound"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Credit consumption
Consume credits
Consumes a specified amount of credits directly from a customer wallet, with no feature mapping. Returns the optimistic balance.
POST
/
api
/
v1
/
credits
/
consumption
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.credits.consumption.consume({
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(
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.Consume(context.TODO(), stigg.V1CreditConsumptionConsumeParams{
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.ConsumptionConsumeParams;
import io.stigg.models.v1.credits.consumption.ConsumptionConsumeResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
ConsumptionConsumeParams params = ConsumptionConsumeParams.builder()
.amount(1.0)
.currencyId("currencyId")
.customerId("customerId")
.idempotencyKey("x")
.build();
ConsumptionConsumeResponse response = client.v1().credits().consumption().consume(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v1.credits.consumption.consume(
amount: 1,
currency_id: "currencyId",
customer_id: "customerId",
idempotency_key: "x"
)
puts(response)using System;
using Stigg.Client;
using Stigg.Client.Models.V1.Credits.Consumption;
StiggClient client = new();
ConsumptionConsumeParams parameters = new()
{
Amount = 1,
CurrencyID = "currencyId",
CustomerID = "customerId",
IdempotencyKey = "x",
};
var response = await client.V1.Credits.Consumption.Consume(parameters);
Console.WriteLine(response);stigg v1:credits:consumption consume \
--api-key 'My API Key' \
--amount 1 \
--currency-id currencyId \
--customer-id customerId \
--idempotency-key xcurl --request POST \
--url https://api.stigg.io/api/v1/credits/consumption \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"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",
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([
'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": {
"customerId": "customer-123",
"currencyId": "credits",
"resourceId": null,
"amount": 10,
"timestamp": "2024-01-01T00:00:00.000Z",
"credit": {
"currencyId": "credits",
"currentUsage": 10,
"usageLimit": 1000,
"timestamp": "2024-01-01T00:00:00.000Z",
"usagePeriodEnd": null
}
}
}{
"message": "<string>",
"code": "BadUserInput",
"reason": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>",
"code": "IdentityForbidden"
}{
"message": "<string>",
"code": "CustomerNotFound"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Headers
Body
application/json
Request body for consuming credits directly from a wallet