# eSIM.bar — Public API and MCP integration

## HTTP API
Base URL: `https://esim.bar/api/public/v1/`. Public sales point: `_SEDPB4EUS4XUV4Y`.
Send `X-Point-Id: _SEDPB4EUS4XUV4Y` with every request. Offer prices and purchases use RUB.
For English product names, send `Accept-Language: en`.

1. Search the current catalog: `GET catalog/search/?type=esim_plan&currency=RUB&country=EG&paginated=1&limit=25&offset=0`.
2. Read the offer conditions, product attributes and linked public campaigns.
3. Validate the cart and calculate its cost with `POST orders/validate-cart/`.
4. Give the buyer a purchase link: `https://esim.bar/en/checkout/ai/?offer_id=<UUID>&quantity=1`.
Add `period_days` for a selectable duration and `campaign_id` for an explicitly selected campaign.
Use `/ru/checkout/ai/` for Russian checkout.
The buyer enters their email, accepts the required consents and pays on the website.

Example request body for a daily plan:
```json
{"currency_code":"RUB","language_code":"en","items":[{"offer_id":"<UUID>","quantity":1,"fields":{"period_days":7}}]}
```
Omit `fields.period_days` for a fixed-duration package. For a campaign, add `campaign_id` at the top level.
Send `promo_code` only when the buyer supplies a code. Keep promotion codes out of URLs.

## Plan prices and conditions
`price` is the base price. When `pricing.selectable_period=true`, it is the price per day.
The full amount for the selected quantity and duration, including fees and discounts, is the quote's `total_amount`.
`data_allowance_behavior=total` means a total data allowance. `daily_cutoff` means a daily allowance,
`daily_throttle` means a daily full-speed allowance followed by throttling,
and `daily_unlimited` means no stated daily quota. Check the FUP and `post_allowance_speed_bps`.
`activation_policy` determines when the plan starts. A missing field means the condition is unconfirmed.
CSV `country` uses OR. `min_price` sorts by base price, which may be a daily rate.
Verify the list of covered countries before claiming coverage for a whole itinerary.

`offers[].campaigns` contains campaign links. Calculate the selected configuration to confirm its price.
Campaigns restricted by account, email or new-customer status are checked on the website.
Do not guess private promotion codes or promise personal discounts without verification. The API checks compatibility rules.
`valid=false` and errors 400/403/404/409/422 mean the selected configuration cannot be promised as available to purchase.
For 429, respect Retry-After. For 5xx, retry later with a delay.
Quotes are preliminary. Price and availability are checked again at checkout.
Calculation creates no order or campaign reservation. The API may record technical validation events.

## MCP
URL: `https://esim.bar/mcp`. Transport: `Streamable HTTP`. Buyer authentication is not required.
Add a remote server with this URL and transport in your MCP client's settings.
The server exposes `search_catalog`, `get_offer`, `quote_cart` and their schemas through MCP.
`quote_cart` validates the cart and calculates its cost through `orders/validate-cart/`. It checks parameters, selected duration, purchase limits and promotion eligibility, then returns the full amount and a `purchase_url` for the selected configuration.
Pass `language="en"` or `language="ru"` to select the language of the data and purchase link.
The sales point and RUB currency are set by the server. Tools do not accept email or existing eSIM details.
If the selected campaign is rejected, ask the buyer to check its conditions on the website or choose an ordinary purchase.

## Response data
Use prices, plan conditions and available campaigns in buyer-facing responses.
Cost and margin fields in HTTP offer details are intended for internal accounting.
Keep orders, customer information and eSIM profile details out of tool inputs.

Documentation: `https://esim.bar/developers/agents/?lang=en`.
OpenAPI: `https://esim.bar/developers/agents/openapi.json?lang=en`.

## MCP response fields

`tools/list` includes a description for every argument and a nested `outputSchema` for each tool.

- `search_catalog` returns `count`, the total matching products, `limit`, the page size, `offset`, the number skipped, and `results`, the current products. Each product includes `id`, its UUID, `title`, the original title, `display_title`, the localized title, `type`, the product type, `region`, geographic coverage, `attributes`, plan conditions, and `offers`, available offers. Each offer includes `id`, its UUID for quotation, `price`, the base price, `currency`, the currency code, `price_basis`, either `day` or `package`, `pricing`, selectable duration rules, and `campaigns`, linked campaign UUIDs.
- `get_offer` returns `offer`, the selected offer, `product`, its conditions and available offers, and `campaigns`, public conditions of linked campaigns. API and MCP response schemas describe individual plan attributes and campaign conditions. Missing fields mean unknown values.
- `quote_cart` returns `offer_id`, the selected offer, `quantity`, the number of separate eSIMs, `period_days`, daily plan duration or null for a fixed package, `currency`, the quote currency, `subtotal_amount`, the amount before fees and discounts, `fee_amount`, fees, `discount_amount`, the discount, and `total_amount`, the full payable amount. `campaign` appears when a campaign applies and describes its conditions, `groups_count`, the applied group count, and `reward_units_count`, the reward unit count. `preliminary=true` identifies a preliminary quote, `quoted_at` is the UTC quote time, and `purchase_url` opens website checkout for the selected variant. The final amount is checked again before payment.
