> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Request prices and report outcomes

> Price one line or a whole quote for a customer through the Elastly API, report won and lost lines back, and read any past price decision with its inputs.

Your quoting tool, storefront back end or order system can ask Elastly for a price at the moment it needs one. Elastly prices each line inside your workspace's guardrails and records a decision for it. When the quote is won or lost, you report the outcome so pricing learns from it. This page covers that flow end to end. For how a price is set, see [How pricing works](/docs/concepts/how-pricing-works.md).

> [!WARNING]
>
> The API reference playground sends requests to production with your own API key. A price or outcome request sent from it creates real decisions and outcomes in your workspace. Use a **Test** key in the playground.

## Before you start

* A **Live** or **Test** API key. A **Read-only** key can request prices and read decisions but cannot report outcomes. A **Storefront** key can only request prices on `POST /v1/price` and receives no cost or margin fields. See [Authentication](/docs/developers/authentication.md).
* The customer, named in one of two ways: the Elastly ID from the `id` field of the customers list, `GET /v1/customers`, or the customer's record key in your connected system. Filter the customers list by your own account number with `accountNumber`.
* The SKUs to price, as they appear in your Elastly catalog.

```bash theme={null}
curl "https://api.elastly.ai/v1/customers?accountNumber=C-1001" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

## Price one line or a few lines

`POST /v1/price` prices up to 100 lines for one customer in one currency.

```bash curl theme={null}
curl -X POST https://api.elastly.ai/v1/price \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 5f0c9a52-3d1e-4b7a-8c6f-2e9d0a1b4c73" \
  -d '{
    "buyer": { "kind": "customer", "customerId": "3c1e9b7a-52d4-4f0e-8a6b-9d2c7e1f0a34" },
    "currency": "USD",
    "lines": [
      { "sku": "AX-2201", "quantity": "40" },
      { "sku": "AX-2202", "quantity": "12" }
    ]
  }'
```

```typescript TypeScript theme={null}
const response = await fetch("https://api.elastly.ai/v1/price", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ELASTLY_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    buyer: { kind: "customer", customerId: "3c1e9b7a-52d4-4f0e-8a6b-9d2c7e1f0a34" },
    currency: "USD",
    lines: [
      { sku: "AX-2201", quantity: "40" },
      { sku: "AX-2202", quantity: "12" },
    ],
  }),
})
const priced = await response.json()
```

```python Python theme={null}
import os
import uuid

import requests

response = requests.post(
    "https://api.elastly.ai/v1/price",
    headers={
        "Authorization": f"Bearer {os.environ['ELASTLY_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "buyer": {"kind": "customer", "customerId": "3c1e9b7a-52d4-4f0e-8a6b-9d2c7e1f0a34"},
        "currency": "USD",
        "lines": [
            {"sku": "AX-2201", "quantity": "40"},
            {"sku": "AX-2202", "quantity": "12"},
        ],
    },
)
priced = response.json()
```

The `buyer.kind` must be `customer`. Name the customer with `customerId`, the Elastly ID, or with `customerRef`, the customer's record key in the connected source system. Send exactly one of the two; a request with both or neither is refused with `400`.

```json theme={null}
{ "buyer": { "kind": "customer", "customerRef": "CUST-2207" } }
```

A line can also name a `unit`, a `warehouseId` and a `deliveryCountry`; the request can set `warehouseId` and `deliveryCountry` for every line at once.

## Price a quote

`POST /v1/quotes/price` takes the same body plus a `quoteRef`, your own reference for the quote, and a `lineRef` on each line. Use it when you will report the quote's outcome later: the outcome refers back to these references.

```bash theme={null}
curl -X POST https://api.elastly.ai/v1/quotes/price \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "quoteRef": "Q-1042",
    "buyer": { "kind": "customer", "customerId": "3c1e9b7a-52d4-4f0e-8a6b-9d2c7e1f0a34" },
    "currency": "USD",
    "lines": [
      { "lineRef": "L1", "sku": "AX-2201", "quantity": "400" },
      { "lineRef": "L2", "sku": "AX-2202", "quantity": "120" }
    ]
  }'
```

A `quoteRef` belongs to one customer. Pricing the same `quoteRef` for a different customer is refused with `422` and `quote_ref_customer_mismatch`.

## Read the response

The response holds one entry per line in `lines`, the `totals` per currency, and `complete`, which is `true` when every line was priced.

Each priced line has `state` set to `ok`, the line `price` and `unitPrice` as money objects, the `guard` that limited the price (`none` when no guardrail applied), any `warnings`, a `trace` of the steps that set the price, and a `decisionId`. Keep the `decisionId` to read the decision later. Money objects are described in the [overview](/docs/developers/overview.md#numbers-and-money).

Each priced line also says how long it may be shown:

| Field | Meaning |
| - | - |
| `priceId` | The identifier of this served price. Send it back on the order line so the order links to the exact price. See [Data ingestion](/docs/developers/data-ingestion.md#echo-the-price-on-an-order-line) |
| `version` | A number that grows when the price for the same request is decided again. Compare versions only within one source |
| `validFrom` | When the price was decided |
| `validUntil` | When the price stops being valid: the end of the workspace's day, or earlier when a scheduled change, an agreement or a custom price starts or ends before then |

A storefront can show a price until its `validUntil` and must ask again after it. Price responses carry `Cache-Control: private, no-cache`, so a shared cache does not store them.

A line that could not be priced has a `state`, a `reason` and a `nextAction` instead of a price. The `state` is one of `missing_cost`, `stale_cost`, `missing_data`, `blocked_floor`, `blocked_map`, `blocked_exposure` and `unavailable`. The `reason` names the cause, such as `cost_age_exceeded` or `unmapped_customer`. The reference page lists every value.

| `nextAction` | What to do |
| - | - |
| `refresh_cost` | Update the item's cost |
| `resolve_input` | Correct the input named by `reason` |
| `resolve_exposure` | Review whether the item and customer may be priced through the API |
| `resolve_guard_conflict` | Resolve the conflict between the guardrails named by `reason` |
| `retry` | Send the request again |

A `customerId` or `customerRef` that does not name an active customer of the workspace returns its lines with the reason `unmapped_customer`.

> [!NOTE]
>
> A request is refused as a whole only for request, access and rate errors. An unpriced line never fails the other lines. See [Errors](/docs/developers/errors.md).

## Report an outcome

When the quote is decided, report each line as won or lost with `POST /v1/outcomes`. A **Read-only** key cannot call it.

```bash theme={null}
curl -X POST https://api.elastly.ai/v1/outcomes \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 0d4e7a91-8b2c-4f63-9e15-7a3c2b1d0f86" \
  -d '{
    "quoteRef": "Q-1042",
    "occurredAt": "2026-11-02T09:30:00Z",
    "lines": [
      { "lineRef": "L1", "outcome": "won", "quantity": "400" },
      { "lineRef": "L2", "outcome": "lost", "reasonCode": "price", "competitor": "Example Supply Co", "competitorPrice": "11.80", "currency": "USD" }
    ]
  }'
```

* A won line carries the `quantity` won.
* A lost line carries a `reasonCode` and can carry the `competitor`, the `competitorPrice` and its `currency`.
* Up to 100 lines per request, each `lineRef` once.

The `quoteRef` must have been priced through `POST /v1/quotes/price` with a key of the same environment; otherwise the request is refused with `404` and `quote_not_found`. The response gives each line a `state`: `recorded` when the outcome was stored, or one of `stale`, `line_not_found`, `unknown_reason`, `competitor_not_allowed` and `occurred_in_future` when it was not.

## Read a past decision

`GET /v1/decisions/{id}` returns a decision with the inputs it was made from: the customer, SKU, quantity, price, floor, target, ceiling, cost, the pricing version and the outcome when one is recorded. The `id` in the path is a `decisionId` or a `priceId`. A key reads only decisions made in its own environment.

```bash theme={null}
curl https://api.elastly.ai/v1/decisions/7e2b4c19-0a5d-4f8e-b631-c9d2e4f7a058 \
  -H "Authorization: Bearer YOUR_API_KEY"
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.