{
  "info": {
    "name": "Fliinow Partner API",
    "description": "Partner API de Fliinow (v1.13.0).\n\nAutenticación: cabecera `X-Fliinow-API-Key` (variable `api_key`).\nBase URL: demo `https://demo.fliinow.com/integration-api/v1`, prod `https://app.fliinow.com/integration-api/v1`.\n\nManejo de errores: ramifica siempre sobre `errorCode`; si es `VALIDATION_ERROR`, el detalle campo a campo está en `validationErrors`. Nunca parsees `message`.\n\nFechas: en el cuerpo `dd-MM-yyyy`; en los parámetros de consulta (from, to) `yyyy-MM-dd`.\n\nFlujo sugerido: 1) Crear operación (guarda operation_id) -> 2) Simular/consultar financiación -> 3) Crear financiación -> el cliente completa el checkout -> webhooks.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "apikey",
    "apikey": [
      {
        "key": "key",
        "value": "X-Fliinow-API-Key",
        "type": "string"
      },
      {
        "key": "value",
        "value": "{{api_key}}",
        "type": "string"
      },
      {
        "key": "in",
        "value": "header",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://demo.fliinow.com/integration-api/v1"
    },
    {
      "key": "api_key",
      "value": ""
    },
    {
      "key": "external_id",
      "value": "BOOK-2026-00123"
    },
    {
      "key": "operation_id",
      "value": ""
    },
    {
      "key": "financial_offer_id",
      "value": "1"
    },
    {
      "key": "event_id",
      "value": "1"
    },
    {
      "key": "agency_id",
      "value": "",
      "type": "string",
      "description": "Only for management group API keys: id of the agency you act on behalf of (sent as X-Fliinow-Agency). Discover valid ids with GET /agencies."
    }
  ],
  "item": [
    {
      "name": "Health",
      "item": [
        {
          "name": "Health check",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/health",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "health"
              ]
            },
            "description": "Verifica conectividad y devuelve la versión de la API y tu partnerCode."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Agencies",
      "description": "Agency discovery for management group API keys.",
      "item": [
        {
          "name": "List group agencies",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/agencies",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "agencies"
              ]
            },
            "description": "Returns the active agencies of the management group your API key can act on behalf of. Only relevant for management group keys. This is the ONLY endpoint that does not require the X-Fliinow-Agency header: the returned ids are the valid values for that header on every other request. Each agency carries availableCountries: the valid values of client.countryCode for it."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Operations",
      "item": [
        {
          "name": "Create operation",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/operations",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "operations"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"externalId\": \"{{external_id}}\",\n  \"client\": {\n    \"firstName\": \"Juan\",\n    \"lastName\": \"García López\",\n    \"email\": \"juan.garcia@email.com\",\n    \"documentId\": \"12345678Z\",\n    \"documentValidityDate\": \"31-12-2030\",\n    \"gender\": \"MALE\",\n    \"prefix\": \"+34\",\n    \"phone\": \"612345678\",\n    \"nationality\": \"ESP\",\n    \"birthDate\": \"15-03-1985\",\n    \"address\": \"Calle Mayor 1\",\n    \"postalCode\": \"28001\",\n    \"city\": \"Madrid\",\n    \"countryCode\": \"ESP\"\n  },\n  \"packageName\": \"Cancún All Inclusive\",\n  \"packageTravel\": false,\n  \"travelersNumber\": 2,\n  \"hotels\": [\n    {\n      \"hotelName\": \"Hotel Caribe\",\n      \"address\": \"Av. Kukulcán 10\",\n      \"postalCode\": \"77500\",\n      \"city\": \"Cancún\",\n      \"country\": \"MEX\",\n      \"guestsNumber\": 2,\n      \"checkInDate\": \"15-03-2027\",\n      \"checkOutDate\": \"20-03-2027\",\n      \"isRefundable\": true,\n      \"price\": 1275.0\n    }\n  ],\n  \"successRedirectUrl\": \"https://example.com/booking/success\",\n  \"errorRedirectUrl\": \"https://example.com/booking/error\",\n  \"webhookUrl\": \"https://example.com/webhooks/operations\",\n  \"totalPrice\": 1275.0\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "Crea cliente + operación. Idempotente por externalId. 400: VALIDATION_ERROR / INVALID_CLIENT / INVALID_OPERATION / INVALID_FLIGHT / INVALID_HOTEL / INVALID_SERVICE. 409: NOT_ELIGIBLE_FOR_FINANCING (ninguna oferta puede financiarla, también si ninguna tiene uno de los plazos de allowedInstallments). 422: UNSUPPORTED_COUNTRY (client.countryCode, país de RESIDENCIA y no nacionalidad, que la agencia no financia; ver availableCountries en GET /agencies). allowedInstallments (opcional, p. ej. [3, 6, 12]) limita las ofertas de la operación a esos números de cuotas."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const ok = pm.response.code === 201;",
                  "pm.test('201 Created', () => pm.expect(pm.response.code).to.eql(201));",
                  "if (ok) {",
                  "  const b = pm.response.json();",
                  "  pm.collectionVariables.set('operation_id', b.id);",
                  "  pm.test('operation id captured', () => pm.expect(b.id).to.be.a('string'));",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "List operations",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/operations?page=0&size=50&status=&from=&to=",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "operations"
              ],
              "query": [
                {
                  "key": "page",
                  "value": "0"
                },
                {
                  "key": "size",
                  "value": "50"
                },
                {
                  "key": "status",
                  "value": "",
                  "disabled": true
                },
                {
                  "key": "from",
                  "value": "",
                  "disabled": true
                },
                {
                  "key": "to",
                  "value": "",
                  "disabled": true
                }
              ]
            },
            "description": "Lista paginada, orden createdAt DESC. status: uno de los estados; from/to en yyyy-MM-dd. 400: VALIDATION_ERROR."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "Get operation",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/operations/{{operation_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "operations",
                "{{operation_id}}"
              ]
            },
            "description": "Detalle de la operación. Soporta If-None-Match (304). 403: OPERATION_ACCESS_DENIED. 404: OPERATION_NOT_FOUND."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "Get operation by external ID",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/operations/by-external-id/{{external_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "operations",
                "by-external-id",
                "{{external_id}}"
              ]
            },
            "description": "Recupera por tu referencia. 404: OPERATION_NOT_FOUND."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "Get operation status",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/operations/{{operation_id}}/status",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "operations",
                "{{operation_id}}",
                "status"
              ]
            },
            "description": "Estado ligero para polling. Soporta If-None-Match (304). 403: OPERATION_ACCESS_DENIED. 404: OPERATION_NOT_FOUND."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "Cancel operation",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/operations/{{operation_id}}/cancel",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "operations",
                "{{operation_id}}",
                "cancel"
              ]
            },
            "description": "Cancela una operación GENERATED, PENDING o CLIENT_REQUESTED (esta, antes en la financiera). 204 sin cuerpo. 409: OPERATION_NOT_CANCELLABLE (estado no cancelable, la financiera no la cancela, o additionalInfo.reason = ALREADY_APPROVED si el cliente acaba de completar la financiación). 404: OPERATION_NOT_FOUND (no existe o es de otra agencia)."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('204 No Content', () => pm.response.to.have.status(204));"
                ]
              }
            }
          ]
        },
        {
          "name": "Get refund details",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/operations/{{operation_id}}/refund/details?amountToRefund=250.00&agencyCancellationFee=20.00&providerCancellationFee=10.00",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "operations",
                "{{operation_id}}",
                "refund",
                "details"
              ],
              "query": [
                {
                  "key": "amountToRefund",
                  "value": "250.00",
                  "description": "Parte del precio a reembolsar. Sin él, todo lo que queda.",
                  "disabled": true
                },
                {
                  "key": "agencyCancellationFee",
                  "value": "20.00",
                  "description": "Gastos que retiene la agencia.",
                  "disabled": true
                },
                {
                  "key": "providerCancellationFee",
                  "value": "10.00",
                  "description": "Gastos que retiene el proveedor del viaje.",
                  "disabled": true
                }
              ]
            },
            "description": "Desglose de lo que recuperaría el cliente si se hiciera ahora el reembolso de los parámetros (todos opcionales; sin ellos, reembolsar todo lo que queda). 200 con totalToRefund, refundableAmount, waivedFliinowFee, remainingRefundableAmount, refundType… 400: VALIDATION_ERROR. 404: OPERATION_NOT_FOUND. 409: OPERATION_NOT_REFUNDABLE. 422: REFUND_NOT_AVAILABLE. 503: REFUND_NOT_SUPPORTED."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "Refund operation",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/operations/{{operation_id}}/refund",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "operations",
                "{{operation_id}}",
                "refund"
              ]
            },
            "description": "Reembolsa una operación CONFIRMED, total o parcialmente (cuerpo opcional; sin amountToRefund se reembolsa todo lo que queda). Un parcial la deja CONFIRMED y no envía webhook; el que reembolsa todo la deja REFUNDED. 204 sin cuerpo. 400: VALIDATION_ERROR. 404: OPERATION_NOT_FOUND. 409: OPERATION_NOT_REFUNDABLE o REQUEST_IN_PROGRESS. 422: REFUND_NOT_AVAILABLE u OPERATION_NOT_REFUNDABLE (la financiera lo rechazó). 500: falló la financiera, se puede reintentar. 503: REFUND_NOT_SUPPORTED.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"amountToRefund\": 250.0,\n  \"agencyCancellationFee\": 20.0,\n  \"providerCancellationFee\": 10.0,\n  \"reason\": \"Flight cancelled by the airline\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('204 No Content', () => pm.response.to.have.status(204));"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Financing",
      "item": [
        {
          "name": "Simulate financing",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/financing/simulate/1275.00",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "financing",
                "simulate",
                "1275.00"
              ]
            },
            "description": "Simula ofertas para un importe, sin operación. 400: VALIDATION_ERROR (importe <= 0). 422: UNSUPPORTED_COUNTRY (countryCode no disponible para la agencia; sin él se comprueba ESP) / NO_FINANCIAL_COMPANIES_CONFIGURED."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "Get financing details",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/financing/{{operation_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "financing",
                "{{operation_id}}"
              ]
            },
            "description": "Ofertas elegibles para una operación activa. 403: OPERATION_ACCESS_DENIED. 404: OPERATION_NOT_FOUND. 409: NOT_ACTIVE_OPERATION. 422: NOT_ELIGIBLE_FOR_FINANCING."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        },
        {
          "name": "Create financing",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/financing",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "financing"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"operationIdentifier\": \"{{operation_id}}\",\n  \"financialOfferId\": \"{{financial_offer_id}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "Inicia financiación con una oferta. Devuelve paymentUrl + financingStatus (REQUESTED/REFUSED/ERROR) con HTTP 200. 400: VALIDATION_ERROR. 403: OPERATION_ACCESS_DENIED. 404: OPERATION_NOT_FOUND. 409: NOT_ACTIVE_OPERATION. 422: NOT_ELIGIBLE_FINANCIAL_OFFER. 500: FINANCING_PROCESSING_ERROR."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "Acknowledge webhook event",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Fliinow-Agency",
                "value": "{{agency_id}}",
                "description": "Required only for management group API keys. Agency id from GET /agencies.",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/operations/webhook-events/ack",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "operations",
                "webhook-events",
                "ack"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"operationIdentifier\": \"{{operation_id}}\",\n  \"operationStatus\": \"CONFIRMED\",\n  \"eventId\": \"{{event_id}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "description": "Confirma (opcional) un evento de webhook recibido. 400: VALIDATION_ERROR. 403: OPERATION_ACCESS_DENIED / WEBHOOK_EVENT_OPERATION_MISMATCH. 404: OPERATION_NOT_FOUND / WEBHOOK_EVENT_NOT_FOUND. 409: WEBHOOK_EVENT_STATUS_MISMATCH / WEBHOOK_EVENT_NOT_ACKNOWLEDGEABLE."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200 OK', () => pm.response.to.have.status(200));"
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}
