---
title: "The contract"
status: "Signed off 26-10-2026 · the signed-off copy is in History"
updated: "15-10-2026"
toc: true
---

# The contract

<p class="lead">The contract is the calculator's own API: what the page, a portal or eRegulations sends, and what comes back. Whichever provider computes, ASYCUDA, Rwanda's portal or our engine, the page sees only this. Here it is, with a real Burundi estimate.</p>

<div class="rule">

**Why a contract of our own.** OBR's service takes one currency for the whole shipment and eRegulations v7 hands back figures that are not exact. Our contract carries a currency on every amount and exact decimals. Each provider has an adapter that translates to and from it, so no customs service is ever asked to change (D23). This page is the first draft; step 4 fixes every field.

</div>

## Four operations

| Operation | Request | Answers |
|---|---|---|
| Search a product | `GET /api/v1/search?q=riz&lang=fr` | Codes, descriptions (with translations, D35), units |
| One product | `GET /api/v1/commodity/10062000000` | The code, its units, any additional variable it needs |
| A reference list | `GET /api/v1/reference/currencies` | Countries, currencies, regimes, treatments, packages, delivery terms |
| An estimate | `POST /api/v1/estimate` | Every charge with its base, rate and amount, the total, where it came from |

All four answer in JSON. Amounts are strings holding exact decimals, so `"53184540.00"` is never rounded on the way. Every amount says its currency.

## An estimate, from start to finish

Husked rice from Pakistan into Burundi: invoice 50 000 000 BIF, external freight 2 000 000, insurance 500 000, 25 000 kg in 500 cartons. The request below is ours; OBR's real answer of 30-09-2026 is translated back into ours underneath.

### What the page sends

```json
{
  "flow": "import",
  "regime": "4",
  "commodity": "10062000000",
  "origin": "PK",
  "treatment": null,
  "quantities": [{ "value": "25000", "unit": "KGM" }],
  "weightGross": "25000",
  "packages": { "count": 500, "type": "CT" },
  "amounts": {
    "invoice":         { "value": "50000000", "currency": "BIF" },
    "externalFreight": { "value": "2000000",  "currency": "BIF" },
    "internalFreight": { "value": "0",        "currency": "BIF" },
    "insurance":       { "value": "500000",   "currency": "BIF" }
  },
  "resultCurrency": "BIF",
  "lang": "fr"
}
```

### What the ASYCUDA adapter sends to OBR

The adapter turns ours into OBR's shape: one currency for the whole declaration, the country's fixed values from the installation's settings (procedure `4000`, national procedure `000`, destination `BI`, CIF), and nothing the trader did not give.

```json
{
  "declarationType": "IM", "declarationProcedure": "4",
  "exportCountry": "PK", "destinationCountry": "BI",
  "deliveryTerms": "CIF", "currencyCode": "BIF",
  "items": [{
    "commodityCode": "10062000000", "originCountry": "PK",
    "invoiceAmount": 50000000, "externalFreightAmount": 2000000,
    "internalFreightAmount": 0, "insuranceAmount": 500000,
    "quantity": 25000, "weightGross": 25000,
    "packagesNumber": 500, "packagesType": "CT",
    "extendedProcedure": "4000", "nationalProcedure": "000"
  }]
}
```

Had the invoice been in USD and the freight in KES, the adapter would first convert both into one currency with OBR's own rates, and say so in the answer. That is what eRegulations v7 already does (ERN-1235).

### What comes back to the page

OBR answered 53 184 540 BIF in nine charges: eight on the rice, and the declaration's flat form fee. Translated into ours:

```json
{
  "provider": "asycuda",
  "source": "OBR tariff API",
  "answeredAt": "2026-09-30T17:25:00+02:00",
  "indicative": false,
  "customsValue": { "value": "52500000.00", "currency": "BIF" },
  "total":        { "value": "53184540.00", "currency": "BIF" },
  "totalLocal":   { "value": "53184540.00", "currency": "BIF" },
  "rate": { "from": "BIF", "to": "BIF", "value": "1", "date": "2026-09-30", "source": "OBR" },
  "charges": [
    { "code": "DDI", "name": "Droit de douane à l'importation",
      "base": "52500000.00", "rate": { "kind": "percent", "value": "75" },  "amount": "39375000.00" },
    { "code": "RAD", "name": "Redevance administrative",
      "base": "52500000.00", "rate": { "kind": "percent", "value": "1" },   "amount": "525000.00" },
    { "code": "FIP", "name": "Financement infrastructure publique",
      "base": "52500000.00", "rate": { "kind": "percent", "value": "1.5" }, "amount": "0.00", "exempt": true },
    { "code": "TSR", "name": "Taxe de sûreté",
      "base": "52500000.00", "rate": { "kind": "percent", "value": "2" },   "amount": "1050000.00" },
    { "code": "PFR", "name": "Prélèvement forfaitaire",
      "base": "52500000.00", "rate": { "kind": "percent", "value": "3" },   "amount": "1575000.00" },
    { "code": "RIF", "name": "Redevance informatique",
      "base": "52500000.00", "rate": { "kind": "percent", "value": "0.25" },"amount": "131250.00" },
    { "code": "RIR", "name": "Redevance d'intégration régionale",
      "base": "52500000.00", "rate": { "kind": "percent", "value": "2" },   "amount": "1050000.00" },
    { "code": "TVA", "name": "Taxe sur la valeur ajoutée",
      "base": "94631250.00", "rate": { "kind": "percent", "value": "10" },  "amount": "9463125.00" },
    { "code": "DMC", "name": "Vente des chemises déclarations", "level": "declaration",
      "rate": { "kind": "flat", "value": "5", "currency": "USD", "at": "3032.9106" }, "amount": "15164.55" }
  ],
  "messages": [],
  "notices": [ "estimate" ]
}
```

Four things the translation does that the customs answer does not:

- **FIP is marked exempt.** OBR sends a nominal rate of 1.5 with an applied rate of 0; the adapter keeps the zero and flags it, never the 1.5 (the prototype's lesson on zeros).
- **DMC is marked flat.** OBR puts "5" in the same field as the percentages; 5 US dollars at 3 032.91 is the amount, so the adapter says "flat, 5 USD".
- **RIR is shown as OBR charged it.** Pakistan is outside the African Union, so here it is due. Where OBR charges it on an exempt origin, the register of known defects says so; the adapter still never corrects it (D4).
- **The rate carries its date and source** (D47), and a total in another currency would come with the local one beside it (D46).

### When it does not work

```json
{ "error": "refused",   "provider": "asycuda", "fields": { "items[0].weightGross": "Required" } }
{ "error": "unavailable", "provider": "asycuda", "since": "2026-09-30T20:20:00+02:00" }
{ "error": "not-found", "commodity": "99999999999" }
```

A refusal names the field so the page can show it there; "unavailable" carries the time the probe first failed; an unknown code is refused before anything is sent to customs (module 1).

## How it differs from what exists

| | OBR's API | eRegulations v7's API | The calculator's contract |
|---|---|---|---|
| Currency | One per declaration | One per request; since 29-09-2026 the page converts each amount first, with a rate list up to 7 days old | One per amount |
| Numbers | Floating point | `int` in, `float` out | Exact decimals, as strings |
| Flat charges | Look like percentages | The same | Marked `flat`, with their currency |
| Exempt charges | Nominal rate, zero applied | The same | Marked `exempt` |
| Where it came from | Not said | Not said | Provider, time, rate date, tariff version when computed |
| Exports | `EX` in the same call | `EX` in the same call, since 7.6.22 (01-10-2026) | `"flow": "export"` |

## Still open for step 4

- The exact names of every field, and a published schema.
- How a computed answer carries its measures and legal acts line by line (module 5's trace).
- How long an address may ask, and the cap on customs calls (?33).
- Which origin an export line carries: v7 sends the installation's country as origin and exporter, and OBR accepts it (01-10-2026); RRA refuses a re-export so sent ("Country of origin cannot be RW", 13-10-2026).

<details class="sources">
<summary>Sources</summary>

- OBR's live answer, through the Burundi trade portal's public API (`infocommerce.obr.bi/api/tariffs/estimate`), 30-09-2026: the rice case above, one call.
- RRA's OpenAPI for the ASYCUDA tariff API: `EstimateInput`, `EstimateResult`, `EstimateTax`.
- eRegulations v7's `TariffsModel.cs` and `TariffsController.cs`; ticket ERN-1235 for the conversion of amounts.
- The prototype's `docs/BURUNDI.md` §5 on flat charges and zeros, and its August total of 53 184 493,74 BIF, since moved by the dollar's rate.
- Asked for by Mehdi Benmoumen on 30-09-2026: "where is the contract?"

</details>
