POST /api/v1/ask

Grounded business-intelligence Q&A — ask a plain-English question and get an answer backed by real sales, stock, and margin data. Free within your plan quota; no wallet debit.

POSTFree within plan quotax-api-key required

What it does

Sends a plain-English business question to the same AI answer engine that powers the AskBiz app’s chat interface, and gets back a structured, grounded answer — not just prose, but a verdict, KPI cards, an optional chart or table, and concrete recommendations. Unlike /scan and /whatsapp/send, this endpoint is not credit-billed — it’s free within your plan’s monthly and per-minute quota, with no wallet debit either way.

Account mode vs. generic mode context

How the answer gets grounded depends on your key’s mode. An account-mode key is tied to a real AskBiz business — for those keys, the endpoint automatically pulls the caller’s own AskBiz profile (business type, currency, region) and the columns from their latest uploaded dataset to ground the answer. Any context you send is ignored for account-mode keys, since there’s already a real account to read from.

A generic-mode key has no AskBiz account behind it, so there’s nothing to read automatically — you must supply context yourself for the answer to be grounded in anything beyond the question text. See Ask business-intelligence questions for a full walkthrough of both modes.

Request

Account-mode key — no context needed, the answer is grounded in the caller’s own connected data:

curl -X POST https://askbiz.co/api/v1/ask \
  -H "x-api-key: abz_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "Which of my products had the worst margin last month?"
  }'

Generic-mode key — context supplied explicitly since there’s no account to read from:

curl -X POST https://askbiz.co/api/v1/ask \
  -H "x-api-key: abz_generic_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "Is a 22% gross margin healthy for this business?",
    "context": {
      "currency": "KES",
      "symbol": "KSh",
      "biz_type": "retail",
      "region": "Nairobi, Kenya",
      "revenue": 480000,
      "margin": 22,
      "top_products": ["Cooking oil 2L", "Maize flour 2kg", "Sugar 1kg"]
    }
  }'

Body parameters

FieldTypeRequiredDescription
questionstringYesMax 2000 characters.
contextobjectNoIgnored for account-mode keys. For generic-mode keys, the only source of grounding data — see fields below.
optionsobjectNo{ cfo_mode?: boolean, simulate_mode?: boolean }.

context object fields

FieldTypeDescription
currencystringe.g. "KES".
symbolstringe.g. "KSh".
biz_typestringOne of retail, ecommerce, distributor, exporter.
regionstringFree text, e.g. "Nairobi, Kenya".
revenuenumberRecent period revenue, in the given currency’s minor or major unit as you define it.
marginnumberGross margin as a percentage.
top_productsstring[]Names of the business’s top products.
sectorstringFree text.
(any other key)anycontext accepts free-form additional key/value pairs beyond the fields above.

Response

200 — every successful call returns the same shape, whether the key is account-mode or generic-mode:

{
  "answer": "Fanta Orange 300ml had the worst margin last month at 11%, well below your 34% average. You sold 210 units at that margin, which cost you roughly KSh 9,800 in foregone profit compared to your average line.",
  "insight_header": "Fanta Orange 300ml is dragging your margin down",
  "verdict": "watch",
  "verdict_sentence": "One low-margin product is quietly eating into an otherwise healthy month.",
  "confidence": "high",
  "kpi_cards": [
    { "label": "Worst margin product", "value": "Fanta Orange 300ml" },
    { "label": "Margin", "value": "11%" }
  ],
  "chart": {
    "type": "bar",
    "labels": ["Fanta Orange 300ml", "Coca-Cola 500ml", "Sprite 500ml"],
    "values": [11, 34, 29],
    "label": "Margin %"
  },
  "table": null,
  "recommendations": [
    "Reprice Fanta Orange 300ml or renegotiate your supplier cost — it's the only line below 20% margin.",
    "Check whether the low margin is a pricing mistake or a deliberate loss-leader."
  ],
  "follow_up_questions": [
    "What was my average margin across all products last month?",
    "How much would repricing this item to 25% margin add to my monthly profit?"
  ],
  "meta": {
    "model": "askbiz-v1",
    "latency_ms": 1840,
    "requests_remaining": 87
  }
}

Response fields

FieldTypeDescription
answerstringPlain-English answer.
insight_headerstring | nullShort one-line summary of the finding, if the model produced one.
verdict'act' | 'watch' | 'problem' | nullAt-a-glance severity for dashboards or alerting.
verdict_sentencestring | nullOne-sentence explanation of the verdict.
confidence'high' | 'medium' | 'low'How well-grounded the answer is in the data actually available.
kpi_cardsobject[]Small label/value pairs suitable for rendering as stat tiles.
chartobject | null{ type, labels, values, label } when the answer is well suited to a chart, otherwise null.
tableobject | null{ headers, rows } when the answer is well suited to a table, otherwise null.
recommendationsstring[]Concrete next actions.
follow_up_questionsstring[]Suggested next questions to ask.
meta.modelstringAlways "askbiz-v1".
meta.latency_msnumberServer-side processing time.
meta.requests_remainingnumber | 'unlimited'Calls left in the current period under your plan’s monthly quota.

Errors

StatusMeaning
400Invalid JSON body, missing question, or question over 2000 characters.
401Missing or invalid x-api-key.
403Key is disabled — re-enable it from your dashboard settings.
429Monthly quota or per-minute rate limit exceeded.
500The underlying AI request failed — safe to retry.

Unlike /scan and /whatsapp/send, this endpoint does not accept an Idempotency-Key header. Every call is treated as independent — retrying a 500 is safe since nothing is billed, but there’s no dedupe against a repeated request. It does return X-RateLimit-Limit / X-RateLimit-Remaining response headers, same as every other endpoint. See Errors and retries for the full contract across endpoints that support idempotency.

Ask endpoint FAQ

Does calling /api/v1/ask cost anything?+

No. It’s free within your plan’s monthly and per-minute quota — there’s no per-call price and no wallet debit, unlike /scan (3¢) or /whatsapp/send (2¢).

Do I need to send context if I’m using an account-mode key?+

No — account-mode keys automatically pull the caller’s own AskBiz profile and latest dataset columns. Any context you send is ignored for account-mode keys.

What happens if I don’t send context with a generic-mode key?+

The question is still answered, but with nothing to ground it in beyond the question text itself — expect lower-confidence, more generic answers. Generic-mode keys have no connected account to read from automatically.

Can I retry a request safely if it times out?+

A 500 is safe to retry since nothing is billed either way. But /ask does not support an Idempotency-Key header, so a retry is a brand-new call — there’s no deduplication against the original attempt.

Does the response include rate-limit headers?+

Yes — every response includes X-RateLimit-Limit and X-RateLimit-Remaining for your per-minute quota, same as /scan and /whatsapp/send. The response body also includes meta.requests_remaining for your monthly quota.