How to add per-minute paid video consultations to an astrology app

Calls themselves need no backend: your App Key is enough to start and join them. Money is different. Keep the user’s wallet and each astrologer’s per-minute price in your own backend, let your server create every call with a time cap worked out from the wallet, and debit the user only from the signed receipt that arrives when the call ends. Titli bills you, the app, per participant-minute: a 12-minute video consult costs ₹4.80 at the list price.

Why this guide uses a server. A free or flat-fee call needs only the App Key in the app (see the Flutter guide). A per-minute paid consult is different: the app should not be trusted to debit its own user’s wallet, because a modified app could skip the debit. So here the wallet, the call cap and the settlement run on your server with the project key. Think of it as production hardening that a paid wallet needs, not as a requirement for making calls.

The money model: three prices and two balances

A consultation app such as an astrology app has three prices in play, and it helps to name them before writing any code.

PriceWho sets itWho pays whomWhere it is stored
The astrologer’s price per minuteYou, or the astrologer inside limits you allowThe user pays your appYour database
The astrologer’s shareYouYour app pays the astrologerYour database
The call minutes: ₹0.20 video, ₹0.05 audio per participant-minuteTitli’s price listYour app pays Titli from a prepaid balanceYour Titli account

The first two are entirely yours. Titli sees none of that money: it meters the call on its media servers and debits your prepaid balance, per second, only while at least two people are connected. A participant-minute is one person connected for one minute, so a 1:1 call uses two of them for every minute on the clock.

The arithmetic for a 12-minute consult

Say your app charges the user ₹30 a minute for video and ₹15 a minute for audio. These two numbers are an example; you choose your own.

Video consultAudio consult
Length12 minutes12 minutes
Your price to the user (example)₹30 a minute₹15 a minute
The user pays you12 × ₹30 = ₹36012 × ₹15 = ₹180
Participant-minutes2 × 12 = 242 × 12 = 24
Titli bills you (INR account)24 × ₹0.20 = ₹4.8024 × ₹0.05 = ₹1.20
Titli bills you (USD account)24 × $0.0023 = $0.055224 × $0.00057 = $0.01368
Left for the astrologer and you₹355.20₹178.80

In this example the call minutes are about 1.3% of what the user pays on video. Payment gateway charges and taxes on your own sales are separate and not shown here. The full price list, with a calculator, is on the pricing page.

The call flow, step by step

  1. Your appThe user taps Call on an astrologerFor a paid consult the app asks your backend instead of starting the call with the App Key, so the cap comes from a wallet the user cannot edit. The project key stays on your server.
  2. Your serverCheck the walletRead the user’s balance and the astrologer’s price from your own database. Refuse politely if the balance is below your minimum.
  3. Your server → TitliRun the pre-call checkGET /v1/end-users/{end_user_id} returns the user’s free seconds and whether a call can start on your account.
  4. Your server → TitliCreate the call with a cap, mint two tokensPOST /v1/calls with max_duration_seconds, then POST /v1/calls/{call_id}/tokens once for the user and once for the astrologer.
  5. Both appsJoinEach app joins with its own token. Billing starts when the second person connects, not while one person waits.
  6. Your appWarn before the money runs outThe app knows the cap, so it can show a countdown and a recharge button with a minute to go.
  7. Titli or your serverThe call endsSomeone hangs up, the cap is reached, or your backend calls POST /v1/calls/{call_id}/end.
  8. Titli → your serverSettle from the receiptThe call.ended webhook carries the signed receipt. Debit the user and credit the astrologer from its connected seconds.

Check the balance and compute the cap

Two checks run before a call, against two different balances. The first is yours: can this wallet pay for at least your minimum consult? The second is Titli’s pre-call check, which is read-only and answers a different question: does this user have free seconds left, and can a call start on your account right now?

End-user check reply
{
  "end_user_id": "user_1001",
  "is_new": true,
  "first_time_free_seconds_left": 60,
  "daily_free_seconds_left": 0,
  "free_seconds_available": 60,
  "day": "2026-11-28",
  "vendor_balance": 1520.4512,
  "can_start_call": true
}

can_start_call is about your prepaid Titli balance and the user’s free seconds. It knows nothing about the user’s wallet in your app. If it is false, the fix is on your side (recharge your account), so alert your team instead of asking the user to pay.

Now turn the wallet into time. With a wallet of ₹200 and a video price of ₹30 a minute, the user can afford 200 × 60 ÷ 30 = 400 seconds, which is 6 minutes 40 seconds. That number goes into max_duration_seconds (allowed range: 10 to 86400), and the server ends the call when that much connected time has passed.

consult-start.js
// consult-start.js (Node 20+). Runs on YOUR server when a user taps "Call" on an astrologer.
const API = 'https://api-videosdk.titliapp.com';
const AUTH = 'Basic ' + Buffer.from(`${process.env.TITLI_KEY_ID}:${process.env.TITLI_KEY_SECRET}`).toString('base64');
export const titli = async (method, path, body) => {
  const r = await fetch(API + path, { method, headers: { Authorization: AUTH, 'Content-Type': 'application/json' }, body: body && JSON.stringify(body) });
  const j = await r.json();
  if (!r.ok) throw Object.assign(new Error(j.error?.code || String(r.status)), { status: r.status });
  return j;
};

export async function startConsult(user, astrologer, type) { // type: 'video' | 'audio'
  // 1. YOUR wallet and YOUR price. Money is kept in paise (integers), never in floats.
  const pricePaise = type === 'video' ? astrologer.videoPricePaise : astrologer.audioPricePaise; // per minute
  const walletPaise = await db.walletBalance(user.id);

  // 2. Titli pre-call check: free seconds left for this user, and can a call start on your account?
  const eu = await titli('GET', `/v1/end-users/${user.id}`);
  if (!eu.can_start_call) throw new Error('calls_unavailable'); // your own Titli balance is empty: alert your team

  // 3. Seconds the wallet pays for, plus the free seconds of your first-call offer (0 if you give none).
  const paidSeconds = Math.floor((walletPaise * 60) / pricePaise);
  const maxSeconds = Math.min(paidSeconds + eu.free_seconds_available, 3600); // your own ceiling: 60 minutes
  if (maxSeconds < 60) throw new Error('recharge_needed'); // your rule: at least one minute

  // 4. Create the call with the cap, remember it, then mint one token per person.
  const call = await titli('POST', '/v1/calls', { type, payer_end_user_id: user.id, max_duration_seconds: maxSeconds });
  await db.consults.insert({ callId: call.id, userId: user.id, astrologerId: astrologer.id, type, pricePaise, maxSeconds, status: 'created' });
  const mine = await titli('POST', `/v1/calls/${call.id}/tokens`, { end_user_id: user.id, role: 'user', name: user.displayName });
  const theirs = await titli('POST', `/v1/calls/${call.id}/tokens`, { end_user_id: astrologer.id, role: 'host', name: astrologer.displayName });
  await notifyAstrologer(astrologer.id, { callId: call.id, url: theirs.livekit_url, token: theirs.token }); // your push or socket
  return { callId: call.id, url: mine.livekit_url, token: mine.token, maxSeconds };
}

Use a stable, pseudonymous id as end_user_id (1 to 128 characters of letters, digits and _ . : @ -), not a phone number. Tokens expire after 10 minutes by default, which limits when a person can join, not how long they can talk. The client side is the same as any other call: see the quickstart or the Flutter guide.

Hard cap or server timer?

The cap is fixed when the call is created; the REST reference has no request that changes it later. That gives you two designs, and the choice depends on whether users may top up in the middle of a consult.

Hard cap (simplest)Server timer with a safety cap
Value of max_duration_secondsExactly what the wallet pays forYour longest allowed consult, for example 3600
Who ends the call when money runs outTitli’s server, on its ownYour backend, with POST /v1/calls/{call_id}/end
Top-up during the callDoes not extend this call; the user calls againYour timer moves forward
If your server is down at the wrong momentNothing can overrunThe call can run to the safety cap, and you absorb the difference

Start with the hard cap. Move to a server timer only when mid-call recharges matter enough to justify the extra moving part.

Warn the user before the money runs out

Your backend returned the cap along with the token, so the app can count down without asking anyone. In Flutter, TitliCall exposes duration, the time since the other person joined:

lib/consult_screen.dart
import 'package:titli_video_sdk/titli_video_sdk.dart';

// token, livekitUrl and maxSeconds all came from YOUR backend (startConsult above).
final call = await TitliCall.connect(url: livekitUrl, token: token, video: true);

var warned = false;
call.duration.addListener(() {
  // duration = time since the other person joined. It is for display only: the bill comes from the server.
  final left = maxSeconds - call.duration.value.inSeconds;
  if (left <= 60 && !warned) {
    warned = true;
    showLowBalanceBanner(secondsLeft: left, onRecharge: openWallet); // your own widgets
  }
});

The countdown is a courtesy, not the meter. The bill and the cut-off both come from the server, so a user who changes the clock on the phone gains nothing. Do not confuse this in-app warning with the balance.low webhook: that event is about your prepaid Titli balance falling below your alert level, and it goes to your backend, not to users.

End the call from your server

Any end that matters for money should be something your backend can do by itself, without trusting either phone.

consult-end.js
// Your server decides the consult is over: the wallet is spent, the astrologer went offline, an admin stepped in.
await titli('POST', `/v1/calls/${callId}/end`); // ends it for everyone; safe to call twice

// Or take one person out and leave the call open for up to 30 seconds:
await titli('POST', `/v1/calls/${callId}/participants/${userId}/remove`);

When the cap is reached the ended call has end_reason: "max_duration"; when your backend ends it, ended_by_vendor; when both people simply leave, completed. In all three cases the app’s SDK reports that the call ended and the receipt is issued. If everyone drops, the call stays open for 30 seconds, so a quick reconnect continues the same consult, and nothing is billed while fewer than two people are connected.

Settle from the call-ended webhook and the signed receipt

This is the rule that keeps your books honest: no money moves in your ledger until the server-side record arrives. The call.ended webhook delivers the call, its receipt and the receipt’s signature in one request.

Receipt inside the call-ended webhook (abridged)
{
  "call_id": "6a1f…", "type": "video", "billing_mode": "participant_minute", "rate_per_minute": 0.2, "currency": "INR",
  "payer_end_user_id": "user_1001", "connected_at": "…", "ended_at": "…", "end_reason": "max_duration",
  "connected_seconds": 720, "participant_seconds": 1440, "free_seconds": 60,
  "billed_minutes": 22.0, "amount": 4.4,
  "participants": [ { "end_user_id": "user_1001", "role": "user", "joined_at": "…", "left_at": "…",
                      "billable_seconds": 720, "free_seconds": 60, "amount": 2.2 } ]
}

Charge the user for connected_seconds minus free_seconds, at the price you stored when the consult was created. Verify the webhook signature first and dedupe on the event id, as shown in Webhooks and signed receipts and the webhooks reference.

settle.js
// settle.js: run this from your webhook receiver, after the signature check, for the "call.ended" event.
export async function onCallEnded(ev) {
  const { call, receipt, receipt_signature } = ev.data;
  const consult = await db.consults.findByCallId(call.id);
  if (!consult || consult.status === 'settled') return; // every call is settled exactly once

  // Seconds two people were really connected, minus the free seconds of your first-call offer.
  const chargeable = Math.max(0, receipt.connected_seconds - receipt.free_seconds);
  const owed = Math.ceil((chargeable * consult.pricePaise) / 60);       // your rounding rule, applied once
  const userPaise = Math.min(owed, await db.walletBalance(consult.userId)); // a wallet never goes below zero
  const astrologerPaise = Math.floor((userPaise * consult.astrologerSharePct) / 100); // your own split

  await db.transaction(async (tx) => {
    // The unique key makes a retried webhook a no-op instead of a second debit.
    await tx.ledger.insert({ key: `consult:${call.id}:debit`, account: `wallet:${consult.userId}`, paise: -userPaise });
    await tx.ledger.insert({ key: `consult:${call.id}:credit`, account: `earnings:${consult.astrologerId}`, paise: astrologerPaise });
    await tx.consults.update(call.id, {
      status: 'settled', seconds: chargeable, endReason: call.end_reason,
      receipt, receiptSignature: receipt_signature, // keep both for disputes
    });
  });
}

Webhooks are retried after 10 seconds, 1 minute, 5 minutes and 30 minutes, and can arrive more than once. The unique ledger keys above make a repeat harmless. For the rare case where no delivery succeeds, run a job that fetches GET /v1/calls/{call_id}/receipt for consults that are still open after an hour. The ledger itself is covered in depth in Designing a user wallet for per-minute calls.

Free first-minute offers

“First minute free” is the most common offer in consultation apps, and there are two ways to fund it.

  • With Titli free seconds. Free seconds per end user are an account setting, off by default: a first-time allowance (used once, the first time a user is seen) and a daily allowance. They belong to the call’s payer and cover the whole call while they last, so you are not billed for those seconds. The receipt reports them as free_seconds.
  • With your own promotion. You simply do not charge the user for the first 60 seconds. Titli still bills you for them, because nothing on the account says otherwise.

Worked through with 60 free seconds on a 12-minute video consult: Titli bills 2 × (720 − 60) ÷ 60 = 22 participant-minutes, so 22 × ₹0.20 = ₹4.40 instead of ₹4.80. Your user pays for 11 minutes: 11 × ₹30 = ₹330. Whether the astrologer is paid for the free minute is your decision; most apps treat it as a marketing cost.

Disputes and refunds

Every dispute in a per-minute app is a question about time: “I was charged for 12 minutes but we spoke for 8.” Store three things with each consult and you can answer it in a minute.

  • The receipt and its signature. The signature is Ed25519 over the canonical JSON of the receipt. Anyone can check it with the public key from GET /v1/receipts/public-key, so it shows that the record was not edited after the call.
  • The participant times. The receipt lists each person’s join and leave time and billable seconds. If the astrologer never joined, the call never connected: connected seconds are zero and there is nothing to charge.
  • The price snapshot. Keep the per-minute price on the consult row. An astrologer who raises the price tomorrow must not change yesterday’s bill.
verify-receipt.js
import crypto from 'node:crypto';
const canonical = (v) => Array.isArray(v) ? '[' + v.map(canonical).join(',') + ']'
  : v && typeof v === 'object' ? '{' + Object.keys(v).sort().map((k) => JSON.stringify(k) + ':' + canonical(v[k])).join(',') + '}'
  : JSON.stringify(v);
const ok = crypto.verify(null, Buffer.from(canonical(receipt)), crypto.createPublicKey(publicKeyPem), Buffer.from(signature, 'base64'));

A refund to your user is a decision and a ledger entry on your side. The receipt stays the record of what was actually connected.

What Titli does not do

  • No payment collection from your users. There is no user wallet, payment gateway or astrologer payout in the API. Those stay in your system by design.
  • No recording. Calls are not recorded or stored. If your product needs consult recordings, this is not the right API for it.
  • No phone-number calling. Calls are app to app over the internet, on video (up to 720p) or audio.
  • No certifications or uptime SLA today. The security page lists what exists and what does not.
  • Limits to plan for. A new account runs 5 calls at the same time until support raises it, and your Titli balance is recharged by UPI or bank transfer in INR (USD accounts: USDT or bank wire), not by card.

Frequently asked questions

Do I need a backend for astrology video calls?

Not to make calls: with your App Key the app can start and join calls with no backend. A paid per-minute wallet is the reason to add one. The app should not be trusted to debit its own user’s wallet, so the wallet check, the time cap and the settlement belong on a server you control. That is production hardening, and the right default for any app that takes money.

Which video call API suits an astrology app with per-minute billing?

One that meters on its own servers, lets your backend cap each call, and gives you a signed record when the call ends. With Titli Video SDK your server sets a time cap on POST /v1/calls, and the call.ended webhook carries an Ed25519-signed receipt with the connected seconds. Video is ₹0.20 and audio ₹0.05 per participant-minute, billed per second.

What does a 12-minute video consultation cost the app?

Two people for 12 minutes is 24 participant-minutes. At the list price that is 24 × ₹0.20 = ₹4.80 for video ($0.0552 on a USD account) and 24 × ₹0.05 = ₹1.20 for audio ($0.01368). What you charge your user is your own price and is not part of this bill.

Does Titli deduct money from my user’s wallet?

No. The wallet, the payment gateway, the astrologer’s price and the astrologer’s payout all live in your system. Titli meters call minutes and debits your own prepaid account balance. It never collects money from your users and never pays your astrologers.

How do I end a consultation when the user runs out of balance?

Either set max_duration_seconds when you create the call, so the server ends it at that many connected seconds, or keep your own timer and call POST /v1/calls/{call_id}/end from your backend. Both end the call for everyone and produce the receipt.

Can I offer new users a free first minute?

Yes. Free seconds per end user are an account setting: a first-time allowance and a daily allowance. While they last, the call is not billed to you, and the receipt reports them as free_seconds so you can leave them out of the user’s charge too.

Are astrology consultations recorded?

No. Titli has no cloud recording. Audio and video pass through the media servers in real time and are not stored, so a call cannot be replayed later by you or by us.

Next steps

Free SDK. Pay only for the minutes you use.

Create a free account: it starts with ₹100 welcome credit, about 250 minutes of 1:1 video, so your first call needs no recharge. Questions? Message us on WhatsApp and a person replies.

Start free