TryItOn
API Reference

Get Credits Balance

Check your virtual try-on API credit balance with GET /credits: subscription, purchased and reserved credits, and how to work out what you can spend.

The credits endpoint returns your virtual try-on API credit balance. It's one balance per account, shared by the TryItOn app, browser extension, mobile app, storefront widget and the API, so try-ons made anywhere on the account draw from it. Call it before a batch of submits, or to show a balance in your own dashboard.

GET https://tryiton.now/api/v1/credits

Prices, plans and how holds work are on Virtual Try-On API Pricing & Credits.

Request

Each SDK example reads the balance and prints the credits you can spend right now. See SDKs to install one.

import { TryItOn } from "tryiton";

const client = new TryItOn({ apiKey: process.env.TRYITON_API_KEY });

const credits = await client.getCredits();
const spendable = credits.subscription + credits.purchased - credits.reserved;
console.log(credits, spendable);
import os

from tryiton import TryItOn

client = TryItOn(api_key=os.environ["TRYITON_API_KEY"])

credits = client.get_credits()
spendable = credits.subscription + credits.purchased - credits.reserved
print(credits, spendable)
package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"time"

	tryiton "github.com/tryiton-now/tryiton-go/v2"
)

func main() {
	client, err := tryiton.New(os.Getenv("TRYITON_API_KEY"))
	if err != nil {
		log.Fatal(err)
	}

	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
	defer cancel()

	credits, err := client.GetCredits(ctx)
	if err != nil {
		log.Fatal(err)
	}
	spendable := credits.Subscription + credits.Purchased - credits.Reserved
	fmt.Printf("%+v %d\n", *credits, spendable)
}
<?php
require 'vendor/autoload.php';

use TryItOn\Client;

$client = new Client(getenv('TRYITON_API_KEY'));

$credits = $client->getCredits();
$spendable = $credits['subscription'] + $credits['purchased'] - $credits['reserved'];
print_r($credits);
echo $spendable, PHP_EOL;
require "tryiton"

client = Tryiton::Client.new(api_key: ENV.fetch("TRYITON_API_KEY"))

credits = client.get_credits
spendable = credits["subscription"] + credits["purchased"] - credits["reserved"]
puts credits, spendable
curl https://tryiton.now/api/v1/credits \
     -H "Authorization: Bearer YOUR_API_KEY"

Response fields

FieldTypeDescription
credits.subscriptionintegerCredits left from your plan's allowance. The allowance is reset to your plan's amount each credit period and doesn't roll over.
credits.purchasedintegerCredits from packs you bought. They don't expire, and refunds land here.
credits.reservedintegerCredits held by work in progress: running photo try-ons and live sessions. A hold becomes a charge when the work finishes, or is released if it fails.
credits.on_demandintegersubscription + purchased + reserved. It includes held credits, so it isn't what you can spend.

Don't use on_demand as your spendable balance. Credits you can spend right now are subscription + purchased − reserved. That's the number the try-on endpoints check before they accept a job.

200 OK
{
  "ok": true,
  "credits": {
    "on_demand": 151,
    "subscription": 50,
    "purchased": 100,
    "reserved": 1
  }
}

In this example on_demand is 50 + 100 + 1 = 151, and you can spend 50 + 100 − 1 = 149 credits. A num_samples: 4 try-on needs 4 spendable credits.

Errors

Errors use the standard envelope { "ok": false, "error": { "name": "...", "message": "..." } }. See Error Codes & Handling.

Statuserror.nameWhen
403ForbiddenThe Authorization header is missing or malformed, or the API key is invalid.
429RateLimitExceededMore than 300 requests a minute from your IP.
500InternalServerErrorSomething went wrong on our side. Retry after a short wait.

Notes

  • Shared balance. Try-ons in the TryItOn app, extension, mobile app and storefront widget spend the same credits as your API calls, so the balance can change between two of your requests.
  • Holds and concurrency. New try-ons and live sessions are refused with 429 ConcurrencyLimitExceeded while reserved is 5 or more. See Rate Limits & Concurrency.
  • Buying credits. Packs and subscriptions are at tryiton.now/app/billing.

On this page