# Consequence-based decision

`POST /api/v1/cb-decision`

> Eevo docs. Every page as Markdown is listed at https://eevo.io/llms.txt; the API is described at https://eevo.io/api/openapi.json.

Weigh consequences, model their overlap and compute expected value for one or more stakeholders. The endpoint runs hundreds of calls to the underlying “raw” Eevo decision model to compare consequences and model their overlap. It then computes expected value separately for each stakeholder you send.

## Quick example

Below is a quick example of a consequence-based decision via curl:

```shell
curl https://eevo.io/api/v1/cb-decision \
  -H "Authorization: Bearer $EEVO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "eevo-1",
  "mode": "default",
  "context": "Acme Corp found a data-export bug that shows some customers a wrong invoice total. A fix is ready; a log dump that would confirm it arrives in 40 minutes.",
  "options": [
    {
      "id": "A",
      "description": "Ship the fix now.",
      "consequences": [
        {
          "id": "a1",
          "label": "Wrong totals stop now",
          "description": "About 200 customers stop seeing a wrong invoice total 40 minutes sooner.",
          "valence": "benefit"
        },
        {
          "id": "a2",
          "label": "Invoices to recheck",
          "description": "Without the log dump to confirm the fix, about 20 customers get an email asking them to recheck one invoice.",
          "valence": "harm"
        }
      ]
    },
    {
      "id": "B",
      "description": "Wait for the log dump, then ship.",
      "consequences": [
        {
          "id": "b1",
          "label": "40 more minutes of wrong totals",
          "description": "About 200 customers keep seeing a wrong invoice total for 40 more minutes.",
          "valence": "harm"
        }
      ]
    }
  ],
  "stakeholders": [
    {
      "id": "customers",
      "description": "The affected customers",
      "values": "Correct invoices, no surprises."
    }
  ]
}'
```

The response:

```json
{
  "id": "dec_7b1c0e4f9a2d4c6b8e3f5a1d2c4b6e8f",
  "model": "eevo-1.2",
  "mode": "default",
  "overlap": "correct",
  "seed": 20261006,
  "results": [
    {
      "stakeholder": {
        "id": "customers",
        "description": "The affected customers"
      },
      "best": "A",
      "confidence": 0.99,
      "probabilities": {
        "A": 0.99,
        "B": 0.01
      },
      "p_best": {
        "A": 0.99,
        "B": 0.01
      },
      "p_best_uncorrected": {
        "A": 1,
        "B": 0
      },
      "best_uncorrected": "A",
      "ev": {
        "A": {
          "mean": 0.52,
          "p10": 0.38,
          "p90": 0.63
        },
        "B": {
          "mean": -0.45,
          "p10": -0.58,
          "p90": -0.33
        }
      },
      "ev_uncorrected": {
        "A": {
          "mean": 0.87,
          "p10": 0.79,
          "p90": 0.95
        },
        "B": {
          "mean": -0.81,
          "p10": -0.9,
          "p90": -0.66
        }
      },
      "harms_benefits": {
        "A": {
          "harms": {
            "mean": 0.18,
            "p10": 0.09,
            "p90": 0.31
          },
          "benefits": {
            "mean": 0.7,
            "p10": 0.6,
            "p90": 0.81
          }
        },
        "B": {
          "harms": {
            "mean": 0.45,
            "p10": 0.33,
            "p90": 0.58
          },
          "benefits": {
            "mean": 0,
            "p10": 0,
            "p90": 0
          }
        }
      },
      "consequences": [
        {
          "id": "a1",
          "option": "A",
          "description": "About 200 customers stop seeing a wrong invoice total 40 minutes sooner.",
          "label": "Wrong totals stop now",
          "valence": "benefit",
          "size": {
            "value": 1,
            "p10": 0.82,
            "p90": 1
          },
          "counted_share": 0.6,
          "overlaps_with": [
            {
              "with": "b1",
              "share": 0.88
            }
          ],
          "discounted_by": {
            "with": "b1",
            "type": "mirror",
            "overlap": 0.88,
            "share": 0.4,
            "absence_p": 0.5
          }
        },
        {
          "id": "a2",
          "option": "A",
          "description": "Without the log dump to confirm the fix, about 20 customers get an email asking them to recheck one invoice.",
          "label": "Invoices to recheck",
          "valence": "harm",
          "size": {
            "value": 0.18,
            "p10": 0.09,
            "p90": 0.31
          },
          "counted_share": 1,
          "overlaps_with": [],
          "discounted_by": null
        },
        {
          "id": "b1",
          "option": "B",
          "description": "About 200 customers keep seeing a wrong invoice total for 40 more minutes.",
          "label": "40 more minutes of wrong totals",
          "valence": "harm",
          "size": {
            "value": 0.9,
            "p10": 0.74,
            "p90": 1
          },
          "counted_share": 0.56,
          "overlaps_with": [
            {
              "with": "a1",
              "share": 0.88
            }
          ],
          "discounted_by": {
            "with": "a1",
            "type": "mirror",
            "overlap": 0.88,
            "share": 0.44,
            "absence_p": 0.5
          }
        }
      ],
      "overlaps": [
        {
          "a": "a1",
          "b": "b1",
          "share": 0.88,
          "p": 0.97,
          "type": "mirror",
          "type_p": 0.95,
          "kind": "mirror",
          "absence_side": "a1",
          "absence_p": 0.5,
          "absence": {
            "a1": 0.5,
            "b1": 0.5
          }
        }
      ],
      "removed_share": 0.41,
      "mc": {
        "draws": 1000,
        "solved": 1000
      },
      "records": {
        "ratio": 3,
        "overlap": 2
      }
    }
  ],
  "agreement": {
    "all_same": true,
    "best_by_stakeholder": {
      "customers": "A"
    }
  },
  "warnings": [],
  "usage": {
    "billed_decisions": 1,
    "ratio_records": 3,
    "overlap_records": 2
  },
  "cost_usd": 0.15,
  "links": {
    "view_url": "https://eevo.io/decisions/dec_7b1c0e4f9a2d4c6b8e3f5a1d2c4b6e8f/explicit",
    "png_url": "https://eevo.io/api/arvo/decisions/dec_7b1c0e4f9a2d4c6b8e3f5a1d2c4b6e8f/explicit.png"
  },
  "meta": {
    "tau": 0.2,
    "draws": 1000,
    "ratio_spread_scale": 0.72,
    "overlap_model": "eevo-1.2@3dacdbf4",
    "correction": {
      "mirror": false,
      "kept": true
    }
  },
  "notes": "EVs are on each stakeholder's own scale (largest consequence = 1); compare options within a stakeholder, not across stakeholders. Informative, not a recommendation."
}
```

A decision that is still running after about 50 seconds answers `202` instead, with a `poll_url` to fetch it from ([Get a decision](https://eevo.io/api/docs/reference/api-get-decision.md)).
