koshdocs
ourkosh.com

Reference

REST API

You can read and change the data of your Household through the Kosh API. The iPhone app uses the same routes.

  • Base URL: https://api.ourkosh.com
  • Paths: every route below starts with /api/v1/.
  • Auth: Authorization: Bearer <session token> from the sign-in below.
  • Bodies: JSON, except the file routes, which take multipart/form-data.
  • Money: an integer in minor units with an ISO 4217 code. In replies, money is { "minor": 100000, "currency": "INR" } (1,000.00 rupees).
  • Dates: YYYY-MM-DD in the Household time zone. Months: YYYY-MM.
  • Errors: { "error": { "code", "message", "field?" } }. See Errors.

Every route can return unauthenticated (401). Every route that needs a Household can also return no_household (403). The Errors column lists the other codes. ? marks an optional field. A write reply with no other status is 200.

Sign in

Sign-in uses the Better-Auth email code routes under /api/auth, not /api/v1.

  1. POST /api/auth/email-otp/send-verification-otp with { "email", "type": "sign-in" }. Kosh emails a 6-digit code. Errors: rate_limited, email_not_sent.
  2. POST /api/auth/sign-in/email-otp with { "email", "otp" }. The session token is in the set-auth-token reply header.
  3. POST /api/auth/sign-out ends the session.

Household and Members

  • GET /api/v1/me: Who is signed in. Works without a Household.
    • Request: none
    • Reply: email, member, household, pendingInvite, aiConsent: { askServer, pdfStatement, categoryProposals } for the caller, or null without a Household
    • Errors: none
  • DELETE /api/v1/me: Deletes the caller from Kosh. Works without a Household. See Delete me from Kosh.
    • Request: scope: me or household, confirm: DELETE
    • Reply: deleted (me or household), appStorePlanActive. The session ends.
    • Errors: validation_failed (confirm), koshadhyaksha_must_hand_over, forbidden (household by a Member), no_household, billing_provider_failed (nothing was deleted)
  • PUT /api/v1/me/ai-consent: Turns one outside-model path on or off for the caller.
    • Request: path: ask_server, pdf_statement or category_proposals; granted; textVersion (1–40)
    • Reply: askServer, pdfStatement, categoryProposals
    • Errors: validation_failed
  • POST /api/v1/households: Creates the Household. The caller becomes Koshadhyaksha.
    • Request: name (1–60), displayName? (1–40), baseCurrency?, locale?, timeZone?, fyStartMonth? (1–12)
    • Reply: 201 Household
    • Errors: already_in_household, validation_failed
  • GET /api/v1/household: The caller's Household.
    • Request: none
    • Reply: id, name, baseCurrency, locale, timeZone, fyStartMonth, owner
    • Errors: none
  • POST /api/v1/household/koshadhyaksha: Gives the Koshadhyaksha role to another active Member. Koshadhyaksha only.
    • Request: memberId
    • Reply: Household
    • Errors: forbidden, conflict (memberId), review_household
  • PATCH /api/v1/household: Changes the Household settings. Any Member.
    • Request: name?, baseCurrency?, locale?, timeZone?, fyStartMonth?
    • Reply: Household
    • Errors: validation_failed
  • GET /api/v1/members: Every Member, removed ones too.
    • Request: none
    • Reply: Member: id, displayName, email, role, state, removedAt
    • Errors: none
  • PATCH /api/v1/members/me: Renames the caller.
    • Request: displayName (1–40)
    • Reply: Member
    • Errors: validation_failed
  • DELETE /api/v1/members/{id}: Removes a Member and revokes their MCP tokens. Koshadhyaksha only.
    • Request: none
    • Reply: Member
    • Errors: forbidden, not_found, owner_cannot_leave, conflict
  • POST /api/v1/reassign: Gives Holdings and Plan Items of one Member to another. Koshadhyaksha only.
    • Request: fromMemberId, toMemberId, holdingIds?, planItemIds?
    • Reply: holdings, planItems (counts)
    • Errors: forbidden, validation_failed
  • GET /api/v1/invites: Pending and past invites. Koshadhyaksha only.
    • Request: none
    • Reply: Invite: id, email, status, invitedBy, createdAt, expiresAt
    • Errors: forbidden
  • POST /api/v1/invites: Invites a person by email (valid 7 days). Koshadhyaksha only.
    • Request: email
    • Reply: 201 Invite
    • Errors: forbidden, plan_required, already_in_household, conflict, validation_failed
  • DELETE /api/v1/invites/{id}: Cancels a pending invite. Koshadhyaksha only.
    • Request: none
    • Reply: Invite
    • Errors: forbidden, not_found, conflict
  • POST /api/v1/invites/accept: Joins the Household whose pending invite matches the caller's email.
    • Request: displayName (1–40)
    • Reply: 201 Member
    • Errors: already_in_household, not_found, plan_required, validation_failed

Accounts

  • GET /api/v1/accounts: Open Accounts with today's balance, by name.
    • Request: none
    • Reply: Account: id, name, kind, currency, liquidity, maskedNumber, member, typedBalance, balance, archivedAt
    • Errors: none
  • POST /api/v1/accounts: Creates an Account. Liquidity comes from the kind if left out.
    • Request: name (1–60), kind (bank, card, wallet, loan), currency, memberId, liquidity?, maskedNumber? (4 characters), typedBalance? (minor, date)
    • Reply: 201 Account
    • Errors: validation_failed
  • PATCH /api/v1/accounts/{id}: Changes an Account. Kind and currency stay fixed.
    • Request: name?, memberId?, liquidity?, maskedNumber?, typedBalance?
    • Reply: Account
    • Errors: not_found, validation_failed
  • DELETE /api/v1/accounts/{id}: Archives an Account. Its Entries stay.
    • Request: none
    • Reply: archived
    • Errors: not_found
  • GET /api/v1/accounts/{id}/balance: The balance, its anchor, and any difference from a newer typed balance.
    • Request: none
    • Reply: balance, anchor (date, balance, source), differs
    • Errors: not_found

Entries

  • GET /api/v1/entries: Entries by date.
    • Request: query accountId?, from?, to?
    • Reply: Entry: id, accountId, date, direction, amount, description, payeeKey (the payee words of the description; null when it has none), categoryId, source, status, statementId, chequeNumber, chequeExpiresOn, inTransfer (true: one side of a Transfer, so its direction is fixed), transferWaiting (true: a Transfer that waits for its other side; neither spending nor income; never true with inTransfer), possibleDuplicates? (on an unconfirmed typed Entry: the ids of statement lines it may repeat)
    • Errors: not_found, validation_failed
  • POST /api/v1/entries: Creates a typed Entry, "not on a statement".
    • Request: accountId, date, direction (debit, credit), amountMinor, currency, description (up to 140), categoryId?, chequeNumber? (debit only, 1–12 digits)
    • Reply: 201 Entry. With no categoryId, a remembered payee of the same payee and direction gives the Category. When one imported statement line already shows it: 200 with that line and matched (statement), and nothing new is saved. When two or more lines could: 201 with possibleDuplicates (their ids)
    • Errors: currency_mismatch, not_found, validation_failed
  • PATCH /api/v1/entries/{id}: Changes an Entry. A statement Entry changes only its Category and its Transfer mark. A new date on one side of a Transfer moves the other side too, and so does a new amount, when the other side is typed. On a Transfer of two amounts (rewards part), a new amount changes this side only. After a new date or amount, Kosh looks for the statement line as on create.
    • Request: date?, direction?, amountMinor?, description?, categoryId?, chequeNumber? (debit only), transferWaiting?. Not accountId or currency. transferWaiting: true marks the Entry as a Transfer: Kosh pairs it at once when its other side is in Kosh (the reply has inTransfer: true), else it waits (transferWaiting: true); its Category is removed. transferWaiting: false, or a categoryId, ends the wait. Not transferWaiting: true with a categoryId
    • Reply: Entry, or the statement line with matched (statement) when one line now shows it; possibleDuplicates?; counterpart? (the other side of its Transfer, when the edit moved it); onlyThisSide? (true: the new amount is on this side only); alsoCategorised? (a new Category: Kosh remembers the payee, and this many other Entries of that payee and direction without a Category took it; only when above 0). categoryId: null changes this Entry only.
    • Errors: conflict (a statement line: "A statement line is fixed. Only its Category can change."; a new amount when the other side is a statement line: "The other side of this Transfer is a statement line. Change the amount there by importing the statement."; a new direction on a Transfer side; transferWaiting: true on a side of a Transfer), not_found, validation_failed
  • DELETE /api/v1/entries/{id}: Deletes a typed Entry.
    • Request: none
    • Reply: deleted
    • Errors: conflict, not_found
  • POST /api/v1/entries/{id}/keep: Keeps a typed Entry that a Statement did not list, as confirmed.
    • Request: none
    • Reply: Entry
    • Errors: not_found
  • POST /api/v1/entries/{id}/discard: Deletes a typed Entry that a Statement did not list.
    • Request: none
    • Reply: deleted
    • Errors: conflict, not_found
  • POST /api/v1/entries/{id}/link: Links a typed Entry to the statement line it repeats. The line takes its place in any Transfer, and the typed Entry is removed.
    • Request: statementEntryId (same Account, direction, amount and currency; not one side of a Transfer)
    • Reply: the statement line, as an Entry
    • Errors: conflict ("This statement line is already one side of a Transfer.", "This statement line is already linked to another Entry."), not_found, validation_failed

Statements

  • POST /api/v1/statements/preview: Reads a statement file and shows what applying it would do. Writes nothing.
    • Request: multipart accountId, file (CSV, OFX, QIF, Excel or PDF, up to 10 MB), password?, links?
    • Reply: format, from, to (the period the file prints when it holds every row, else the first and last row dates), opening, closing, check, lines[] (status: new, matches, duplicate; entryId, nearEntryId), duplicateOf ({ statementId, importedOn }: the stored Statement of this Account with the same dates and closing balance, or the same end date and closing balance and the same lines (row count, money-out sum and money-in sum); without a closing balance, the same end date and the same lines; null when none), unmatchedTyped
    • Errors: validation_failed, not_found, currency_mismatch, statement_unbalanced, import_wrong_password, import_unreadable, import_unknown_format, import_extraction_invalid, import_too_large, import_extractor_unavailable, usage_limit, ai_consent_required (pdf_statement: a PDF that needs the model)
  • POST /api/v1/statements/apply: Adds new lines, confirms matched typed Entries, skips repeats, in one batch.
    • Request: the same multipart form; or JSON from a PDF preview: accountId, format (pdf), from, to, openingMinor, closingMinor, lines[] (1–500: date, direction, amountMinor, description), links?
    • Reply: 201 statementId, added, confirmed, duplicates, categorised (new lines that took the Category of a remembered payee), transferred (paired: Transfers made, a new line paired with its other side or with a waiting Transfer; waiting: new lines of a Transfer payee that wait for their other side), unmatchedTyped
    • Errors: the same as preview, and statement_duplicate (409) when duplicateOf is not null: nothing is saved

links is a list of { "line", "entryId" }: the 0-based row of a near match and the typed Entry it confirms. In the multipart form it is a JSON string. See Statement import.

Payees

A remembered payee is a payee key, a direction and a Category. Kosh gives that Category to every Entry of the payee and direction that has no Category and is not one side of a Transfer. It never changes an Entry that has a Category. See Categories for Entries.

A Transfer payee is a payee key and a direction whose Entries are money moved between the Household's own Accounts. Kosh pairs each Entry of the payee without a Category with its other side: an Entry in another Account of the Household, the other direction, the same currency and amount, within 5 days, not yet in a Transfer. With two or more, the nearest date wins. If two are equally near, Kosh makes no pair. An Entry with no other side in Kosh waits for it (transferWaiting). A new Entry that is the other side of a waiting Transfer pairs with it, for any payee. A tie pairs nothing. See Transfers.

  • GET /api/v1/payees/pending: Entries without a Category, by payee.
    • Request: none
    • Reply: total (Entries without a Category, not Transfer sides and not waiting Transfers), ungrouped (those with no payee words), payees (every payee group that waits, before the limit of 50 on groups; for "Showing 50 of 199 payees"), groups[] (at most 50, largest first, then by key: payeeKey, direction, count, latestDate, sample: the newest description, ownName: true when the key holds the first and last name of an active Member, as words in any order or joined; a hint that the Entries may be Transfers), suggestUsesQuestion (true when suggest counts one server question; false when it counts one Category-proposal call), transferWaiting (Entries that wait for their other side: set, not to sort, so not in total)
    • Errors: none
  • POST /api/v1/payees/suggest: The server's Category provider proposes a Category for each pending payee it can place. It sees the payee keys, their directions and the Category names only. Saves nothing.
    • Request: {}
    • Reply: suggestions[]: payeeKey, direction, categoryId (only pending payees, only the Household's Categories, only picks the provider is sure of). Counts one Category-proposal call: 200 a month for each Household, on every plan, apart from the monthly questions. Only when the server model stands in for TypeSafe (suggestUsesQuestion is true) does it count one server question instead. With nothing pending: an empty list and no count
    • Errors: ai_consent_required (category_proposals), usage_limit, import_extractor_unavailable, validation_failed
  • PUT /api/v1/payees: Remembers payees and gives each Category to the pending Entries of that payee and direction. A Transfer payee pairs its pending Entries instead.
    • Request: items[] (1–50, each payee and direction once): payeeKey (as pending gives it), direction, and either categoryId or transfer: true (exactly one of the two)
    • Reply: items[]: id, payeeKey, direction, categoryId (null for a Transfer payee), transfer, applied (Entries that took the Category, or were paired), paired and waiting (for a Transfer payee: its Entries without a Category paired now, and those that wait for their other side; 0 for a Category payee)
    • Errors: validation_failed
  • GET /api/v1/payees: The remembered payees, by key.
    • Request: none
    • Reply: payees[]: id, payeeKey, direction, categoryId, transfer (false), count (Entries of this payee and direction whose Category is categoryId now; 0 is valid); transferPayees[]: id, payeeKey, direction, categoryId (null), transfer (true), count and paired (Entries of this payee and direction that are one side of a Transfer; 0 is valid), waiting (those that wait for their other side)
    • Errors: none
  • DELETE /api/v1/payees/{id}: Forgets a remembered payee. Its Entries keep their Category, and the Transfers a Transfer payee made stay. DELETE /api/v1/transfers/{id} undoes one pair.
    • Request: none
    • Reply: 204
    • Errors: not_found

Transfers

  • GET /api/v1/transfers/suggested: Debit and credit pairs on two of your own Accounts, not yet confirmed. A waiting Transfer can be one side. Confirming the pair (POST /api/v1/transfers) ends the wait.
    • Request: none
    • Reply: debit, credit (Entries), kind (same_currency, cross_currency)
    • Errors: none
  • POST /api/v1/transfers: Confirms a pair as a Transfer.
    • Request: debitEntryId, creditEntryId
    • Reply: 201 Transfer: id, debitEntryId, creditEntryId, kind
    • Errors: conflict, not_found, validation_failed
  • POST /api/v1/transfers/pay: Pays one Account from another: a debit, a credit and the Transfer. A side that an imported statement line already shows is that line.
    • Request: fromAccountId, toAccountId, date, amountMinor (what the receiving Account got), fromAmountMinor? (what the paying Account paid, when rewards paid part), description?
    • Reply: 201 transfer, debit, credit (each with matched? or possibleDuplicates?), fromStatement (debit, credit: the sides that are statement lines)
    • Errors: currency_mismatch, not_found, validation_failed
  • DELETE /api/v1/transfers/{id}: Removes a Transfer. Both Entries count as spending or income again.
    • Request: none
    • Reply: deleted
    • Errors: not_found

Money

  • GET /api/v1/money: Accounts and Holdings by Liquidity, in their own currency and the Base currency.
    • Request: none
    • Reply: baseCurrency, rateDate, netWorth, spendable, groups[] (liquidity, total, lines), rates
    • Errors: none
  • GET /api/v1/money/spending: Money out and in for a month in the Base currency, without confirmed Transfers.
    • Request: query period (YYYY-MM)
    • Reply: period, baseCurrency, total, inflow, byCategory, unconverted, rateDate
    • Errors: validation_failed

Categories

  • GET /api/v1/categories: The Household's Categories.
    • Request: none
    • Reply: Category: id, name, nature, holdingCount
    • Errors: none
  • POST /api/v1/categories: Creates a Category.
    • Request: name (1–40), nature (asset, liability, tracked)
    • Reply: 201 Category
    • Errors: conflict, validation_failed
  • PATCH /api/v1/categories/{id}: Renames a Category or changes its kind.
    • Request: name?, nature?
    • Reply: Category
    • Errors: conflict, not_found, validation_failed
  • DELETE /api/v1/categories/{id}: Removes a Category. Refused while a Holding uses it.
    • Request: none
    • Reply: removed
    • Errors: conflict, not_found
  • GET /api/v1/asset-classes: The Household's Asset classes.
    • Request: none
    • Reply: AssetClass: id, name, holdingCount
    • Errors: none
  • POST /api/v1/asset-classes: Creates an Asset class.
    • Request: name (1–40)
    • Reply: 201 AssetClass
    • Errors: conflict, validation_failed
  • DELETE /api/v1/asset-classes/{id}: Removes an Asset class. Refused while a Holding uses it.
    • Request: none
    • Reply: removed
    • Errors: conflict, not_found

Holdings

  • GET /api/v1/holdings: Active Holdings with their newest Snapshot.
    • Request: none
    • Reply: Holding: id, name, kind, currency, liquidity, fundHouse, isin, folioLabel, category, assetClass, tags, goalId, member, latestSnapshot, unitsMilli, unitsOnDate, nav
    • Errors: none
  • POST /api/v1/holdings: Creates a Holding. Liquidity comes from the kind if left out.
    • Request: name (1–80), memberId, kind (fund, stock, fd, ppf, nps, epf, property, insurance, other), currency, liquidity?, fundHouse?, isin?, categoryId?, assetClassId?, tags? (up to 10), unitsMilli?, unitsOnDate?
    • Reply: 201 Holding
    • Errors: not_found, validation_failed
  • PATCH /api/v1/holdings/{id}: Changes a Holding. Currency stays fixed.
    • Request: any Holding field except currency
    • Reply: Holding
    • Errors: not_found, validation_failed
  • DELETE /api/v1/holdings/{id}: Archives a Holding. Its Snapshots stay.
    • Request: none
    • Reply: Holding
    • Errors: not_found
  • GET /api/v1/holdings/{id}/snapshots: Snapshots of one Holding, oldest first.
    • Request: query from?, to?
    • Reply: Snapshot: holdingId, onDate, value, source
    • Errors: not_found, validation_failed
  • PUT /api/v1/holdings/{id}/snapshots/{date}: Sets the value on one date. One value per date.
    • Request: valueMinor (0 or more)
    • Reply: Snapshot
    • Errors: not_found, validation_failed
  • DELETE /api/v1/holdings/{id}/snapshots/{date}: Deletes the Snapshot of one date.
    • Request: none
    • Reply: deleted
    • Errors: not_found, validation_failed
  • POST /api/v1/navs/refresh: Checks AMFI for new NAVs now, at most once a minute.
    • Request: none
    • Reply: checkedAt, okAt, stale, failure
    • Errors: none

Imports (CAS)

  • POST /api/v1/imports: Reads a CAS and returns a preview, open for 30 minutes. Writes no Holding.
    • Request: multipart type (cas), file (up to 10 MB and 60 pages), password?, memberId?
    • Reply: 201 id, type, statementDate, expiresAt, items[] (action: create, update; holding, snapshot, xirrBp), xirrByFundHouse, notices
    • Errors: validation_failed, import_too_large, import_wrong_password, import_unreadable, import_unknown_format
  • GET /api/v1/imports/{id}: The open preview.
    • Request: none
    • Reply: the preview
    • Errors: not_found
  • POST /api/v1/imports/{id}/apply: Writes the Holdings and Snapshots of the preview.
    • Request: none
    • Reply: holdingsCreated, holdingsUpdated, snapshotsUpserted, transactionsAdded
    • Errors: not_found
  • POST /api/v1/imports/{id}/discard: Closes the preview. Nothing is written.
    • Request: none
    • Reply: 204
    • Errors: not_found

Plan Items

  • GET /api/v1/plan-items: Every Plan Item.
    • Request: query state? (active, paused, stopped)
    • Reply: PlanItem: id, name, amount, direction, accountId, member, schedule, startDate, endDate, linkedHoldingId, goalId, state, notification, mutedByMe
    • Errors: validation_failed
  • POST /api/v1/plan-items: Creates a Plan Item and its Occurrences.
    • Request: name (1–80), amountMinor, currency, direction (in, out), memberId, schedule, accountId?, startDate?, endDate?, linkedHoldingId?
    • Reply: 201 planItem, occurrencesCreated
    • Errors: currency_mismatch, not_found, validation_failed
  • GET /api/v1/plan-items/{id}: One Plan Item.
    • Request: none
    • Reply: PlanItem
    • Errors: not_found
  • PATCH /api/v1/plan-items/{id}: Changes a Plan Item. Future pending Occurrences are made again.
    • Request: any Plan Item field
    • Reply: PlanItem
    • Errors: currency_mismatch, not_found, validation_failed
  • POST /api/v1/plan-items/{id}/pause: Pauses. Future pending Occurrences go.
    • Request: none
    • Reply: PlanItem
    • Errors: conflict, not_found
  • POST /api/v1/plan-items/{id}/resume: Resumes a paused Plan Item.
    • Request: none
    • Reply: PlanItem
    • Errors: conflict, not_found
  • POST /api/v1/plan-items/{id}/stop: Stops for good. Future pending Occurrences go.
    • Request: none
    • Reply: PlanItem
    • Errors: conflict, not_found
  • PUT /api/v1/plan-items/{id}/notification: Sets the notification for every phone.
    • Request: enabled, leadDays (0–30)
    • Reply: PlanItem
    • Errors: not_found, validation_failed
  • PUT /api/v1/plan-items/{id}/mute: Mutes the Plan Item on the caller's phone only.
    • Request: none
    • Reply: PlanItem
    • Errors: not_found
  • DELETE /api/v1/plan-items/{id}/mute: Unmutes it on the caller's phone.
    • Request: none
    • Reply: PlanItem
    • Errors: not_found

schedule is one of: { "kind": "monthly", "dayOfMonth", "intervalMonths?", "anchorDate?" } (an interval above 1 needs anchorDate), { "kind": "yearly", "dayOfMonth", "month" }, { "kind": "once", "date" }, { "kind": "weekly", "weekday" (0 = Monday … 6 = Sunday), "intervalWeeks", "anchorDate" }, { "kind": "dates", "dates" (1–60) }.

Occurrences and Today

  • GET /api/v1/occurrences: Occurrences, with the status worked out for today.
    • Request: query from?, to?, status? (pending, done, overdue)
    • Reply: Occurrence: id, planItem, member, dueDate, amount, status, doneAt, doneBy
    • Errors: validation_failed
  • POST /api/v1/occurrences/{id}/done: Marks done and records the Member.
    • Request: none
    • Reply: Occurrence
    • Errors: not_found
  • POST /api/v1/occurrences/{id}/undo: Undoes a done mark.
    • Request: none
    • Reply: Occurrence
    • Errors: not_found
  • GET /api/v1/today: The Today data for the app and the widget.
    • Request: none
    • Reply: asOf, next, overdue, dueToday, month (done, total)
    • Errors: none

Goals

  • GET /api/v1/goals: Goals with links and progress.
    • Request: none
    • Reply: Goal: id, name, target, targetDate, member, holdingIds, planItemIds, progress (saved, remaining, savedBp, monthsLeft)
    • Errors: none
  • POST /api/v1/goals: Creates a Goal. The target date must be after today.
    • Request: name (1–60), targetMinor, currency, targetDate, memberId?
    • Reply: 201 Goal
    • Errors: not_found, validation_failed
  • PATCH /api/v1/goals/{id}: Changes a Goal. Currency stays fixed.
    • Request: name?, targetMinor?, targetDate?, memberId?
    • Reply: Goal
    • Errors: not_found, validation_failed
  • PUT /api/v1/goals/{id}/links: Replaces the linked Holdings and Plan Items.
    • Request: holdingIds (up to 500), planItemIds (up to 500)
    • Reply: Goal
    • Errors: not_found, validation_failed
  • DELETE /api/v1/goals/{id}: Deletes a Goal. Its Holdings and Plan Items stay.
    • Request: none
    • Reply: deleted
    • Errors: not_found

Rules

  • GET /api/v1/rules: The Household's Rules.
    • Request: none
    • Reply: Rule: id, name, measure, scope, op, threshold, enabled
    • Errors: none
  • POST /api/v1/rules: Creates a Rule.
    • Request: name (1–60), measure, scope (kind, id?), op (above, below), threshold ({ "kind": "bp", "value" } or { "kind": "money", "minor", "currency" })
    • Reply: 201 Rule
    • Errors: not_found, validation_failed
  • PATCH /api/v1/rules/{id}: Changes a Rule, or turns it off.
    • Request: any Rule field, enabled?
    • Reply: Rule
    • Errors: not_found, validation_failed
  • DELETE /api/v1/rules/{id}: Deletes a Rule.
    • Request: none
    • Reply: deleted
    • Errors: not_found
  • GET /api/v1/rules/status: Checks every enabled Rule against a month. The text states the fact only.
    • Request: query period (YYYY-MM)
    • Reply: ruleId, label, broken, text for each subject
    • Errors: not_found, validation_failed

See Rules for the measures and scopes.

Ask

  • GET /api/v1/ask/catalog: The text a model reads to plan a question.
    • Request: none
    • Reply: summary, members[] (id, firstName): the active Members
    • Errors: none
  • POST /api/v1/ask: Asks the server model. Counts one server question first.
    • Request: question (1–300 characters), memberId?: an active Member of this Household. It filters every query to that Member and wins over the model's plan.
    • Reply: outOfScope, parts[] (type, text, fact), text, steps, memberId: the Member the answer is filtered to, or null for the whole Household
    • Errors: ai_consent_required (ask_server), usage_limit, import_extractor_unavailable, validation_failed (memberId of no active Member of this Household)
  • POST /api/v1/ask/run: Runs a plan from the caller's own model. Not counted.
    • Request: plan: { "queries" (up to 4), "outOfScope" }. Each query may have memberId.
    • Reply: the same as POST /api/v1/ask
    • Errors: validation_failed (field plan.queries.N.memberId for a Member that is not active in this Household)

See Ask for the query types and About one Member.

MCP tokens

  • GET /api/v1/mcp-tokens: The caller's tokens. Never the secret.
    • Request: none
    • Reply: id, name, tokenPrefix, createdAt, expiresAt, lastUsedAt, revokedAt
    • Errors: none
  • POST /api/v1/mcp-tokens: Makes a token. The secret is in this reply only.
    • Request: name (1–40), expiresInDays (1–90)
    • Reply: 201 the token and secret
    • Errors: plan_required, validation_failed
  • DELETE /api/v1/mcp-tokens/{id}: Revokes a token: your own, or any as Koshadhyaksha.
    • Request: none
    • Reply: the token
    • Errors: forbidden, not_found

App data

  • GET /api/v1/sync: A full refresh of the phone's local copy. Checks AMFI first, at most every 15 minutes.
    • Request: none
    • Reply: serverTime, household, members, planItems, occurrences, holdings, navStatus
    • Errors: none
  • POST /api/v1/events: Sends one product count from the app to OpenPanel. Works without a Household. Fixed names only.
    • Request: name, properties? (short values)
    • Reply: 202, no body
    • Errors: validation_failed

Plan and billing

Kosh is free during private testing, and checkout is not open. These routes report the plan; the payment routes take no payments now.

India pays through Dodo Payments in INR, and the INR price includes GST. Every other country pays through Paddle in USD, and Paddle adds tax at checkout. A Household that has or had a subscription keeps its provider and its currency. The two billing GET replies are never cached (Cache-Control: private, no-store, Vary: CF-IPCountry).

  • GET /api/v1/billing/terms: What a visitor from this country pays. No sign-in.
    • Request: none
    • Reply: currency (INR or USD), taxInclusive, prices (solo and household, each month and year, as { minor, available }), checkoutOpen, paddle. No ids.
    • available is false when the price is under the provider's minimum charge. Dodo takes no subscription under 1 USD, so it applies when the INR price is under 1 USD at the latest ECB rate.
    • paddle is { environment, clientToken } for Paddle.js (sandbox or production). The client-side token is public by design. The value is null while Paddle is not configured or has no token.
    • Errors: none
  • GET /api/v1/billing: The Household's plan, this month's use and the plans. Any Member.
    • Request: none
    • Reply: plan (free, solo or household), name, interval (month, year or null), source (subscription, managed, free or billing_off), status, currentPeriodEnd, cancelAtPeriodEnd, testMode, canBuy, currency, limits, usage (month, questions and pdfPages, each used and allowed), plans (id, name, limits, prices.month and prices.year as { minor, currency, available, change }, minor units in currency; available as in /billing/terms, always true on Free; change is when a change to that plan and interval would start: now, period_end or unavailable, and null for Free, the current choice, no subscription, or while a change waits), managed, provider, taxInclusive, paymentFailed, planEndsAt, canResume, changesTo, paidThrough, doublePaid
    • changesTo is { plan, interval, on } while a downgrade waits for the end of the paid period, else null. on is YYYY-MM-DD in the Household time zone. Until on, plan and interval stay the larger plan.
    • While a change waits for its payment, changesTo is { plan, interval, on: null, waitingForPayment: true }, and plan and interval stay the current plan. The change applies when the provider confirms it. If the payment fails, changesTo is null again and the plan does not change.
    • paidThrough says who takes the money for the plan in force: apple (iPhone in-app purchase), paddle or dodo (web). It is null on Free, on a managed plan and while payments are off. source stays subscription for all three.
    • doublePaid is true when two sources pay at once (the web and the App Store). The higher plan holds. Stop one of them.
    • Errors: none
  • POST /api/v1/billing/checkout: Not open during private testing. Koshadhyaksha only.
    • Request: plan (solo or household), interval (month or year)
    • Reply: url, plan, interval, currency, minor (the price that GET /api/v1/billing shows)
    • Dodo gives its hosted page. Paddle gives its checkout URL for this payment: https://ourkosh.com/checkout?_ptxn=<id>. That page loads Paddle.js. After payment the buyer returns to the Household screen of the web app.
    • A plan and interval with available: false gives conflict before any provider call, for example "Kosh Solo monthly is not offered here. Choose the yearly plan."
    • While the plan is paid through the App Store, the reply is paid_elsewhere (409).
    • Errors: forbidden, conflict, paid_elsewhere, plan_managed, billing_provider_failed, billing_unavailable, validation_failed
  • POST /api/v1/billing/change: Changes the plan or the interval at the Household's provider. Koshadhyaksha only.
    • Request: plan (solo or household), interval (month or year)
    • Reply: plan, interval, upgrade, effective (now, period_end or on_payment), on (YYYY-MM-DD or null).
    • The plan and the interval decide effective, never the price. upgrade is true for a higher plan.
      Changeeffective
      Same interval, higher plan (Solo to Household)now
      Same interval, lower plan (Household to Solo)period_end
      Monthly to yearly, any plannow
      Yearly to monthlyHigher plan: now. Same or lower plan: period_end with Dodo Payments; plan_change_unavailable with Paddle
    • now: the new plan starts now. The provider charges the new price and credits the unused part of the paid period. on is null. period_end: the Household keeps the paid plan until on (the day the new plan starts). There is no refund and no extra charge.
    • on_payment: a change that starts now but waits for its payment. Dodo Payments applies it only when the charge clears (in India, up to 2 days). The current plan stays until then, and GET /api/v1/billing shows the change in changesTo. A second change while one waits gives conflict.
    • plan_change_unavailable (409): Paddle cannot set a change for a later date, and a change now would end the paid year. The message gives the date: "A yearly plan changes to monthly only at its end. Cancel the plan; it stays active until 2027-01-15. Then choose the monthly plan." Kosh makes no provider call.
    • GET /api/v1/billing gives the same answer before the tap, in plans[].prices.month.change and plans[].prices.year.change.
    • While a downgrade waits, a second change gives conflict.
    • Errors: forbidden, not_found, conflict, paid_elsewhere, plan_change_unavailable, plan_managed, billing_provider_failed, billing_unavailable, validation_failed
  • POST /api/v1/billing/portal: Not open during private testing. Koshadhyaksha only.
    • Request: none
    • Reply: url
    • Errors: forbidden, not_found, paid_elsewhere, plan_managed, billing_provider_failed, billing_unavailable
  • POST /api/v1/billing/cancel: The plan stays until the paid period ends. Koshadhyaksha only.
    • Request: none
    • Reply: ok
    • Errors: forbidden, not_found, paid_elsewhere, plan_managed, billing_provider_failed, billing_unavailable
  • POST /api/v1/billing/resume: Undoes a scheduled cancel before the period ends. Paddle only. Koshadhyaksha only.
    • Request: none
    • Reply: ok
    • Errors: forbidden, not_found, conflict, paid_elsewhere, resume_unavailable, plan_managed, billing_provider_failed, billing_unavailable
  • GET /api/v1/billing/apple/token: The Household's account token for iPhone purchases. Any Member.
    • Request: none
    • Reply: appAccountToken: a random UUID. The iPhone sets it on each App Store purchase, so the purchase names the Household. The first call by the Koshadhyaksha makes it, and it never changes. A Member gets null until it exists.
    • Errors: billing_unavailable
  • POST /api/v1/billing/apple/link: Ties an App Store purchase to the Household. The iPhone sends it after a purchase, a restore or an update.
    • Request: signedTransaction: the purchase as the App Store signed it (StoreKit 2 jwsRepresentation).
    • Reply: the same as GET /api/v1/billing.
    • Kosh checks that Apple signed the purchase (the chain ends at Apple Root CA - G3), that it is a Kosh plan, and that it carries this Household's token.
    • A first purchase: Koshadhyaksha only. While a Paddle or Dodo plan pays, the reply is paid_elsewhere and nothing is linked.
    • A restore or a renewal of a purchase the Household has: any Member.
    • Errors: forbidden, paid_elsewhere, apple_other_household, validation_failed, billing_unavailable
  • POST /webhooks/apple: App Store Server Notifications, version 2. No sign-in.
    • Request: signedPayload, signed by Apple.
    • Reply: applied. A bad signature gives unauthenticated (401). Each notification applies once (by its notificationUUID).

Kosh shows your numbers. It does not advise on investments.

ourkosh.com