---
name: avanza-contratacion
description: Quote and contract fibre, mobile, TV and alarms at Avanza Fibra through the API.
---

# Avanza Fibra: contracting skill for agents

Avanza Fibra is a leading Spanish fibre-optic and mobile operator. This is its public contracting API for agents: the official surface, open to any agent operating in Spain, to quote and contract on behalf of a customer.

Follow this order; do not invent steps that are not here.

## Context

- What this is: the public, official Avanza Fibra tool for agents. It is not an internal API: anyone can request a credential and operate with it.
- Market: Spain. Own network in 40 municipalities of Murcia, Alicante, Valencia, Almería, Granada, Albacete and Cuenca; outside that coverage you cannot contract.
- Base: https://agents.avanzafibra.com
- Authentication: Authorization: Bearer <token>, with capabilities.
- Full specification: https://agents.avanzafibra.com/docs
- The server recalculates every total. Yours is a check, never the truth.

## Flow

- POST /orders (order_create, requires orders:write): Creates an order on behalf of a customer. The server RECALCULATES the total. The amount you send is a check, never the source of truth. If the total does not match the calculated one, it answers PRICE_MISMATCH and creates nothing. conditions.userConfirmedAt is required: the instant the CUSTOMER confirmed the conditions (ISO 8601, not in the future, at most 7 days old). Without it: ORDER_USER_CONFIRMATION_REQUIRED. paymentRef is required, just as the web checkout requires the IBAN: without it, PAYMENT_REF_REQUIRED. Never send customer.iban: AGENT_RAW_IBAN_NOT_ALLOWED. See "Payments without an IBAN". 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.
- POST /drafts (draft_create, requires drafts:write): Leaves a configured draft and returns the customer's signed link (72 h). orders:write also opens it. The draft is the step before secure payment: payment_link_create takes it by draftId.
- POST /payment-links (payment_link_create, requires orders:write): Creates the secure link (30 minutes) where the CUSTOMER types their IBAN. You never see it. Pass exactly one of draftId (a draft created by your same credential) or quote (configuration, network, packId, isEmpresa). collectPersonalData=true makes the link also collect name, ID number, email and phone: it is the recommended flow.
- GET /payment-links/{linkId}/status (payment_link_status, requires orders:write): pending, completed or expired. On completed it returns paymentRef, the masked IBAN and the initials. You only see your own links: any other answers 404.
- POST /agent/payment-credentials (payment_credential_tokenize, requires payment:tokenize): Delegated tokenization, server to server: an IBAN and holder in exchange for a paymentRef. It is NOT an MCP tool and the MCP rejects any IBAN in its arguments. Body: iban, holderName, bindTo ({ draftId } or { quoteFingerprint }) and ttlSec (maximum 1800).
- GET /orders/{orderId} (order_get, requires orders:write): Returns the order. Requires ?token= with the order's accessToken. 404 if the token does not belong to the order.
- GET /orders/{orderId}/status (order_status_get, requires orders:write): Order progress, without personal data. Returns only orderId, status and updatedAt (plus installationStatus when it exists). There is no anonymous access: it requires an agent credential.
- GET /products (products_list, public, no credential): The full catalog: fibre, mobile, TV, landline, alarms and packs. It is the same list that feeds the website. Load it once and reuse it.
- GET /products/{id} (product_get, public, no credential): One product by identifier.
- POST /pricing/calculate (pricing_calculate, public, no credential): A quote for a configuration: the pricing engine, exactly as on the website. The total it returns is the one POST /orders will expect to receive.

Order of use: load the catalog, quote the configuration, leave a draft, get payment through the secure link, create the order with its idempotency key and check the status while it is processed.

## Payments without an IBAN

The IBAN never passes through the agent. You receive a paymentRef: opaque, single-use, expiring, bound to your credential and to the specific quote. Only the server knows which account is behind it.

### Recommended flow: secure link (MCP or REST)

1. draft_create (POST /drafts) leaves the configuration and the customer contact.
2. payment_link_create (POST /payment-links) with draftId and collectPersonalData=true. It returns a 30-minute url.
3. Hand the url to the customer as is, through the channel where you talk to them. That page is not a conversation with you: they open it in their browser and type their IBAN and their details themselves.
4. payment_link_status (GET /payment-links/{linkId}/status) until it says completed. It returns paymentRef, the masked IBAN (ES** **** **** **** **** 1234) and the holder initials. Show the customer the masked one so they can confirm it is their account.
5. order_create (POST /orders) with paymentRef, claimedTotal and conditions.userConfirmedAt. Do not send customer.iban or the data the customer already typed in the link. If the link did not collect them, send the customer first name and surnames: the holder must share a surname with them.

### Platforms that already hold payment data: tokenization

1. Request a credential with payment:tokenize (granted separately and never by default).
2. From your server, POST /agent/payment-credentials with iban, holderName, bindTo and ttlSec. It answers a paymentRef.
3. Use it in order_create exactly like the one from the link. This operation does not exist as an MCP tool and the MCP rejects any IBAN in its arguments.

### Guarantees

- A paymentRef works for a single order (PAYMENT_REF_ALREADY_REDEEMED from the second attempt on).
- It expires after 30 minutes at most and is only accepted from the credential that originated it, for the quote it was bound to.
- If the order amounts are not the ones the customer saw, it is rejected (PAYMENT_REF_QUOTE_MISMATCH).
- The account holder must be the contracting person: they share at least one surname with the person on the order (for a company, they match the company name or the contact person). If someone else pays, that person should contract themselves through the secure link with collectPersonalData=true, or through the website: an agent cannot skip this check.
- The link locks after 5 wrong IBANs.
- Everything is kept in the order audit: who requested the payment, when and with which masked account.

While delegated payment is off on the server, order_create still accepts orders without paymentRef (what exists today); once it is turned on, it becomes required.

## 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.

## Errors

| Code | Retry | Meaning |
| --- | --- | --- |
| PRICE_MISMATCH | no | The total you sent does not match the one the server calculates. No order is created. |
| IDEMPOTENCY_KEY_EXPIRED | yes | The key is more than 24 hours old. Nothing was created with it: generate a new key for the SAME cart. |
| IDEMPOTENCY_KEY_REUSED | no | An order may already exist with that key and different data. Do not regenerate the key: you would create the duplicate that idempotency prevents. |
| ORDER_USER_CONFIRMATION_REQUIRED | no | conditions.userConfirmedAt is missing. Nothing is created. Ask the customer to confirm the conditions and resend with that instant (ISO 8601, not in the future, at most 7 days old). |
| PAYMENT_REF_REQUIRED | no | An agent order requires paymentRef, just as the web checkout requires the IBAN. Create a payment link, wait for completed and resend with the reference. |
| AGENT_RAW_IBAN_NOT_ALLOWED | no | The order carries a raw IBAN. It is rejected without being stored or logged. Remove it and use paymentRef. |
| PAYMENT_REF_INVALID | no | The reference does not exist or is not yours. The answer is the same for both cases, on purpose. |
| PAYMENT_REF_EXPIRED | no | The reference has expired. Create a new link: the customer has to type their IBAN again. |
| PAYMENT_REF_ALREADY_REDEEMED | no | The reference has already backed an order. It is single-use. If this is a retry of that same order, repeat it with the same idempotency-key and you will receive the original. |
| PAYMENT_REF_QUOTE_MISMATCH | no | The order does not match the quote or draft the reference was bound to, or the amounts the customer saw. Create another link for the correct order. |
| PAYMENT_REF_CUSTOMER_MISMATCH | no | The customer data in the order is not what the customer typed in the link. Send customer empty or with the same data. |
| PAYMENT_HOLDER_MISMATCH | no | The account holder shares no surname with the customer (sharing only the first name is not enough); for a company, the holder matches neither the company name nor the contact person (generic words such as CONSTRUCCIONES, SERVICIOS or GRUPO do not count). On the third refusal with the same reference, it is revoked (PAYMENT_REF_REVOKED): names cannot be guessed. Another account is needed. |
| PAYMENT_HOLDER_REQUIRED | no | The order does not name the contracting person (first name AND surnames are needed; for a company, the company name is enough), so the holder cannot be checked. If the link did not collect personal data, send them in customer; if it did, they are taken from the link. |
| PAYMENT_REF_BINDING_MISMATCH | no | The order is not the configuration (draft or quote) the reference was bound to. Create another link for the correct order. |
| PAYMENT_REF_REVOKED | no | The reference was revoked and can no longer be used, for example after three holder refusals (PAYMENT_HOLDER_MISMATCH). Create a new link. |
| AGENT_PAYMENTS_DISABLED | no | Agent payments are not enabled in this environment. There are no links or references and, while they stay off, order_create does not require paymentRef. |
| PAYMENT_LINK_ALREADY_COMPLETED | no | The customer has already completed this link. Call payment_link_status and use the paymentRef it returns; you do not need another link. |
| PAYMENT_IBAN_INVALID | no | The IBAN the customer typed is not valid (format, country, length or check digits). The customer sees it on their page with the attempts they have left; after five, the link locks (PAYMENT_LINK_LOCKED). |
| PAYMENT_PERSONAL_DATA_INVALID | no | The personal data the customer typed in the link is not valid (for example, the ID number or NIE). They fix it themselves on the same page. |
| PAYMENT_LINK_QUOTE_UNAVAILABLE | no | The link's configuration cannot be quoted (for example, no coverage or a discontinued product). Fix the configuration. |
| PAYMENT_LINK_DRAFT_NOT_FOUND | no | The draft does not exist or was not created by your credential. A link can only be created on your own drafts. |
| PAYMENT_SECRET_UNREADABLE | no | The account stored for that reference cannot be read (an incident on our side, not yours). Create a new link; if it happens again, let us know. |
| PAYMENT_LINK_NOT_FOUND | no | The link does not exist or does not belong to your credential. |
| PAYMENT_LINK_EXPIRED | no | The link has expired (30 minutes). Create another. |
| PAYMENT_LINK_LOCKED | no | The link locked after several wrong IBANs. Create another. |
| PAYMENT_RATE_LIMITED | yes | Too many links or tokenizations per hour for your credential. Respect Retry-After. |
| ANONYMOUS_RATE_LIMITED | yes | MCP only, and only without a credential. It has two variants: the per-client cap (you have used up your public reads) and the shared budget of one tool across all anonymous callers ("too many calls without a credential to this tool, from all anonymous callers together"). Either way the response says how many seconds to wait. With a credential, neither applies. |
| AGENT_RATE_LIMITED | yes | You have exceeded your credential limit. There is no effect: the request is rejected before the handler, with no order and no idempotency row. Respect Retry-After. |

## Limits

- Orders per day: 50. Per credential label, in a UTC calendar day. Fixed window aligned to midnight.
- Reads per minute: 600. Per credential label. Fixed window aligned to the minute.
- Order status: 120 / min. The status endpoint's own limit, on top of the previous one.
- Messages per JSON-RPC batch (MCP): 20. A batch with more messages is rejected as a whole.
- Payment links per hour: 30. Per credential label. Each link lasts 30 minutes at most.
- Tokenizations per hour: 60. Per credential label that holds payment:tokenize.

Limits apply per credential label. They never count the anonymous or personal funnel.

## Requesting a credential

Any agent can operate this API with a credential. You request the credential by email and a person issues it: there is no automatic sign-up.

- Write to info@avanzafibra.com with your company, the use case and the expected daily volume.
- Say which capabilities you need: catalog:read to check coverage, orders:write to contract and pay through a secure link. Quotes and the catalog need no credential. Do not ask for personal-data:read if you do not need it. payment:tokenize only if your platform already holds payment data.
- You receive the credential with its limits and an expiry date (90 days by default for new integrators).
- Rotate before it expires: request a new credential, change the token in your client and ask for the old one to be revoked.

## Out of scope

- The MCP is at https://agents.avanzafibra.com/mcp, on the same host as this API, and it is public: any MCP client can connect, list the tools and call eight public reads without a credential (products_list, product_get, packs_list, packs_applicable, pricing_calculate, discount_validate, campaign_info and worker_public_profile), with usage caps per client and per tool. Everything else requires the agent's own credential in the Authorization header: coverage, drafts, orders and secure payment links. No write tool is anonymous.
- Orders, secure-link payment and follow-up are also available as MCP tools. Payment goes through the secure link the customer opens or through the paymentRef that link returns; no tool accepts an IBAN. IBAN tokenization does not exist over MCP: only over REST, server to server, with payment:tokenize.
- No agent ever sees a full IBAN, not even its own customer's. The API always returns the masked account.
- Coverage is not an anonymous query: it would reveal where Avanza Fibra has network. You query it with a credential that carries catalog:read, and the order is resolved on the server with the address it carries.
- With WebMCP on, the website (and the contracting funnel, if it also has it on) exposes tools to browser agents (WebMCP section). Those tools prepare the order but do not confirm it: full contracting by an agent still goes through the API.
- An order created by an agent reaches the panel with its origin and its label, and goes through the same checks as a human one.

## 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.

- buscar_direccion (any page of avanzafibra.com): Searches towns and streets with the coverage autocomplete.
- comprobar_cobertura (any page of avanzafibra.com): Checks whether an address has fibre, with the same states as the website.
- listar_tarifas (any page of avanzafibra.com): Lists fibre, mobile, TV, landline and packs with the current catalog prices.
- calcular_presupuesto (any page of avanzafibra.com): Calculates the monthly quote with the server pricing engine.
- promocion_vigente (any page of avanzafibra.com): Returns the current promotion and its conditions.
- empezar_contratacion (any page of avanzafibra.com): Takes the user to the contracting funnel with the configuration already chosen.

- 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.

## Capabilities

- catalog:read: Check coverage and search addresses. The other catalog reads (products, packs, quotes) are public and need no capability.
- drafts:write: Leave a configured draft with its signed link so the customer can finish it.
- orders:write: Create an order on behalf of a customer, follow its status and create secure payment links.
- orders:read: Read the order list and detail and the metrics, without full ID numbers or IBANs.
- personal-data:read: Read the personal data of an order (address, contact) and the rest of the administration reads.
- admin:write: The administration writes that are considered safe.
- payment:tokenize: Tokenize a customer's IBAN from the agent platform's server (POST /agent/payment-credentials).

