Skip to main content
This page is the full contract in one place. A coding agent should be able to read it and produce a working client without opening anything else.
If you are an agent: read this page top to bottom before writing code. Everything you need is here. The only values the user supplies are MATHFI_BASE_URL, MATHFI_EMAIL and MATHFI_PASSWORD. Take all three as configuration. Do not hard-code them, do not write the credentials to disk, do not log them.
Machine-readable sources:

The contract in brief

Products and the pipeline

Two products, run in sequence or independently.
The handoff is one field: pass featureRefinementKey when creating the dataset and no files move.

Endpoints

Everything below is relative to your tenant’s API root, written here as $BASE. All need Authorization: Bearer <token> except POST /api/login.

Authentication

Feature Refinery

columnStatus[] is one {columnIndex, columnName, outcome} per original column, in header order, with outcome either KEEP or REMOVE. refinedTrainUrl and refinedPredictionUrl are the reduced files; refinedColumnStatusUrl is the same decisions as a file, so the same columns can be dropped from a later prediction file. | GET | /api/v1/feature-refinery/{key} | | {state, inputs[], totalColumns, columnsRemoved, ...} | | GET | /api/v1/feature-refinery | offset, limit (≤100) | {refinements[], total} | | POST | /api/v1/feature-refinery/{key}/cancel | none | {state} | | DELETE | /api/v1/feature-refinery/{key} | | 204 — non-destructive; retires the run from your list, keeps its data | name must match ^[A-Za-z0-9 _-]{1,100}$ and be unique among your unfinished runs. numberOfBuckets must be 4, 10 or 20.

Datasets

datasetName is 3 to 30 characters. numberOfBuckets is 4 to 1000.

Training

Models

Predictions

State machines

Poll until terminal. Never match on intermediate states; they can change.

Uploading to a signed URL

uploadTargets[] entries look like:

Decision rules a client must get right

These are the four places a naive client goes wrong.

1. Whether to call /clean

2. Which training target to use

Never default to 0.9 because it sounds better. A target above what the data supports produces a degenerate champion: it predicts one class for every row, accuracy looks plausible, F1 is exactly zero, and the run reports COMPLETED.

3. Validating the result before you trust it

After a run completes, check the champion before reporting success:

4. Bucket count on a refinement handoff

A dataset built from a refinement inherits recommendedNumberOfBuckets and it cannot be changed; the refined files were produced at that setting. Send your own value only on the upload route.

Error handling

Retry-safe operations: every GET, and DELETE (idempotent, and non-destructive — nothing it touches is destroyed, so a retry cannot lose anything). Not retry-safe without checking first: every POST that creates something. On an ambiguous failure, list and look before creating again.

Reference CLI shape

A useful client exposes these commands. The tenant URL and credentials come from the environment; everything else is a flag.
mathfi pipeline is the whole flow: refine, hand over, train at the recommended target, take the default champion, predict, download. Design notes worth keeping:
  • wait commands block and exit non-zero on failure. That is what makes the CLI usable in a script.
  • Print state changes, not a tick per poll. A refinement can poll for an hour.
  • --json on every read command. Agents parse, humans read.
  • Never print the token.
  • Fail fast on a missing MATHFI_BASE_URL with a message that names the pattern. A client that silently defaults to some host will fail against a different tenant in a way nobody can read.

Whole pipeline, as pseudocode

Things that will bite you

Working curl flows

The same steps, runnable.

Endpoint reference

Schemas and responses, generated from the spec.