Saltar al contenido

API reference

The REST operations an agent uses, the usage limits and every error code.

View as Markdown

Endpoints

Base URL:

text
https://agents.avanzafibra.com
POST/ordersMCP tool order_create

Creates an order on behalf of a customer.

Requires orders:write

  • 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/draftsMCP tool draft_create

Leaves a configured draft and returns the customer's signed link (72 h).

Requires drafts:write

  • orders:write also opens it. The draft is the step before secure payment: payment_link_create takes it by draftId.
POST/payment-linksMCP tool payment_link_create

Creates the secure link (30 minutes) where the CUSTOMER types their IBAN. You never see it.

Requires orders:write

  • 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}/statusMCP tool payment_link_status

pending, completed or expired. On completed it returns paymentRef, the masked IBAN and the initials.

Requires orders:write

  • You only see your own links: any other answers 404.
POST/agent/payment-credentialsREST only

Delegated tokenization, server to server: an IBAN and holder in exchange for a paymentRef.

Requires payment:tokenize · Operation payment_credential_tokenize

  • 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}REST only

Returns the order. Requires ?token= with the order's accessToken.

Requires orders:write · Operation order_get

  • 404 if the token does not belong to the order.
GET/orders/{orderId}/statusMCP tool order_status_get

Order progress, without personal data.

Requires orders:write

  • Returns only orderId, status and updatedAt (plus installationStatus when it exists).
  • There is no anonymous access: it requires an agent credential.
GET/productsMCP tool products_list

The full catalog: fibre, mobile, TV, landline, alarms and packs.

Public, no credential needed

  • It is the same list that feeds the website. Load it once and reuse it.
GET/products/{id}MCP tool product_get

One product by identifier.

Public, no credential needed

POST/pricing/calculateMCP tool pricing_calculate

A quote for a configuration: the pricing engine, exactly as on the website.

Public, no credential needed

  • The total it returns is the one POST /orders will expect to receive.

Rate limits

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

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

Over a limit, the API answers 429 with AGENT_RATE_LIMITED. 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.

Errors

Every error has a code. The Retry column says whether repeating the same request can ever succeed.

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.

CodeMeaningRetry
PRICE_MISMATCHThe total you sent does not match the one the server calculates. No order is created.No
IDEMPOTENCY_KEY_EXPIREDThe key is more than 24 hours old. Nothing was created with it: generate a new key for the SAME cart.Yes
IDEMPOTENCY_KEY_REUSEDAn order may already exist with that key and different data. Do not regenerate the key: you would create the duplicate that idempotency prevents.No
ORDER_USER_CONFIRMATION_REQUIREDconditions.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).No
PAYMENT_REF_REQUIREDAn agent order requires paymentRef, just as the web checkout requires the IBAN. Create a payment link, wait for completed and resend with the reference.No
AGENT_RAW_IBAN_NOT_ALLOWEDThe order carries a raw IBAN. It is rejected without being stored or logged. Remove it and use paymentRef.No
PAYMENT_REF_INVALIDThe reference does not exist or is not yours. The answer is the same for both cases, on purpose.No
PAYMENT_REF_EXPIREDThe reference has expired. Create a new link: the customer has to type their IBAN again.No
PAYMENT_REF_ALREADY_REDEEMEDThe 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.No
PAYMENT_REF_QUOTE_MISMATCHThe 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.No
PAYMENT_REF_CUSTOMER_MISMATCHThe customer data in the order is not what the customer typed in the link. Send customer empty or with the same data.No
PAYMENT_HOLDER_MISMATCHThe 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.No
PAYMENT_HOLDER_REQUIREDThe 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.No
PAYMENT_REF_BINDING_MISMATCHThe order is not the configuration (draft or quote) the reference was bound to. Create another link for the correct order.No
PAYMENT_REF_REVOKEDThe reference was revoked and can no longer be used, for example after three holder refusals (PAYMENT_HOLDER_MISMATCH). Create a new link.No
AGENT_PAYMENTS_DISABLEDAgent payments are not enabled in this environment. There are no links or references and, while they stay off, order_create does not require paymentRef.No
PAYMENT_LINK_ALREADY_COMPLETEDThe customer has already completed this link. Call payment_link_status and use the paymentRef it returns; you do not need another link.No
PAYMENT_IBAN_INVALIDThe 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).No
PAYMENT_PERSONAL_DATA_INVALIDThe 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.No
PAYMENT_LINK_QUOTE_UNAVAILABLEThe link's configuration cannot be quoted (for example, no coverage or a discontinued product). Fix the configuration.No
PAYMENT_LINK_DRAFT_NOT_FOUNDThe draft does not exist or was not created by your credential. A link can only be created on your own drafts.No
PAYMENT_SECRET_UNREADABLEThe 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.No
PAYMENT_LINK_NOT_FOUNDThe link does not exist or does not belong to your credential.No
PAYMENT_LINK_EXPIREDThe link has expired (30 minutes). Create another.No
PAYMENT_LINK_LOCKEDThe link locked after several wrong IBANs. Create another.No
PAYMENT_RATE_LIMITEDToo many links or tokenizations per hour for your credential. Respect Retry-After.Yes
ANONYMOUS_RATE_LIMITEDMCP 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.Yes
AGENT_RATE_LIMITEDYou 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.Yes

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.

OpenAPI specification

The complete contract, with schemas and an interactive console, is the OpenAPI specification.

Personaliza tu tarifa