Help us shape the future of Go! Take the 2026 Go Developer Survey

trueup

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 16 Imported by: 0

README

TrueUp for Go

Go Reference

The official client for the TrueUp API. Send TrueUp two ledgers (a supplier statement and your receiving log, your books and the bank feed, invoices and payments) and it pairs every row, then tells you what's only on one side, what was counted twice and where the numbers disagree.

Go 1.21+. No dependencies beyond the standard library.

Install

go get github.com/merchantprotocol/trueup-go

Quickstart

Create an API key in the TrueUp dashboard (API keys), then set TRUEUP_API_KEY:

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/merchantprotocol/trueup-go"
)

func main() {
	client, err := trueup.NewClient() // reads TRUEUP_API_KEY
	if err != nil {
		log.Fatal(err)
	}
	// left: the side that bills or claims; right: the other side
	result, err := client.Reconcile(context.Background(), trueup.File("statement.csv"), trueup.File("receiving.csv"), nil)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(result.Headline)
	// 7 of 8 rows of statement.csv paired with receiving.csv; 1 only in statement.csv, ...
	for _, f := range result.Findings {
		fmt.Println(f.Kind, f.Subject, f.Detail)
	}
	// qty_mismatch statement.csv:row 5 Qty 24 vs qty_received 20; ...
	// phantom statement.csv:row 6 no match on the other side
}

Reconcile

A table is a file, file contents, or rows:

trueup.File("books.csv")
trueup.Content("books.csv", csvBytes)
trueup.Rows("invoices", []trueup.Row{{"Invoice #": "INV-10101", "Date": "2026-06-09", "Total": "$2,999.31"}})

CSV, TSV, JSON and JSON Lines are read, and date and number formats are detected. Nothing about the columns is configured.

Not sure which file is which? client.ReconcileFiles(ctx, []trueup.Table{trueup.File("a.csv"), trueup.File("b.csv")}, nil) picks the pair and the sides.

Reuse what was learned by passing an earlier result's weights, and answer the questions TrueUp wasn't sure about:

march, _ := client.Reconcile(ctx, trueup.File("march-statement.csv"), trueup.File("march-receiving.csv"), nil)
april, _ := client.Reconcile(ctx, trueup.File("april-statement.csv"), trueup.File("april-receiving.csv"),
	&trueup.ReconcileOptions{Weights: march.Details.Weights})

client.Reconcile(ctx, trueup.File("statement.csv"), trueup.File("receiving.csv"), &trueup.ReconcileOptions{
	Answers: &trueup.Answers{
		Same:      [][2]string{{"statement.csv:row 12", "receiving.csv:row 11"}},
		Different: [][2]string{{"statement.csv:row 3", "receiving.csv:row 9"}},
	},
})

Each call to Reconcile or ReconcileFiles counts as one analysis on your plan.

Match

Two lists that describe the same things in different words (two catalogs, a supplier's price book and your invoice, two vendor lists): every record on the left is paired with its counterpart on the right, or reported as having none. Nothing is configured; the columns can have different names.

res, err := client.Match(ctx, trueup.File("invoice.csv"), trueup.File("catalog.csv"), nil)
fmt.Println(res.Headline)
// 4 of 5 records in invoice.csv matched to catalog.csv (0 unsure); 1 have no counterpart.
for _, f := range res.Findings {
	fmt.Println(f.Kind, f.Subject, f.Detail)
}
// match 4 ~ 5 4 · cheese puffs jumbo 8oz · 3.30 · 10  ↔  C-105 · Cheese Puffs Jumbo 8 oz · 3.25
// only_left 5 5 · beef jerky teriyaki 2.5oz · 5.75 · 6

Kind is match, unsure_match (a person should check), only_left or only_right. Details.Pairs lists every pair with its confidence. Like Reconcile, it takes File, Content or Rows; MatchFiles picks the pair; MatchStored works on stored files (with a saved model); and Details.Weights can be passed back as MatchOptions.Weights to match next month's lists the same way. One analysis per call.

Audit

Find what doesn't add up. Send text documents with labeled amounts (invoices, statements, schedules; about 4 or more of a kind) and TrueUp learns the arithmetic each kind obeys from the documents themselves, then flags the ones that break it. Send one table and it checks its rows the same way (qty × unit price = amount), and flags repeated rows.

res, err := client.Audit(ctx, []trueup.Table{trueup.File("inv-1041.txt"), /* … */ trueup.File("inv-1046.txt")}, nil)
fmt.Println(res.Headline)
// 1 of 6 documents don't add up; 0 more to review (5 laws learned).
for _, f := range res.Findings {
	fmt.Println(f.Subject, *f.Amount, f.Detail)
}
// inv-1045.txt 200 subtotal + tax amount = total: 4,837.84 vs 5,037.84

// Next month, even one invoice at a time, against the same laws:
client.Audit(ctx, []trueup.Table{trueup.File("inv-1050.txt")}, &trueup.AuditOptions{Weights: res.Details.Weights})

AuditStored(ctx, fileIDs, model) audits stored files. One analysis per call.

Estimate

Price a new job from your past estimates. Send a domain file for the trade (a .tu file naming the facts to read, what costs scale with, and the cost categories), at least 3 past estimates in any format (CSV, TSV, Markdown, JSON, or text proposals), and one request describing the new job in plain words:

files := []trueup.Table{trueup.File("barndo.tu"), trueup.File("01_anderson.csv"), /* … */ trueup.File("job_a.txt")}
res, err := client.Estimate(ctx, files, nil)
fmt.Println(res.Headline)
// job_a.txt: $292,267 (80% range $248,742 – $335,792) from 10 past estimates.

// The next job, with what was learned (no need to send the history again):
client.Estimate(ctx, []trueup.Table{trueup.File("job_b.txt")}, &trueup.EstimateOptions{Weights: res.Details.Weights})

EstimateStored(ctx, fileIDs, model) prices from stored files. One analysis per call.

Stored files, runs and saved models

Files uploaded to your team stay there (you'll also see them in the dashboard). Runs on stored files are kept, and what a run learned can be saved as a model:

files, err := client.UploadFiles(ctx, trueup.File("statement.csv"), trueup.File("receiving.csv"))
statement, receiving := files[0], files[1]   // statement.Rows, .Columns, .Roles ("Qty": "number", ...)

res, err := client.ReconcileStored(ctx, trueup.StoredInput{LeftFileID: statement.ID, RightFileID: receiving.ID}, nil)
modelID, err := client.CreateModel(ctx, res.RunID, "Acme statements")

// Next month: apply what was learned.
client.ReconcileStored(ctx, trueup.StoredInput{FileIDs: []string{aprilStatement.ID, aprilReceiving.ID}},
	&trueup.StoredOptions{Model: modelID})
Method Returns
UploadFiles(ctx, tables...), ListFiles(ctx), GetFile(ctx, id) StoredFile: ID, Name, Rows, Columns, Roles
FileContent(ctx, id) the bytes, exactly as uploaded
DeleteFile(ctx, id)
ReconcileStored(ctx, StoredInput, *StoredOptions) StoredResult: a result plus RunID (one analysis)
ListRuns(ctx, limit, before) RunPage: Runs, HasMore, newest first
AllRuns(ctx, func(Run) bool) calls you for every run, paging for you
GetRun(ctx, id) RunDetail: Run, Result
CreateModel(ctx, runID, name), ListModels(ctx), GetModel(ctx, id), DeleteModel(ctx, id) GetModel includes the Weights

Findings

Kind Meaning
phantom Only on the left: billed or recorded, never matched
unbilled Only on the right: received or paid, never billed
duplicate, received_duplicate A copy of a row that's already paired
qty_mismatch, price_change, amount_mismatch Paired rows whose numbers disagree
unsure_pair A likely pair a person should confirm

Account and usage

acct, _ := client.Account(ctx)
usage, _ := client.Usage(ctx)
plans, _ := client.Plans(ctx)

Errors

API errors are *trueup.Error with Status, Code (the API's error code) and Message. Match kinds with errors.Is:

Sentinel When
trueup.ErrAuthentication 401: missing, unknown or revoked key
trueup.ErrInvalidRequest 400, 413, 415, 422: the request or the files need fixing (unsupported_file, not_reconcilable, ...)
trueup.ErrRateLimited 429 rate_limited: retried automatically; RetryAfter
trueup.ErrQuotaExceeded 429 quota_exceeded: the plan's monthly allowance is used up
trueup.ErrServer 5xx: retried automatically
trueup.ErrConnection the API couldn't be reached
if errors.Is(err, trueup.ErrQuotaExceeded) {
	fmt.Println("upgrade the plan")
}

Configuration

trueup.NewClient(
	trueup.WithAPIKey("tu_live_..."),       // default: TRUEUP_API_KEY
	trueup.WithBaseURL("https://..."),      // default: TRUEUP_BASE_URL, then the hosted API
	trueup.WithHTTPClient(&http.Client{Timeout: 5 * time.Minute}),
	trueup.WithMaxRetries(2),               // rate limits, 5xx and dropped connections
)

Development

The tests run in Docker against the live API:

export TRUEUP_API_KEY=tu_live_...   # a key for a test team (each run uses 10 analyses)
just test                            # or: docker compose run --rm test

License

MIT

Documentation

Overview

Package trueup is the official client for the TrueUp API.

Send TrueUp two ledgers (a supplier statement and your receiving log, your books and the bank feed, invoices and payments) and it pairs every row, then tells you what's only on one side, what was counted twice and where the numbers disagree.

client, err := trueup.NewClient() // reads TRUEUP_API_KEY
result, err := client.Reconcile(ctx, trueup.File("statement.csv"), trueup.File("receiving.csv"), nil)
for _, f := range result.Findings {
	fmt.Println(f.Kind, f.Subject, f.Detail)
}

Index

Constants

View Source
const DefaultBaseURL = "https://trueup-cloud.merchantprotocol.workers.dev"

DefaultBaseURL is the hosted TrueUp API.

View Source
const Version = "0.5.0"

Version of this SDK.

Variables

View Source
var (
	ErrAuthentication = errors.New("authentication")  // 401: missing, unknown or revoked API key
	ErrInvalidRequest = errors.New("invalid request") // 400, 413, 415, 422: the request or the files need fixing
	ErrNotFound       = errors.New("not found")       // 404, 405
	ErrRateLimited    = errors.New("rate limited")    // 429 rate_limited
	ErrQuotaExceeded  = errors.New("quota exceeded")  // 429 quota_exceeded: retrying won't help
	ErrServer         = errors.New("server error")    // 5xx
	ErrConnection     = errors.New("connection")      // the API couldn't be reached
)

Kinds of error, for errors.Is.

Functions

This section is empty.

Types

type Account

type Account struct {
	Team struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"team"`
	Plan *struct {
		Slug string `json:"slug"`
		Name string `json:"name"`
	} `json:"plan"`
	Key struct {
		ID     string `json:"id"`
		Name   string `json:"name"`
		Prefix string `json:"prefix"`
	} `json:"key"`
}

Account is the team, plan and key behind an API key.

type Answers

type Answers struct {
	Same      [][2]string `json:"same,omitempty"`
	Different [][2]string `json:"different,omitempty"`
}

Answers are decisions a person made about pairs: [left row, right row], e.g. {"statement.csv:row 3", "receiving.csv:row 4"}.

type AuditDetails added in v0.4.0

type AuditDetails struct {
	Laws []struct {
		Scope string `json:"scope"`
		Law   string `json:"law"`
		Held  string `json:"held"`
	} `json:"laws"`
	Model struct {
		Learned bool `json:"learned"`
	} `json:"model"`
	// Weights: pass back as AuditOptions.Weights to check new documents against the same laws.
	Weights json.RawMessage `json:"weights"`
}

AuditDetails are the laws learned (or applied) and what to pass back to apply them again.

type AuditOptions added in v0.4.0

type AuditOptions struct {
	Weights json.RawMessage
}

AuditOptions are optional settings for an audit call.

type AuditResult added in v0.4.0

type AuditResult struct {
	Analysis string             `json:"analysis"`
	Title    string             `json:"title"`
	Headline string             `json:"headline"`
	Stats    map[string]float64 `json:"stats"`
	// Findings: Kind is arithmetic (the numbers break a law; Amount is how far off) or duplicate_row.
	Findings []Finding    `json:"findings"`
	Details  AuditDetails `json:"details"`
	Inputs   []string     `json:"inputs"`
	Engine   string       `json:"engine"`
	RunID    string       `json:"run_id"`
}

AuditResult is the answer to an audit call: documents (Analysis "audit") or a table's rows ("table-audit").

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	MaxRetries int
	// contains filtered or unexported fields
}

Client talks to the TrueUp API. It is safe for concurrent use.

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient returns a client. It fails if there is no API key.

func (*Client) Account

func (c *Client) Account(ctx context.Context) (*Account, error)

Account returns the team, plan and key behind the client's API key.

func (*Client) AllRuns added in v0.2.0

func (c *Client) AllRuns(ctx context.Context, fn func(Run) bool) error

AllRuns calls fn for every run, newest first, fetching page after page. Return false from fn to stop.

func (*Client) Audit added in v0.4.0

func (c *Client) Audit(ctx context.Context, files []Table, opts *AuditOptions) (*AuditResult, error)

Audit finds what doesn't add up. Text documents (invoices, statements, 4 or more of a kind): TrueUp learns the arithmetic each kind obeys and flags the ones that break it. One table: the same for its rows, plus repeated rows. opts may be nil. One analysis.

func (*Client) AuditStored added in v0.4.0

func (c *Client) AuditStored(ctx context.Context, fileIDs []string, model string) (*AuditResult, error)

AuditStored audits files already stored in the team, by id. model (a saved audit model id) may be "".

func (*Client) CreateModel added in v0.2.0

func (c *Client) CreateModel(ctx context.Context, runID, name string) (string, error)

CreateModel saves what a run learned as a model and returns the model's id.

func (*Client) DeleteFile added in v0.2.0

func (c *Client) DeleteFile(ctx context.Context, id string) error

DeleteFile deletes a stored file.

func (*Client) DeleteModel added in v0.2.0

func (c *Client) DeleteModel(ctx context.Context, id string) error

DeleteModel deletes a saved model.

func (*Client) Estimate added in v0.5.0

func (c *Client) Estimate(ctx context.Context, files []Table, opts *EstimateOptions) (*EstimateResult, error)

Estimate prices a new job from past estimates: a domain file for the trade (.tu), at least 3 past estimates in any format, and one request describing the new job; or, with opts.Weights, just the request. One analysis.

func (*Client) EstimateStored added in v0.5.0

func (c *Client) EstimateStored(ctx context.Context, fileIDs []string, model string) (*EstimateResult, error)

EstimateStored prices from files already stored in the team, by id. model (a saved estimate model id) may be "".

func (*Client) FileContent added in v0.2.0

func (c *Client) FileContent(ctx context.Context, id string) ([]byte, error)

FileContent returns a stored file's bytes, exactly as uploaded.

func (*Client) GetFile added in v0.2.0

func (c *Client) GetFile(ctx context.Context, id string) (*StoredFile, error)

GetFile returns one stored file.

func (*Client) GetModel added in v0.2.0

func (c *Client) GetModel(ctx context.Context, id string) (*Model, error)

GetModel returns one saved model, including its Weights.

func (*Client) GetRun added in v0.2.0

func (c *Client) GetRun(ctx context.Context, id string) (*RunDetail, error)

GetRun returns one run and its full result.

func (*Client) ListFiles added in v0.2.0

func (c *Client) ListFiles(ctx context.Context) ([]StoredFile, error)

ListFiles returns the team's stored files.

func (*Client) ListModels added in v0.2.0

func (c *Client) ListModels(ctx context.Context) ([]Model, error)

ListModels returns the team's saved models.

func (*Client) ListRuns added in v0.2.0

func (c *Client) ListRuns(ctx context.Context, limit int, before string) (*RunPage, error)

ListRuns returns one page of runs on stored files, newest first. limit is 1-100 (0 for the default of 100); before is a run id ("" for the newest).

func (*Client) Match added in v0.3.0

func (c *Client) Match(ctx context.Context, left, right Table, opts *MatchOptions) (*MatchResult, error)

Match pairs the records of two lists that describe the same things in different words (two catalogs, a price book and an invoice): each record on left (the list to go through) with its counterpart on right (the list to search), or reports it has none. opts may be nil. One analysis.

func (*Client) MatchFiles added in v0.3.0

func (c *Client) MatchFiles(ctx context.Context, files []Table, opts *MatchOptions) (*MatchResult, error)

MatchFiles sends two or more lists; TrueUp picks the pair to match and puts the shorter on the left. opts may be nil. One analysis.

func (*Client) MatchStored added in v0.3.0

func (c *Client) MatchStored(ctx context.Context, in StoredInput, model string) (*MatchResult, error)

MatchStored matches lists already stored in the team, by id. model (a saved match model id) may be "". The run is kept: its id is RunID. One analysis.

func (*Client) Plans

func (c *Client) Plans(ctx context.Context) ([]Plan, error)

Plans returns the plans a team can be on.

func (*Client) Reconcile

func (c *Client) Reconcile(ctx context.Context, left, right Table, opts *ReconcileOptions) (*ReconcileResult, error)

Reconcile reconciles two tables. left is the side that bills or claims (a statement, your books), right the other side (receiving log, bank feed). opts may be nil. Counts as one analysis.

func (*Client) ReconcileFiles

func (c *Client) ReconcileFiles(ctx context.Context, files []Table, opts *ReconcileOptions) (*ReconcileResult, error)

ReconcileFiles sends two or more files; TrueUp picks the pair to reconcile and which side is which. opts may be nil. One analysis.

func (*Client) ReconcileStored added in v0.2.0

func (c *Client) ReconcileStored(ctx context.Context, in StoredInput, opts *StoredOptions) (*StoredResult, error)

ReconcileStored reconciles files already stored in the team, by id. The run is kept: its id is RunID. opts may be nil. One analysis.

func (*Client) UploadFiles added in v0.2.0

func (c *Client) UploadFiles(ctx context.Context, files ...Table) ([]StoredFile, error)

UploadFiles stores one or more files in the team. Each comes back with its ID, Rows, Columns and Roles.

func (*Client) Usage

func (c *Client) Usage(ctx context.Context) (*Usage, error)

Usage returns this month's usage for the key's team.

type Details

type Details struct {
	Model   map[string]any  `json:"model"`
	Weights json.RawMessage `json:"weights"`
	Pairs   []Pair          `json:"pairs"`
}

Details are what the run learned and every pair it made.

type Error

type Error struct {
	Status     int
	Code       string
	Message    string
	RetryAfter time.Duration
	Body       []byte
	// contains filtered or unexported fields
}

Error is any error the API returned, or a failure to reach it. Code is the API's error code; branch on it (or use errors.Is with the sentinel kinds below).

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap lets errors.Is(err, trueup.ErrQuotaExceeded) and friends work.

type EstimateDetails added in v0.5.0

type EstimateDetails struct {
	Scope []struct {
		Category   string  `json:"category"`
		Include    bool    `json:"include"`
		Confidence float64 `json:"confidence"`
		Why        string  `json:"why"`
	} `json:"scope"`
	Total map[string]any `json:"total"`
	Model struct {
		Learned bool `json:"learned"`
	} `json:"model"`
	// Weights: the trade and its labeled past estimates; pass back as EstimateOptions.Weights with just a request.
	Weights json.RawMessage `json:"weights"`
}

EstimateDetails are the job's scope, its total, and what was learned.

type EstimateOptions added in v0.5.0

type EstimateOptions struct {
	Weights json.RawMessage
}

EstimateOptions are optional settings for an estimate call.

type EstimateResult added in v0.5.0

type EstimateResult struct {
	Analysis string `json:"analysis"`
	Title    string `json:"title"`
	Headline string `json:"headline"`
	// Stats: total, low, high (the 80% range), categories priced, past estimates, ...
	Stats map[string]float64 `json:"stats"`
	// Findings: Kind "priced_line" is one cost category (Amount is its price); status "unsure" is for a person.
	Findings []Finding       `json:"findings"`
	Details  EstimateDetails `json:"details"`
	Inputs   []string        `json:"inputs"`
	Engine   string          `json:"engine"`
	RunID    string          `json:"run_id"`
}

EstimateResult is the answer to an estimate call: the new job priced part by part, with an 80% range.

type Finding

type Finding struct {
	// Kind: phantom, unbilled, duplicate, received_duplicate, qty_mismatch, price_change, amount_mismatch, unsure_pair.
	Kind    string `json:"kind"`
	Label   string `json:"label"`
	Subject string `json:"subject"`
	Detail  string `json:"detail"`
	// Confidence is how likely the pairing is right; nil for rows with no pair.
	Confidence *float64       `json:"confidence"`
	Status     string         `json:"status"`
	Amount     *float64       `json:"amount"`
	Provenance []string       `json:"provenance"`
	Data       map[string]any `json:"data"`
}

Finding is one thing TrueUp found.

type MatchDetails added in v0.3.0

type MatchDetails struct {
	Columns struct {
		Left  map[string]string `json:"left"`
		Right map[string]string `json:"right"`
	} `json:"columns"`
	// Pairs are [left id, right id, confidence].
	Pairs []MatchPair `json:"pairs"`
	Model struct {
		Learned bool `json:"learned"`
	} `json:"model"`
	// Weights: pass back as MatchOptions.Weights to match the same way without learning.
	Weights json.RawMessage `json:"weights"`
}

MatchDetails are how the columns lined up, every pair, and what was learned.

type MatchOptions added in v0.3.0

type MatchOptions struct {
	// Weights is Details.Weights from an earlier match: apply what was learned then instead of learning again.
	Weights json.RawMessage
}

MatchOptions are optional settings for a match call.

type MatchPair added in v0.3.0

type MatchPair struct {
	LeftID     string
	RightID    string
	Confidence float64
}

MatchPair is one pair: the left record's id, the right record's id, and the confidence.

func (*MatchPair) UnmarshalJSON added in v0.3.0

func (p *MatchPair) UnmarshalJSON(b []byte) error

UnmarshalJSON reads a pair from the API's [left id, right id, confidence].

type MatchResult added in v0.3.0

type MatchResult struct {
	Analysis string             `json:"analysis"`
	Title    string             `json:"title"`
	Headline string             `json:"headline"`
	Stats    map[string]float64 `json:"stats"`
	// Findings: Kind is match, unsure_match (a person should check), only_left or only_right.
	Findings []Finding    `json:"findings"`
	Details  MatchDetails `json:"details"`
	Inputs   []string     `json:"inputs"`
	Engine   string       `json:"engine"`
	// RunID is the kept run, for MatchStored.
	RunID string `json:"run_id"`
}

MatchResult is the answer to a match call.

type Model added in v0.2.0

type Model struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Analysis    string  `json:"analysis"`
	SourceRunID *string `json:"source_run_id"`
	CreatedAt   string  `json:"created_at"`
	// Weights is set only by GetModel.
	Weights json.RawMessage `json:"weights,omitempty"`
}

Model is a saved model: what a run learned, reusable on next month's files.

type Option

type Option func(*Client)

Option configures a Client.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets the API key (default: TRUEUP_API_KEY).

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets the API address (default: TRUEUP_BASE_URL, then the hosted API).

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient sets the HTTP client (default: 300 s timeout; big ledgers take a while).

func WithMaxRetries

func WithMaxRetries(n int) Option

WithMaxRetries sets retries for rate limits, server errors and dropped connections (default 2).

type Pair

type Pair struct {
	Left       string  `json:"left"`
	Right      string  `json:"right"`
	Confidence float64 `json:"confidence"`
}

Pair is one pairing of a left row with a right row.

type Plan

type Plan struct {
	Slug        string `json:"slug"`
	Name        string `json:"name"`
	Description string `json:"description"`
	PriceCents  int    `json:"price_cents"`
	Interval    string `json:"interval"`
	Purchasable bool   `json:"purchasable"`
	Limits      []struct {
		Metric               string `json:"metric"`
		Included             int    `json:"included"`
		HardCap              bool   `json:"hard_cap"`
		OverageMicrosPerUnit *int   `json:"overage_micros_per_unit"`
	} `json:"limits"`
}

Plan is a plan a team can be on.

type ReconcileOptions

type ReconcileOptions struct {
	// Weights is Details.Weights from an earlier result: apply what was learned then instead of learning again.
	Weights json.RawMessage
	Answers *Answers
}

ReconcileOptions are optional settings for a reconcile call.

type ReconcileResult

type ReconcileResult struct {
	Analysis string             `json:"analysis"`
	Title    string             `json:"title"`
	Headline string             `json:"headline"`
	Stats    map[string]float64 `json:"stats"`
	Findings []Finding          `json:"findings"`
	Details  Details            `json:"details"`
	Inputs   []string           `json:"inputs"`
	Engine   string             `json:"engine"`
}

ReconcileResult is the answer to a reconcile call.

type Row

type Row map[string]any

Row is one row of a table: column name -> value (string, number, bool or nil).

type Run added in v0.2.0

type Run struct {
	ID       string `json:"id"`
	Analysis string `json:"analysis"`
	// Status is "done" or "failed".
	Status string `json:"status"`
	// Via is "api" or "portal".
	Via    string   `json:"via"`
	Inputs []string `json:"inputs"`
	Model  *struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"model"`
	Headline *string            `json:"headline"`
	Stats    map[string]float64 `json:"stats"`
	// Findings is how many findings the run has.
	Findings  *int    `json:"findings"`
	Error     *string `json:"error"`
	CreatedAt string  `json:"created_at"`
}

Run is a run on stored files, from the API or the dashboard.

type RunDetail added in v0.2.0

type RunDetail struct {
	Run    Run              `json:"run"`
	Result *ReconcileResult `json:"result"`
}

RunDetail is one run and its full result (nil if the run failed).

type RunPage added in v0.2.0

type RunPage struct {
	Runs    []Run `json:"runs"`
	HasMore bool  `json:"has_more"`
}

RunPage is one page of runs, newest first.

type StoredFile added in v0.2.0

type StoredFile struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Size int64  `json:"size"`
	// Kind is "table" or "document".
	Kind    string   `json:"kind"`
	Rows    *int     `json:"rows"`
	Columns []string `json:"columns"`
	// Roles is what TrueUp read each column as: "date", "number", "text", ...
	Roles     map[string]string `json:"roles"`
	CreatedAt string            `json:"created_at"`
}

StoredFile is a file stored in the team (uploaded through the API or the dashboard).

type StoredInput added in v0.2.0

type StoredInput struct {
	LeftFileID  string
	RightFileID string
	FileIDs     []string
}

StoredInput names stored files by id: LeftFileID and RightFileID, or FileIDs for TrueUp to pick the pair.

type StoredOptions added in v0.2.0

type StoredOptions struct {
	// Model is a saved model id: apply what it learned instead of learning again.
	Model   string
	Answers *Answers
}

StoredOptions are optional settings for ReconcileStored.

type StoredResult added in v0.2.0

type StoredResult struct {
	ReconcileResult
	RunID string `json:"run_id"`
}

StoredResult is a reconcile result on stored files, with the id of the run that was kept.

type Table

type Table struct {
	Name string
	// contains filtered or unexported fields
}

Table is one table to reconcile: a file, file contents, or rows. Name is how findings refer to its rows ("statement.csv:row 5"). Build one with File, Content or Rows.

func Content

func Content(name string, content []byte) Table

Content is a table from file contents; name's extension says the format (.csv, .tsv, .json, .jsonl).

func File

func File(path string) Table

File is a table read from a file on disk when the request is sent.

func Rows

func Rows(name string, rows []Row) Table

Rows is a table from rows.

type Usage

type Usage struct {
	Period   string        `json:"period"`
	ResetsAt string        `json:"resets_at"`
	Metrics  []UsageMetric `json:"metrics"`
}

Usage is this month's usage for a team.

type UsageMetric

type UsageMetric struct {
	Metric    string `json:"metric"`
	Label     string `json:"label"`
	Used      int    `json:"used"`
	Included  int    `json:"included"`
	Remaining int    `json:"remaining"`
	HardCap   bool   `json:"hard_cap"`
	Overage   int    `json:"overage"`
}

UsageMetric is this month's use of one metric.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL