# Sourcing Scenario

A sourcing scenario defines a sourcing configuration for a project. Each scenario specifies which
assemblies to source (demands), their required quantities, and a set of solution preferences
that control how offers are evaluated and selected.

Sourcing scenarios belong to a project, which is either an **RFQ** (Request for Quotation) or a
**Negotiation**. A single project can have multiple scenarios, allowing you to compare
different sourcing strategies side by side — for example, different order quantities,
supplier preferences, or lead time targets.

**Note on solution preferences:** Sourcing scenarios include detailed solution preferences that control
how offers are evaluated (e.g., lead time targets, supplier preferences, inventory handling,
pricing filters, packaging, and excess thresholds). These settings are complex and evolve
frequently — we update them on a monthly basis. For this reason, **managing solution
preferences via the API is not supported**. Please configure them through the Luminovo UI
instead.


## Run Calculation

 - [POST /sourcing-scenarios/run-selection](https://docs.luminovo.com/specs/bundled/sourcing-scenario/runsourcingcalculation.md): Triggers the sourcing selection calculation for the given scenarios.

Typical usage:
- Run for single scenario: {"type": "SourcingScenarios", "sourcing_scenario_ids": ["scenario-uuid"]} - runs selection for one specific scenario
- Multiple specific scenarios: {"type": "SourcingScenarios", "sourcing_scenario_ids": ["uuid1", "uuid2", "uuid3"]} - runs selection for multiple scenarios

Requirements:
- An empty sourcing_scenario_ids array will return a 400 Bad Request error.
- All sourcing scenarios must belong to the same RFQ. Scenarios from different RFQs will result in an error.

## Get Scenario

 - [GET /sourcing-scenarios/{id}](https://docs.luminovo.com/specs/bundled/sourcing-scenario/getsourcingscenariov2.md): Returns a sourcing scenario with its associated project, demands, and settings.

Project

A sourcing scenario is associated with a project, which is either an RFQ (Request for
Quotation) or a Negotiation. The project field is a tagged object with a type
field ("Rfq" or "Negotiation") and an id field containing the project's UUID.

Demands

Each demand item has a type field indicating its kind. Currently only "Assembly"
demands are returned, each with:
- id: the assembly's UUID
- name: the human-readable assembly designator
- quantity: the required quantity with unit of measurement (e.g., {"unit": "Pieces", "quantity": 1000.0})

Limitation: Part demands (for off-the-shelf parts and components/IPNs) are not yet
included in this endpoint and will be added as new type values in a future update.
Consumers should gracefully handle or ignore unknown demand types.

Currency and Exchange Rates

settings.currency.base_currency is the base currency used for all cost calculations in
this sourcing scenario. All monetary values are converted to this currency.

settings.currency.exchange_rates maps each foreign currency code to its conversion rate.
Rates are expressed as: 1 unit of base currency = rate units of foreign currency.

Each rate has an is_manual flag:
- true: the rate was manually overridden by a user and takes precedence over the automatic rate
- false: the rate was automatically fetched from a public exchange rate provider

The settings object is extensible — additional setting groups may be added alongside
currency in the future.

Versioning

> Note: A legacy v1 version of this endpoint is available by sending
> Accept: application/api.luminovo.sourcing-scenario-v1+json. It is deprecated and
> returns a less detailed response — it omits currency settings, assembly names, and project
> type information. All new integrations should use v2.

## Create Scenario (deprecated)

 - [POST /sourcing-scenarios](https://docs.luminovo.com/specs/bundled/sourcing-scenario/createsourcingscenario.md): Deprecated. This endpoint is deprecated and will be removed in a future version.

Create a new sourcing scenario corresponding to an RfQ.

## Update Scenario (deprecated)

 - [PATCH /sourcing-scenarios/{id}](https://docs.luminovo.com/specs/bundled/sourcing-scenario/updatesourcingscenario.md): Deprecated. This endpoint is deprecated and will be removed in a future version.

Updates a sourcing scenario based on its ID. All assemblies relating to the scenario must be
included in the request — only those in the request will be considered for the scenario.

