Decision models · API v1

Decision API

Send a document or a JSON record, get back a probability for every allowed answer of every question, in one model pass. No free text to parse. Each use case (inside a pack) fixes the questions and options; you only send the input. With a custom schema you can also ask your own questions.

Base URL · Auth Authorization: Bearer ma_… · Format JSON, UTF-8

Quick start


Response:


Use decision.option for the answer and decision.band to decide what to do with it: act (run automatically), confirm (ask a person to confirm), human (hand over). Bands come from the pack's thresholds, by default act > 0.9, confirm 0.5–0.9, human < 0.5; you can apply your own thresholds to confidence.

Authentication and keys

MediaAtlas issues one key per customer or integration. Send it as a Bearer token. Keys can be limited to some packs, a request rate and a monthly token quota. Keep keys on your server; never put them in browser code. A leaked key is revoked and replaced on request.

POST/v1/decisions

Body

fieldtype
packstringPack id, e.g. accounts-payable. See the reference below or GET /v1/packs.
usecasestringUse-case id within the pack, e.g. approval_gate.
inputstring | objectOne document (text) or record (JSON object). Some use cases require JSON fields, listed per use case.
inputsarrayInstead of input: up to 32 inputs decided in one call. Results come back in the same order.
questionsobjectOptional custom schema instead of pack/usecase, see Custom questions.
modelstringOptional; leave it out to use the default. GET /v1/models lists what is available.

Response

field
idRequest id (dec_…), quote it in support requests.
modelModel tier that decided.
results[]One per input. decision: the use case's main question with option, confidence, band. answers: every question with option, confidence, band and probabilities for all options; score questions add expected (probability-weighted level) and level. Ranking use cases return ranking[] of {id, score} instead.
usageinput_tokens, output_tokens (always 0, see Billing), decisions (inputs × questions).
latency_msTime spent on the server.

Custom questions

Send questions instead of pack/usecase. Each question has a type: choice (named options), score (ordered levels, low to high) or noul (yes/no), an instructions sentence, and criteria: for choice an object {option: "when to pick it"}, for score a list of level descriptions. Write criteria as decision rules; the model reads them.



Other endpoints

GET/v1/models – available tiers and the default.
GET/v1/packs – every pack and use case with its input description, questions and options (no key needed).
GET/v1/packs/{pack} – one pack.
GET/v1/usage – this month's requests, decisions and tokens for your key, plus quota and rate limit.

Errors

Errors return {"error": {"code", "message"}}.

statuscodemeaning
400invalid_json, missing_input, invalid_inputs, invalid_schemaFix the request.
401missing_key, invalid_keyNo key, unknown or revoked key.
403pack_not_allowedThe key is not enabled for this pack.
400unknown_modelThe model is not available here; see /v1/models.
404unknown_pack, unknown_usecaseCheck ids in /v1/packs.
413input_too_largeAn input is over 20,000 characters; split it.
422input_mismatchThe use case needs JSON fields the input does not have.
429rate_limited, quota_exceededWait for Retry-After seconds, or ask for a higher quota.
503 / 504busy, timeoutRetry with backoff.

Billing and limits

API use is included in your MediaAtlas plan up to the agreed monthly volume; MediaAtlas sets up the integration and issues keys for your developers. Usage is metered per key in input tokens: the input plus the use case's questions and options as the model reads them. Decision models do not generate text, so output_tokens is always 0. Longer inputs and more questions cost more tokens; a batch (inputs) costs the same as separate calls but is faster. GET /v1/usage shows the running total. Request content is not stored, only counts and timings.

Client examples

Python


JavaScript (server side)


C# (.NET)



Pack reference

Generated from the pack definitions served by GET /v1/packs, so it always matches the running server.