# Zigbongo documentation

> Two calls from your server: ask which option to show, then report what it was worth. Start with a quickstart, then read the guides for the details.

## What Zigbongo does

Zigbongo is a hosted API that sits behind the choices your product makes for each customer: an offer, the plan to
lead with, a paywall, a trial length, an upsell, an onboarding step. At each of these decision points your server
sends the options you have and the one you'd show today, and gets back the option to show. Later you report the
outcome, such as revenue, and Zigbongo learns which options raise revenue per customer (ARPU). Each decision point
keeps learning rather than running a fixed A/B test (a multi-armed bandit, and a contextual bandit when you send
inputs): it starts from your default, moves traffic as the evidence builds, and measures the lift against a holdout,
people who keep your defaults. It only chooses among the options you send. It never writes copy, sets prices or invents steps. More in
[How it works](https://zigbongo.com/how-it-works/) and [Bandit vs A/B testing](https://zigbongo.com/bandit-vs-ab-testing/).

## Concepts

- **Flow:** one place in your product where Zigbongo chooses for a customer, such as `checkout` or `onboarding`,
  named by a key you choose (1 to 128 letters, digits, `-`, `_` or `.`). A flow exists the first time your code asks
  about it.
- **Decision point (node):** a place in a flow where your code asks Zigbongo to choose between options, such as
  `upsell`. A flow can have one or many.
- **Option:** one of the choices at a decision point, named by a key, such as `none` or `annual`. You build every
  option; Zigbongo only decides which one to show.
- **Default:** the option you'd show today. It's where learning starts, what the holdout always gets, what everyone
  sees while a flow is paused, and what the SDKs show when Zigbongo is slow or unreachable.
- **Session:** one run of a flow for one customer, such as one visit to checkout, from its first decision to its
  outcome, however many decision points it has. A five-step quiz is one session, not five. Live sessions are what you
  pay for, after 10,000 free each month ([Pricing](https://zigbongo.com/pricing/)).
- **Subject:** your own id for the person, such as their user id. Send the same one every time: it keeps their
  holdout assignment stable and lets you report outcomes per customer.
- **Outcome:** what your app reports after Zigbongo chose, such as a purchase and its amount: revenue, margin, a
  renewal or a cancellation, as a number. You report it per session or per customer, and it counts when it happens
  within the flow's attribution window (one day by default).
- **Holdout:** 5% of people keep your defaults, the same people for the life of the flow, so the lift is always
  measured against what you'd have done anyway, with a 95% interval. You can change the share per flow and per
  decision point.
- **Lift:** how much more the customers Zigbongo chooses for bring than the holdout, per session.
- **Environment and key:** each project has a live environment, for real customers, and a test environment, for
  development and staging. Each learns on its own, and test environments are free. An API key belongs to one
  environment, so the key you use decides where your calls go. Keys stay on your server.
- **Input:** context you attach to a decision, such as plan, country, traffic source or an earlier answer. Inputs are
  flat strings, numbers and booleans, exact values or bands, and they let each group of customers get its own best
  option.

## The two calls

Both calls come from your server, never from a browser or app.

1. **Decide** at each decision point: send the options, the default and, if you like, some inputs. You get back the
   option to show. Over HTTP, this is `POST /v1/flows/{flowKey}/decide`.
2. **Report the outcome** when you know it, minutes or weeks later: `POST /v1/outcomes`, per session or per
   customer. It counts within the flow's attribution window, one day by default and up to 90 days in the flow's
   settings.

With the Node.js SDK:

```js
import { Zigbongo } from "@zigbongo/sdk";

const zb = new Zigbongo({ apiKey: process.env.ZIGBONGO_KEY, baseUrl: "https://zigbongo.com" });

// 1. At the decision point
const s = zb.session("checkout", user.id);
const upsell = await s.decide("upsell", ["none", "annual"], "none");
show(upsell.option);

// 2. Later, when they pay
await s.outcome(invoice.total, invoice.id);
```

There is no schema and nothing to set up first. Registering a flow up front is optional: see
[Registered flows](https://zigbongo.com/docs/registered-flows.md).

Some safeguards are always on. The SDKs wait at most 150 ms for an answer; on a timeout or an error they show your
default and report the fallback, which is never learned from. Pause a flow and within seconds everyone sees your
default choices.

## For AI assistants and agents

Every docs page is also plain Markdown, without the site around it: put `.md` in place of the trailing slash, so this
page is [/docs.md](https://zigbongo.com/docs.md) and the Node.js quickstart is
[/docs/quickstart/node.md](https://zigbongo.com/docs/quickstart/node.md). A request that asks for `text/markdown` gets the Markdown at the
page's own address too. [llms.txt](https://zigbongo.com/llms.txt) lists every page with a sentence about it, and
[llms-full.txt](https://zigbongo.com/llms-full.txt) holds all of them in one file, to give an assistant the whole of the docs at once.

## Where to go next

Start with the quickstart for your language. Each one goes from an API key to a first decision and outcome in a free
test environment:

- [Node.js quickstart](https://zigbongo.com/docs/quickstart/node.md)
- [PHP quickstart](https://zigbongo.com/docs/quickstart/php.md)
- [HTTP quickstart](https://zigbongo.com/docs/quickstart/http.md), for any other language

Then the guides:

- [Sessions and outcomes](https://zigbongo.com/docs/sessions-and-outcomes.md): sessions over several decision points, and reporting
  outcomes per session or per customer.
- [Holdout and lift](https://zigbongo.com/docs/holdout-and-lift.md): how the lift is measured, and when it's clear.
- [Inputs](https://zigbongo.com/docs/inputs.md): sending context so each group of customers gets its own best option.
- [Registered flows](https://zigbongo.com/docs/registered-flows.md): defining a flow's steps and routing up front.
- [Fallbacks and timeouts](https://zigbongo.com/docs/fallbacks-and-timeouts.md): what happens when Zigbongo is slow or unreachable.
- [Retries and rate limits](https://zigbongo.com/docs/retries-and-rate-limits.md): what to retry, and how long to wait.
- [Pausing flows](https://zigbongo.com/docs/pausing-flows.md): the kill switch.
- [Erasing customers](https://zigbongo.com/docs/erasing-customers.md): passing on a GDPR erasure request.
- [Environments and keys](https://zigbongo.com/docs/environments-and-keys.md): live and test, and looking after your keys.

Every call, field and error code is in the [HTTP API reference](https://zigbongo.com/docs/api.md).

---

The Markdown of https://zigbongo.com/docs/. Every docs page: https://zigbongo.com/llms.txt
