Saltar al contenido

How agents work with Avanza Fibra

An agent quotes, checks coverage, leaves a draft, gets payment through a secure link and creates the order. The server recalculates every total and the customer confirms the conditions.

View as Markdown

The contracting flow

  1. Read the catalog

    Load the catalog once and reuse it to choose what to quote.

    products_list GET /products List the public catalog: fibre, mobile, TV, landline, alarms and packs.

  2. Quote the configuration

    Send the chosen configuration to the pricing engine. Keep the total it returns: it is the one the order will expect.

    pricing_calculate POST /pricing/calculate Quote a configuration with the pricing engine. The total is the one order_create expects.

  3. Check coverage

    Check the installation address before you promise fibre.

    coverage_check Check whether an address has fibre coverage. Needs catalog:read.

  4. Leave a draft

    Save the configuration as a draft and keep the signed link for the customer.

    draft_create POST /drafts Leave a configured draft and get the customer's signed link (72 h). orders:write also opens it. Needs drafts:write.

  5. Create the secure payment link

    Create the link from the draft and hand it to the customer. They type the IBAN there, not you.

    payment_link_create POST /payment-links Create the secure link (30 minutes) the customer opens to type their IBAN. You never see it. Needs orders:write.

  6. Check the payment link

    Poll the link until it is completed, then keep the paymentRef it returns.

    payment_link_status GET /payment-links/{linkId}/status Check a payment link: pending, completed or expired. On completed it returns paymentRef and the masked IBAN. Needs orders:write.

  7. Create the order

    Send the order with the paymentRef, the quoted total and the instant the customer confirmed the conditions.

    order_create POST /orders Create an order on behalf of a customer. Requires paymentRef and conditions.userConfirmedAt; accepts an idempotency key. Needs orders:write.

Then follow the order with order_status_get while it is processed.

Idempotency

Send the same key on every attempt of the same purchase.

http
POST /orders
Authorization: Bearer <token>
idempotency-key: <uuid>
content-type: application/json
  • The idempotency-key header is optional but recommended: without it the order is still created, with no protection against a retry.
  • A retry with the same key returns the original order with 200 and the Idempotency-Replayed: true header. Over MCP, the response always includes replay (boolean) and, when it is true, replayNote explains (in Spanish) that nothing new was created.
  • IDEMPOTENCY_KEY_EXPIRED: The key is more than 24 hours old. Nothing was created with it: generate a new key for the SAME cart.
  • IDEMPOTENCY_KEY_REUSED: An order may already exist with that key and different data. Do not regenerate the key: you would create the duplicate that idempotency prevents.

Rules

Always send an idempotency key

The idempotency-key header is optional for the server, but without it a retry after a lost response creates a second order. The same purchase carries the SAME key in all its attempts and the retry returns the original order. The replay window is 24 hours.

Retry only what can be retried

PRICE_MISMATCH, IDEMPOTENCY_KEY_REUSED and the 4xx validation errors do not improve when repeated: they give the same result. AGENT_RATE_LIMITED, 5xx responses and network errors do make sense to retry.

Never send personal data to logs

ID numbers, IBANs and full addresses do not go to logs, traces or error messages. The API masks them in its own output; an agent must not reintroduce them anywhere else. The IBAN, moreover, never passes through your hands: the customer types it in the secure link (see "Payments without an IBAN").

Do not trust the total you calculate

The authoritative amount is the one the server sets. An agent that builds its own price and sends it as truth receives PRICE_MISMATCH, and that is the correct behavior.

Where the customer finishes

The agent never completes the customer's part.

  • The draft link opens the contracting funnel at https://pedido.avanzafibra.com so the customer can review and finish.
  • The secure payment link is where the customer types their IBAN and, with collectPersonalData=true, their personal details. The agent never types or sees the IBAN. See Payments without an IBAN.
  • The customer confirms the conditions: your order carries that instant in conditions.userConfirmedAt.

In the browser (WebMCP)

WebMCP-compatible browsers discover tools with a strict schema on the pages of avanzafibra.com, instead of reading the screen and pressing buttons. Each tool uses the same endpoints as the interface.

Available in browsers that expose document.modelContext (Chrome with the origin trial or with the chrome://flags/#enable-webmcp-testing flag). Without that support nothing is registered.

ToolWhereWhat it does
buscar_direccionany page of avanzafibra.comSearches towns and streets with the coverage autocomplete.
comprobar_coberturaany page of avanzafibra.comChecks whether an address has fibre, with the same states as the website.
listar_tarifasany page of avanzafibra.comLists fibre, mobile, TV, landline and packs with the current catalog prices.
calcular_presupuestoany page of avanzafibra.comCalculates the monthly quote with the server pricing engine.
promocion_vigenteany page of avanzafibra.comReturns the current promotion and its conditions.
empezar_contratacionany page of avanzafibra.comTakes the user to the contracting funnel with the configuration already chosen.

What no tool does

  • No tool submits the order, accepts conditions or signs: the final confirmation is always a click by the user.
  • No tool asks for or fills in name, ID number, IBAN, email or phone: the user types them.
  • The address tools (street, town, postal code, number) use the address the agent gives only to check coverage and prefill the order; the user reviews it. The address and the cart are saved when the tab closes, whether or not the user accepted the data processing, just as if the customer typed them; only commercial messages depend on consent.
  • The tools that remove or replace something already chosen (cart products, address, mobile line options, the order open in the funnel) reject it unless the agent passes sustituir: true, and they are marked as consequential so the browser asks for confirmation. A draft only opens with an empty order and no earlier content in the page session.
  • The tools only exist while the page is open in a WebMCP-compatible browser.
Personaliza tu tarifa