Create a spend limit
Sets a limit for a product and period that has none. Send exactly one of amount and unlimited: true. The period’s spend is checked at once: if it is already above the new limit, the product is blocked immediately (evaluation.blocked_now). Returns 409 when a limit already exists for the product and period; update it instead. With credential_id, the limit applies to that API key only: it needs an amount, and the period’s API key limits cannot add up to more than the total limit when the total has an amount.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const SpendLimit = await client.spendLimits.create();
console.log(SpendLimit.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
spend_limit = client.spend_limits.create()
print(spend_limit.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
spendLimit, err := client.SpendLimits.New(
context.TODO(),
telnyx.SpendLimitNewParams{
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", spendLimit.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.spendLimits.SpendLimitCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
SpendLimitCreateParams params = SpendLimitCreateParams.builder()
.build();
var response = client.spendLimits().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
spend_limit = telnyx.spend_limits.create
puts(spend_limit)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$spend_limit = $client->spendLimits->create();
var_dump($spend_limit);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx spend-limits create \
--api-key 'My API Key'curl --request POST \
--url https://api.telnyx.com/v2/spend_limits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"product": "inference",
"period": "daily",
"amount": 100,
"reason": "Team budget"
}
'{
"data": {
"record_type": "spend_limit",
"product": "inference",
"product_name": "Inference",
"period": "daily",
"period_start": "2026-09-24",
"period_end": "2026-09-25",
"limit": {
"amount": "100",
"unlimited": false,
"origin": "self_service",
"updated_at": "2026-09-24T09:12:03.412Z"
},
"effective_limit_usd": "100",
"spend_usd": "37.41",
"spend_error": null,
"blocked": false,
"block": null,
"evaluation": {
"spend_usd": "37.41",
"released": false,
"blocked_now": false,
"still_over_limit": false,
"still_blocked_other_period": false,
"evaluation_deferred": false
}
}
}Authorizations
Body
- Amount
- Unlimited
Send exactly one of amount and unlimited: true.
Optional. Identifier of one API key as recorded on usage, never the key's secret: the limit then applies to that key only. Absent or null sets the total limit. A blank value, or one with control characters, is refused; it never means the total limit. An API key limit always has an amount.
1 - 255"KEY0192F3A1B2C3D4E5F6A7B8C9D0E1F2"
Response
The limit was created. evaluation says whether the change blocked the product.
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const SpendLimit = await client.spendLimits.create();
console.log(SpendLimit.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
spend_limit = client.spend_limits.create()
print(spend_limit.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
spendLimit, err := client.SpendLimits.New(
context.TODO(),
telnyx.SpendLimitNewParams{
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", spendLimit.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.spendLimits.SpendLimitCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
SpendLimitCreateParams params = SpendLimitCreateParams.builder()
.build();
var response = client.spendLimits().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
spend_limit = telnyx.spend_limits.create
puts(spend_limit)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$spend_limit = $client->spendLimits->create();
var_dump($spend_limit);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx spend-limits create \
--api-key 'My API Key'curl --request POST \
--url https://api.telnyx.com/v2/spend_limits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"product": "inference",
"period": "daily",
"amount": 100,
"reason": "Team budget"
}
'{
"data": {
"record_type": "spend_limit",
"product": "inference",
"product_name": "Inference",
"period": "daily",
"period_start": "2026-09-24",
"period_end": "2026-09-25",
"limit": {
"amount": "100",
"unlimited": false,
"origin": "self_service",
"updated_at": "2026-09-24T09:12:03.412Z"
},
"effective_limit_usd": "100",
"spend_usd": "37.41",
"spend_error": null,
"blocked": false,
"block": null,
"evaluation": {
"spend_usd": "37.41",
"released": false,
"blocked_now": false,
"still_over_limit": false,
"still_blocked_other_period": false,
"evaluation_deferred": false
}
}
}