{
  "info": {
    "title": "AgentSIM agent API",
    "version": "1.0.0",
    "description": "AgentSIM sells prepaid travel data eSIMs for countries and regions worldwide, backed by Airalo's global eSIM network. No account needed: pick a plan, pay, and get a one-tap install link and QR code within seconds. Built for AI agents like Instinct and Muse that buy on a traveler's behalf.\n\nHow an agent buys an eSIM for a traveler, with no account and no API key:\n1. `GET /api/v1/recommendations?countries=JP,KR&days=10` returns up to 3 options, best value first. Or browse with `GET /api/v1/destinations?query=japan`, then `GET /api/v1/packages?destination=japan&minDays=7`.\n2. `POST /api/v1/orders` with `{\"packageSlug\": \"<slug>\"}` returns `checkoutUrl`, `order.id` (ord_..., not a secret) and `orderSecret` (osk_..., shown once: store it). Send an `Idempotency-Key` header so a retried request returns the same checkout.\n3. Open `checkoutUrl` in a browser and pay (card or Link). Payment comes first; if the eSIM can't be issued, the payment is refunded in full.\n4. Poll `GET /api/v1/orders/{orderId}` with `Authorization: Bearer <orderSecret>` every 3 to 5 seconds until `status` is `fulfilled`.\n5. Send `travelerMessage` to the traveler verbatim. It has the one-tap iPhone install link, Android steps and the order ID, never a secret.\n\nBuyer keys: the first createOrder without `Authorization: Bearer agsk_...` returns `buyerKey` once. Send it on later orders and to `GET /api/v1/orders` to list this buyer's orders; it also opens every order it bought. Never forward either key to the traveler.\n\nAfter delivery: `GET /api/v1/orders/{orderId}/usage` returns the data left. To add data, `GET /api/v1/orders/{orderId}/topup-packages`, then `POST /api/v1/orders/{orderId}/topups` with `{\"topupPackageId\": \"<id>\"}` and pay like a new order. Register an HTTPS callback with `PUT /api/v1/webhook` to receive signed `esim.low_data` events.\n\nPrices are integer cents with a `currency`. Timestamps are ISO 8601 UTC. Errors are `{ \"error\": { \"code\", \"message\" } }` and the message says what to do next. An MCP server with the same operations is at `/api/mcp`.",
    "contact": {
      "url": "https://agent-sim-omega.vercel.app/contact"
    }
  },
  "servers": [
    {
      "url": "https://agent-sim-omega.vercel.app"
    }
  ],
  "components": {
    "securitySchemes": {
      "buyerKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Anonymous buyer key (agsk_...), returned once as buyerKey by the first createOrder without one."
      },
      "orderSecret": {
        "type": "http",
        "scheme": "bearer",
        "description": "The order's secret key (osk_...), returned once as orderSecret by the createOrder that made it."
      }
    },
    "schemas": {
      "DestinationType": {
        "type": "string",
        "enum": [
          "country",
          "region",
          "global"
        ],
        "description": "country: one country. region: several countries. global: worldwide."
      },
      "ListDestinationsResponse": {
        "type": "object",
        "properties": {
          "destinations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Destination"
            }
          }
        },
        "required": [
          "destinations"
        ],
        "additionalProperties": false
      },
      "Destination": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Destination slug from listDestinations.",
            "examples": [
              "japan",
              "europe",
              "global"
            ]
          },
          "name": {
            "type": "string",
            "examples": [
              "Japan"
            ]
          },
          "type": {
            "$ref": "#/components/schemas/DestinationType"
          },
          "countryCodes": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Z]{2}$",
              "description": "ISO 3166-1 alpha-2 country code.",
              "examples": [
                "JP"
              ]
            },
            "description": "Countries covered. One entry for a country."
          },
          "imageUrl": {
            "description": "Provider image, when there is one.",
            "type": [
              "string",
              "null"
            ]
          },
          "packageCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Packages for sale."
          },
          "fromPriceCents": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Price of the cheapest package, in cents of currency."
          },
          "currency": {
            "type": "string",
            "const": "USD",
            "description": "ISO 4217 currency code of every *Cents field in this object."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Destination page for people and browsing agents."
          },
          "markdownUrl": {
            "type": "string",
            "format": "uri",
            "description": "Markdown version of the destination page."
          },
          "packagesUrl": {
            "type": "string",
            "format": "uri",
            "description": "listPackages for this destination."
          }
        },
        "required": [
          "slug",
          "name",
          "type",
          "countryCodes",
          "imageUrl",
          "packageCount",
          "fromPriceCents",
          "currency",
          "url",
          "markdownUrl",
          "packagesUrl"
        ],
        "additionalProperties": false
      },
      "ListPackagesResponse": {
        "type": "object",
        "properties": {
          "packages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Package"
            }
          }
        },
        "required": [
          "packages"
        ],
        "additionalProperties": false
      },
      "Package": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Package slug from listPackages or listRecommendations.",
            "examples": [
              "japan-1gb-7-days"
            ]
          },
          "destinationSlug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Destination slug from listDestinations.",
            "examples": [
              "japan",
              "europe",
              "global"
            ]
          },
          "title": {
            "type": "string",
            "examples": [
              "Japan 1 GB, 7 days"
            ]
          },
          "dataMb": {
            "anyOf": [
              {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ],
            "description": "Data allowance in MB; null when unlimited."
          },
          "isUnlimited": {
            "type": "boolean"
          },
          "validityDays": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991,
            "description": "Days the package stays valid once it starts."
          },
          "priceCents": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Amount in minor units (cents) of currency."
          },
          "currency": {
            "type": "string",
            "const": "USD",
            "description": "ISO 4217 currency code of every *Cents field in this object."
          },
          "operatorName": {
            "type": "string"
          },
          "coverage": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Coverage"
            }
          },
          "activationPolicy": {
            "description": "When validity starts, e.g. first-usage.",
            "type": [
              "string",
              "null"
            ]
          },
          "dataOnly": {
            "type": "boolean"
          },
          "requiresKyc": {
            "type": "boolean"
          },
          "rechargeable": {
            "type": "boolean"
          },
          "hotspot": {
            "description": "Tethering allowed; null when the network does not say.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Destination page listing this package."
          },
          "buyUrl": {
            "type": "string",
            "format": "uri",
            "description": "Checkout page for browsing agents and people."
          }
        },
        "required": [
          "slug",
          "destinationSlug",
          "title",
          "dataMb",
          "isUnlimited",
          "validityDays",
          "priceCents",
          "currency",
          "operatorName",
          "coverage",
          "activationPolicy",
          "dataOnly",
          "requiresKyc",
          "rechargeable",
          "hotspot",
          "url",
          "buyUrl"
        ],
        "additionalProperties": false
      },
      "Coverage": {
        "type": "object",
        "properties": {
          "countryCode": {
            "type": "string",
            "pattern": "^[A-Z]{2}$",
            "description": "ISO 3166-1 alpha-2 country code.",
            "examples": [
              "JP"
            ]
          },
          "networks": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Operator networks, e.g. Docomo, SoftBank."
          },
          "speeds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "e.g. 4G, 5G. Empty when unknown."
          }
        },
        "required": [
          "countryCode",
          "networks",
          "speeds"
        ],
        "additionalProperties": false
      },
      "UsageLevel": {
        "type": "string",
        "enum": [
          "light",
          "moderate",
          "heavy"
        ],
        "description": "light: maps and messaging. moderate (default): some social and browsing. heavy: video and hotspot."
      },
      "ListRecommendationsResponse": {
        "type": "object",
        "properties": {
          "countries": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Z]{2}$",
              "description": "ISO 3166-1 alpha-2 country code.",
              "examples": [
                "JP"
              ]
            },
            "description": "The countries as resolved ISO codes."
          },
          "days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 365,
            "description": "Total trip length in days."
          },
          "itinerary": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "country": {
                      "type": "string",
                      "pattern": "^[A-Z]{2}$",
                      "description": "ISO 3166-1 alpha-2 country code.",
                      "examples": [
                        "JP"
                      ]
                    },
                    "days": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 365
                    }
                  },
                  "required": [
                    "country",
                    "days"
                  ],
                  "additionalProperties": false
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "Days per country when they were given; null when only a total was."
          },
          "recommendations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Recommendation"
            },
            "description": "Up to 3, best value first. Empty when nothing fits."
          }
        },
        "required": [
          "countries",
          "days",
          "itinerary",
          "recommendations"
        ],
        "additionalProperties": false
      },
      "Recommendation": {
        "type": "object",
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/RecommendationKind"
          },
          "reason": {
            "type": "string",
            "description": "One sentence to repeat to the traveler."
          },
          "totalPriceCents": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Amount in minor units (cents) of currency."
          },
          "currency": {
            "type": "string",
            "const": "USD",
            "description": "ISO 4217 currency code of every *Cents field in this object."
          },
          "packages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Package"
            }
          }
        },
        "required": [
          "kind",
          "reason",
          "totalPriceCents",
          "currency",
          "packages"
        ],
        "additionalProperties": false
      },
      "RecommendationKind": {
        "type": "string",
        "enum": [
          "singleCountry",
          "regional",
          "combination"
        ],
        "description": "combination: one package per country; buy each one with its own createOrder."
      },
      "CreateOrderRequest": {
        "type": "object",
        "properties": {
          "packageSlug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Package slug from listPackages or listRecommendations.",
            "examples": [
              "japan-1gb-7-days"
            ]
          },
          "email": {
            "description": "Traveler email; the install link is also sent there.",
            "type": "string",
            "maxLength": 254,
            "format": "email",
            "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
          },
          "agentHint": {
            "description": "Name of your agent or product, e.g. \"Instinct\".",
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          }
        },
        "required": [
          "packageSlug"
        ]
      },
      "CreateOrderResponse": {
        "type": "object",
        "properties": {
          "order": {
            "$ref": "#/components/schemas/Order"
          },
          "checkoutUrl": {
            "type": "string",
            "format": "uri",
            "description": "Hosted payment page. Open it in a browser and pay."
          },
          "checkoutExpiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "The payment page stops working after this.",
            "examples": [
              "2026-09-23T20:04:11.000Z"
            ]
          },
          "orderSecret": {
            "description": "osk_... Returned once, by the call that created the order; null on replays. Never send it to the traveler.",
            "type": [
              "string",
              "null"
            ]
          },
          "buyerKey": {
            "description": "agsk_... Only when this call created a new buyer; otherwise null. Never send it to the traveler.",
            "type": [
              "string",
              "null"
            ]
          },
          "nextStep": {
            "type": "string"
          }
        },
        "required": [
          "order",
          "checkoutUrl",
          "checkoutExpiresAt",
          "orderSecret",
          "buyerKey",
          "nextStep"
        ],
        "additionalProperties": false
      },
      "Order": {
        "type": "object",
        "properties": {
          "access": {
            "type": "string",
            "const": "full"
          },
          "id": {
            "type": "string",
            "pattern": "^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$",
            "description": "Order id (TypeID with prefix ord). Not a credential.",
            "examples": [
              "ord_01k5x3f7h9a2b4c6d8e0f1g2h3"
            ]
          },
          "kind": {
            "$ref": "#/components/schemas/OrderKind"
          },
          "status": {
            "$ref": "#/components/schemas/OrderStatus"
          },
          "nextStep": {
            "type": "string",
            "description": "What the agent should do now."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Order page. Shows the status; the eSIM after Find your order."
          },
          "apiUrl": {
            "type": "string",
            "format": "uri",
            "description": "getOrder for this order."
          },
          "failureReason": {
            "description": "Our explanation of a failure; never provider or payment details.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp in UTC.",
            "examples": [
              "2026-09-23T20:04:11.000Z"
            ]
          },
          "fulfilledAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 timestamp in UTC.",
                "examples": [
                  "2026-09-23T20:04:11.000Z"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "refundedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 timestamp in UTC.",
                "examples": [
                  "2026-09-23T20:04:11.000Z"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "When the payment was refunded in full."
          },
          "priceCents": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Amount in minor units (cents) of currency."
          },
          "currency": {
            "type": "string",
            "const": "USD",
            "description": "ISO 4217 currency code of every *Cents field in this object."
          },
          "package": {
            "$ref": "#/components/schemas/Package"
          },
          "esim": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Esim"
              },
              {
                "type": "null"
              }
            ],
            "description": "Issued eSIM orders only."
          },
          "travelerMessage": {
            "description": "Plain text under 600 characters to forward verbatim by SMS or chat. Issued eSIM orders only.",
            "type": [
              "string",
              "null"
            ]
          },
          "lowData": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LowData"
              },
              {
                "type": "null"
              }
            ]
          },
          "topupPackagesUrl": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "description": "Absolute URL."
              },
              {
                "type": "null"
              }
            ],
            "description": "Issued eSIM orders: listTopupPackages."
          },
          "usageUrl": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "description": "Absolute URL."
              },
              {
                "type": "null"
              }
            ],
            "description": "Issued eSIM orders: getUsage."
          },
          "usage": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UsageReading"
              },
              {
                "type": "null"
              }
            ],
            "description": "Issued eSIM orders: the latest reading, null while the network has none."
          },
          "receipt": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Receipt"
              },
              {
                "type": "null"
              }
            ],
            "description": "Paid orders, when the payment provider answers."
          },
          "topup": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TopupTarget"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "access",
          "id",
          "kind",
          "status",
          "nextStep",
          "url",
          "apiUrl",
          "failureReason",
          "createdAt",
          "fulfilledAt",
          "refundedAt",
          "priceCents",
          "currency",
          "package",
          "esim",
          "travelerMessage",
          "lowData",
          "topupPackagesUrl",
          "usageUrl",
          "usage",
          "receipt",
          "topup"
        ],
        "additionalProperties": false
      },
      "OrderKind": {
        "type": "string",
        "enum": [
          "esim",
          "topup"
        ],
        "description": "esim: a new eSIM. topup: data added to the eSIM of an earlier order."
      },
      "OrderStatus": {
        "type": "string",
        "enum": [
          "pendingPayment",
          "fulfilling",
          "fulfilled",
          "failed",
          "expired",
          "needsAttention"
        ],
        "description": "pendingPayment: not paid yet. fulfilling: poll again. fulfilled: eSIM ready. failed: could not issue; any payment refunded in full. expired: never paid. needsAttention: we are resolving it manually."
      },
      "Esim": {
        "type": "object",
        "properties": {
          "iccid": {
            "type": "string",
            "description": "The eSIM's ICCID. Quote it to support.",
            "examples": [
              "8910300000000000001"
            ]
          },
          "appleInstallUrl": {
            "type": "string",
            "format": "uri",
            "description": "One-tap install link for iOS 17.4 and later."
          },
          "androidInstallUrl": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "description": "Absolute URL."
              },
              {
                "type": "null"
              }
            ],
            "description": "Android install link when the provider supplies one."
          },
          "lpa": {
            "type": "string",
            "description": "Full LPA string, the QR code payload."
          },
          "smdpAddress": {
            "type": "string",
            "description": "SM-DP+ address for manual Android setup."
          },
          "activationCode": {
            "type": "string",
            "description": "Activation code for manual Android setup."
          },
          "qrPngUrl": {
            "type": "string",
            "format": "uri",
            "description": "QR code PNG. Send the same Authorization header to fetch it."
          },
          "apn": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "iccid",
          "appleInstallUrl",
          "androidInstallUrl",
          "lpa",
          "smdpAddress",
          "activationCode",
          "qrPngUrl",
          "apn"
        ],
        "additionalProperties": false
      },
      "LowData": {
        "type": "object",
        "properties": {
          "level": {
            "type": "string",
            "description": "\"75%\" or \"90%\" of data used, or \"3days\" / \"1days\" before expiry.",
            "examples": [
              "90%"
            ]
          },
          "remainingPercent": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp in UTC.",
            "examples": [
              "2026-09-23T20:04:11.000Z"
            ]
          }
        },
        "required": [
          "level",
          "remainingPercent",
          "at"
        ],
        "additionalProperties": false
      },
      "UsageReading": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/UsageStatus"
          },
          "isUnlimited": {
            "type": "boolean"
          },
          "remainingMb": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ],
            "description": "Null for unlimited plans."
          },
          "totalMb": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ]
          },
          "remainingPercent": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "expiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 timestamp in UTC.",
                "examples": [
                  "2026-09-23T20:04:11.000Z"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "When the plan ends. Null until the plan has started (status notActive or unknown): the days start at first connection (or on install for some plans), so a date before that is not the plan's end."
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the provider reported these numbers.",
            "examples": [
              "2026-09-23T20:04:11.000Z"
            ]
          },
          "nextCheckAfter": {
            "type": "string",
            "format": "date-time",
            "description": "Polling earlier returns the same reading.",
            "examples": [
              "2026-09-23T20:04:11.000Z"
            ]
          }
        },
        "required": [
          "status",
          "isUnlimited",
          "remainingMb",
          "totalMb",
          "remainingPercent",
          "expiresAt",
          "checkedAt",
          "nextCheckAfter"
        ],
        "additionalProperties": false
      },
      "UsageStatus": {
        "type": "string",
        "enum": [
          "notActive",
          "active",
          "finished",
          "expired",
          "unknown"
        ],
        "description": "notActive: not activated yet (installed or not, never connected); the plan's days have not started and expiresAt is null. active: in use. finished: data used up (depleted). expired: validity ended. unknown: the provider reported another state."
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "receiptNumber": {
            "type": "string",
            "pattern": "^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$",
            "description": "The order id.",
            "examples": [
              "ord_01k5x3f7h9a2b4c6d8e0f1g2h3"
            ]
          },
          "paidAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 timestamp in UTC.",
                "examples": [
                  "2026-09-23T20:04:11.000Z"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "item": {
            "type": "string"
          },
          "priceCents": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Amount in minor units (cents) of currency."
          },
          "currency": {
            "type": "string",
            "const": "USD",
            "description": "ISO 4217 currency code of every *Cents field in this object."
          },
          "paymentMethod": {
            "type": "string",
            "examples": [
              "Visa ending 4242",
              "Link",
              "Test payment"
            ]
          },
          "cardBrand": {
            "type": [
              "string",
              "null"
            ]
          },
          "cardLast4": {
            "type": [
              "string",
              "null"
            ]
          },
          "stripeReceiptUrl": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "description": "Absolute URL."
              },
              {
                "type": "null"
              }
            ]
          },
          "refundedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 timestamp in UTC.",
                "examples": [
                  "2026-09-23T20:04:11.000Z"
                ]
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "receiptNumber",
          "paidAt",
          "item",
          "priceCents",
          "currency",
          "paymentMethod",
          "cardBrand",
          "cardLast4",
          "stripeReceiptUrl",
          "refundedAt"
        ],
        "additionalProperties": false
      },
      "TopupTarget": {
        "type": "object",
        "properties": {
          "iccid": {
            "anyOf": [
              {
                "type": "string",
                "description": "The eSIM's ICCID. Quote it to support.",
                "examples": [
                  "8910300000000000001"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "parentOrderId": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$",
                "description": "Order id (TypeID with prefix ord). Not a credential.",
                "examples": [
                  "ord_01k5x3f7h9a2b4c6d8e0f1g2h3"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "parentApiUrl": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "description": "Absolute URL."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "iccid",
          "parentOrderId",
          "parentApiUrl"
        ],
        "additionalProperties": false
      },
      "ListOrdersResponse": {
        "type": "object",
        "properties": {
          "orders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderListItem"
            }
          }
        },
        "required": [
          "orders"
        ],
        "additionalProperties": false
      },
      "OrderListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$",
            "description": "Order id (TypeID with prefix ord). Not a credential.",
            "examples": [
              "ord_01k5x3f7h9a2b4c6d8e0f1g2h3"
            ]
          },
          "kind": {
            "$ref": "#/components/schemas/OrderKind"
          },
          "status": {
            "$ref": "#/components/schemas/OrderStatus"
          },
          "package": {
            "$ref": "#/components/schemas/PackageRef"
          },
          "iccid": {
            "anyOf": [
              {
                "type": "string",
                "description": "The eSIM's ICCID. Quote it to support.",
                "examples": [
                  "8910300000000000001"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "The eSIM's ICCID once issued."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp in UTC.",
            "examples": [
              "2026-09-23T20:04:11.000Z"
            ]
          },
          "fulfilledAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 timestamp in UTC.",
                "examples": [
                  "2026-09-23T20:04:11.000Z"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Absolute URL."
          },
          "apiUrl": {
            "type": "string",
            "format": "uri",
            "description": "Absolute URL."
          },
          "lowData": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LowData"
              },
              {
                "type": "null"
              }
            ]
          },
          "topupPackagesUrl": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "description": "Absolute URL."
              },
              {
                "type": "null"
              }
            ]
          },
          "usageUrl": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "description": "Absolute URL."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "kind",
          "status",
          "package",
          "iccid",
          "createdAt",
          "fulfilledAt",
          "url",
          "apiUrl",
          "lowData",
          "topupPackagesUrl",
          "usageUrl"
        ],
        "additionalProperties": false
      },
      "PackageRef": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Package slug from listPackages or listRecommendations.",
            "examples": [
              "japan-1gb-7-days"
            ]
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "slug",
          "title"
        ],
        "additionalProperties": false
      },
      "GetOrderResponse": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/OrderStatusView"
          },
          {
            "$ref": "#/components/schemas/Order"
          }
        ]
      },
      "OrderStatusView": {
        "type": "object",
        "properties": {
          "access": {
            "type": "string",
            "const": "statusOnly"
          },
          "id": {
            "type": "string",
            "pattern": "^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$",
            "description": "Order id (TypeID with prefix ord). Not a credential.",
            "examples": [
              "ord_01k5x3f7h9a2b4c6d8e0f1g2h3"
            ]
          },
          "kind": {
            "$ref": "#/components/schemas/OrderKind"
          },
          "status": {
            "$ref": "#/components/schemas/OrderStatus"
          },
          "nextStep": {
            "type": "string",
            "description": "What the agent should do now."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Order page. Shows the status; the eSIM after Find your order."
          },
          "apiUrl": {
            "type": "string",
            "format": "uri",
            "description": "getOrder for this order."
          },
          "failureReason": {
            "description": "Our explanation of a failure; never provider or payment details.",
            "type": [
              "string",
              "null"
            ]
          },
          "package": {
            "$ref": "#/components/schemas/PackageRef"
          },
          "refunded": {
            "type": "boolean"
          },
          "stuck": {
            "type": "boolean",
            "description": "Fulfillment has been running for more than 5 minutes."
          }
        },
        "required": [
          "access",
          "id",
          "kind",
          "status",
          "nextStep",
          "url",
          "apiUrl",
          "failureReason",
          "package",
          "refunded",
          "stuck"
        ],
        "additionalProperties": false
      },
      "ListTopupPackagesResponse": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string",
            "pattern": "^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$",
            "description": "Order id (TypeID with prefix ord). Not a credential.",
            "examples": [
              "ord_01k5x3f7h9a2b4c6d8e0f1g2h3"
            ]
          },
          "iccid": {
            "type": "string",
            "description": "The eSIM's ICCID. Quote it to support.",
            "examples": [
              "8910300000000000001"
            ]
          },
          "topupPackages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TopupPackage"
            },
            "description": "Cheapest first. Empty when none are offered."
          },
          "nextStep": {
            "type": "string"
          }
        },
        "required": [
          "orderId",
          "iccid",
          "topupPackages",
          "nextStep"
        ],
        "additionalProperties": false
      },
      "TopupPackage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Our id for this top-up of this eSIM (not the supplier's). Pass it as topupPackageId to createTopup.",
            "examples": [
              "1gb-7-days"
            ]
          },
          "title": {
            "type": "string",
            "examples": [
              "1 GB, 7 days"
            ]
          },
          "dataMb": {
            "anyOf": [
              {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ],
            "description": "Data allowance in MB; null when unlimited."
          },
          "isUnlimited": {
            "type": "boolean"
          },
          "validityDays": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991,
            "description": "Days the package stays valid once it starts."
          },
          "priceCents": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Amount in minor units (cents) of currency."
          },
          "currency": {
            "type": "string",
            "const": "USD",
            "description": "ISO 4217 currency code of every *Cents field in this object."
          }
        },
        "required": [
          "id",
          "title",
          "dataMb",
          "isUnlimited",
          "validityDays",
          "priceCents",
          "currency"
        ],
        "additionalProperties": false
      },
      "CreateTopupRequest": {
        "type": "object",
        "properties": {
          "topupPackageId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "A TopupPackage id from listTopupPackages."
          },
          "agentHint": {
            "description": "Name of your agent or product.",
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          }
        },
        "required": [
          "topupPackageId"
        ]
      },
      "CreateTopupResponse": {
        "type": "object",
        "properties": {
          "order": {
            "description": "The new top-up order. Poll it with the eSIM order's secret key.",
            "$ref": "#/components/schemas/Order"
          },
          "checkoutUrl": {
            "type": "string",
            "format": "uri",
            "description": "Hosted payment page. Open it in a browser and pay."
          },
          "checkoutExpiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 timestamp in UTC.",
            "examples": [
              "2026-09-23T20:04:11.000Z"
            ]
          },
          "nextStep": {
            "type": "string"
          }
        },
        "required": [
          "order",
          "checkoutUrl",
          "checkoutExpiresAt",
          "nextStep"
        ],
        "additionalProperties": false
      },
      "Usage": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/UsageStatus"
          },
          "isUnlimited": {
            "type": "boolean"
          },
          "remainingMb": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ],
            "description": "Null for unlimited plans."
          },
          "totalMb": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "null"
              }
            ]
          },
          "remainingPercent": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "expiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 timestamp in UTC.",
                "examples": [
                  "2026-09-23T20:04:11.000Z"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "When the plan ends. Null until the plan has started (status notActive or unknown): the days start at first connection (or on install for some plans), so a date before that is not the plan's end."
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the provider reported these numbers.",
            "examples": [
              "2026-09-23T20:04:11.000Z"
            ]
          },
          "nextCheckAfter": {
            "type": "string",
            "format": "date-time",
            "description": "Polling earlier returns the same reading.",
            "examples": [
              "2026-09-23T20:04:11.000Z"
            ]
          },
          "orderId": {
            "type": "string",
            "pattern": "^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$",
            "description": "Order id (TypeID with prefix ord). Not a credential.",
            "examples": [
              "ord_01k5x3f7h9a2b4c6d8e0f1g2h3"
            ]
          },
          "iccid": {
            "type": "string",
            "description": "The eSIM's ICCID. Quote it to support.",
            "examples": [
              "8910300000000000001"
            ]
          },
          "lowData": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LowData"
              },
              {
                "type": "null"
              }
            ]
          },
          "topupPackagesUrl": {
            "type": "string",
            "format": "uri",
            "description": "listTopupPackages for this eSIM."
          },
          "nextStep": {
            "type": "string"
          }
        },
        "required": [
          "status",
          "isUnlimited",
          "remainingMb",
          "totalMb",
          "remainingPercent",
          "expiresAt",
          "checkedAt",
          "nextCheckAfter",
          "orderId",
          "iccid",
          "lowData",
          "topupPackagesUrl",
          "nextStep"
        ],
        "additionalProperties": false
      },
      "Webhook": {
        "type": "object",
        "properties": {
          "url": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "description": "Absolute URL."
              },
              {
                "type": "null"
              }
            ],
            "description": "The registered HTTPS callback, or null."
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          },
          "signatureHeader": {
            "type": "string",
            "examples": [
              "AgentSIM-Signature"
            ]
          },
          "signatureFormat": {
            "type": "string",
            "examples": [
              "t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>"
            ]
          }
        },
        "required": [
          "url",
          "events",
          "signatureHeader",
          "signatureFormat"
        ],
        "additionalProperties": false
      },
      "WebhookEventType": {
        "type": "string",
        "enum": [
          "esim.low_data"
        ]
      },
      "UpdateWebhookRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048,
            "description": "Public https:// URL on port 443 that receives signed esim.low_data events."
          }
        },
        "required": [
          "url"
        ]
      },
      "UpdateWebhookResponse": {
        "type": "object",
        "properties": {
          "url": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "description": "Absolute URL."
              },
              {
                "type": "null"
              }
            ],
            "description": "The registered HTTPS callback, or null."
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          },
          "signatureHeader": {
            "type": "string",
            "examples": [
              "AgentSIM-Signature"
            ]
          },
          "signatureFormat": {
            "type": "string",
            "examples": [
              "t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>"
            ]
          },
          "secret": {
            "type": "string",
            "description": "Signing secret (whsec_...). Shown once; registering again rotates it."
          },
          "nextStep": {
            "type": "string"
          }
        },
        "required": [
          "url",
          "events",
          "signatureHeader",
          "signatureFormat",
          "secret",
          "nextStep"
        ],
        "additionalProperties": false
      },
      "DeleteWebhookResponse": {
        "type": "object",
        "properties": {
          "deleted": {
            "type": "boolean",
            "const": true
          }
        },
        "required": [
          "deleted"
        ],
        "additionalProperties": false
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "esim.low_data"
          },
          "orderId": {
            "type": "string",
            "pattern": "^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$",
            "description": "The order id only, never its secret key.",
            "examples": [
              "ord_01k5x3f7h9a2b4c6d8e0f1g2h3"
            ]
          },
          "iccid": {
            "type": "string",
            "description": "The eSIM's ICCID. Quote it to support.",
            "examples": [
              "8910300000000000001"
            ]
          },
          "remainingPercent": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "level": {
            "type": "string",
            "description": "\"75%\" or \"90%\" of data used, or \"3days\" / \"1days\" before expiry.",
            "examples": [
              "90%"
            ]
          },
          "topupPackagesUrl": {
            "type": "string",
            "format": "uri",
            "description": "listTopupPackages for this eSIM."
          }
        },
        "required": [
          "type",
          "orderId",
          "iccid",
          "remainingPercent",
          "level",
          "topupPackagesUrl"
        ],
        "additionalProperties": false
      }
    }
  },
  "openapi": "3.1.1",
  "paths": {
    "/api/v1/destinations": {
      "get": {
        "operationId": "listDestinations",
        "summary": "List destinations",
        "description": "Countries, regions and global destinations with packages for sale. A country query also returns the regional and global destinations that cover it. Next: listPackages with a destination slug.",
        "tags": [
          "catalog"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "query",
            "schema": {
              "description": "Country or region name or ISO code, e.g. \"Japan\", \"JP\", \"Europe\". A country also matches the regions covering it.",
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "in": "query",
            "name": "type",
            "schema": {
              "$ref": "#/components/schemas/DestinationType"
            },
            "allowEmptyValue": true,
            "allowReserved": true,
            "style": "deepObject",
            "explode": true
          }
        ],
        "responses": {
          "200": {
            "description": "Matching destinations.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListDestinationsResponse"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request: The request is malformed or fails validation. The message names the field and how to fix it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/packages": {
      "get": {
        "operationId": "listPackages",
        "summary": "List packages",
        "description": "Packages for sale, cheapest first. Filter by destination slug or by one country (includes regional and global packages covering it). Next: createOrder with the slug of a package whose validityDays covers the trip.",
        "tags": [
          "catalog"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "destination",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "description": "Destination slug from listDestinations.",
              "examples": [
                "japan",
                "europe",
                "global"
              ]
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "in": "query",
            "name": "country",
            "schema": {
              "description": "One country as an ISO code or name. Includes the regional and global packages covering it.",
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "examples": [
                "JP",
                "South Korea"
              ]
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "in": "query",
            "name": "minDays",
            "schema": {
              "description": "Only packages valid for at least this many days.",
              "type": "integer",
              "minimum": 1,
              "maximum": 365
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "in": "query",
            "name": "minGb",
            "schema": {
              "description": "Only packages with at least this much data in GB. Unlimited packages always qualify.",
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 1000
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "Packages sorted by price, cheapest first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListPackagesResponse"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request: The request is malformed or fails validation. The message names the field and how to fix it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found: No such resource. The message says which call returns valid values.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/packages/{packageSlug}": {
      "get": {
        "operationId": "getPackage",
        "summary": "Get a package",
        "description": "One package by slug. Next: createOrder with this slug.",
        "tags": [
          "catalog"
        ],
        "parameters": [
          {
            "in": "path",
            "required": true,
            "name": "packageSlug",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Package slug from listPackages or listRecommendations.",
              "examples": [
                "japan-1gb-7-days"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The package.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Package"
                }
              }
            }
          },
          "404": {
            "description": "not_found: No such resource. The message says which call returns valid values.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/recommendations": {
      "get": {
        "operationId": "listRecommendations",
        "summary": "Recommend packages for a trip",
        "description": "The fastest way to choose. Up to 3 options, best value first, each with a one-sentence reason to repeat to the traveler. Give countries and the total days (countries=JP,KR&days=7), or days per country (countries=JP:4,KR:3): each local plan of a combination then covers that country's own days, and regional plans the whole trip. A combination needs one createOrder per package. Next: createOrder with the chosen slug.",
        "tags": [
          "catalog"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "countries",
            "schema": {
              "minItems": 1,
              "maxItems": 20,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "description": "ISO 3166-1 alpha-2 code or English country name.",
                "examples": [
                  "JP",
                  "South Korea"
                ]
              },
              "description": "Countries visited, as ISO codes or English names, in visiting order. Add days per country as COUNTRY:DAYS. In a query string: comma-separated, e.g. \"JP,KR\" with days=7, or \"JP:4,KR:3\"."
            },
            "allowEmptyValue": true,
            "allowReserved": true,
            "required": true,
            "explode": false
          },
          {
            "in": "query",
            "name": "days",
            "schema": {
              "description": "Total trip length in days. Required unless every country has its own days (JP:4,KR:3); when both are given they must add up.",
              "type": "integer",
              "minimum": 1,
              "maximum": 365
            },
            "allowEmptyValue": true,
            "allowReserved": true
          },
          {
            "in": "query",
            "name": "usage",
            "schema": {
              "$ref": "#/components/schemas/UsageLevel"
            },
            "allowEmptyValue": true,
            "allowReserved": true,
            "style": "deepObject",
            "explode": true
          },
          {
            "in": "query",
            "name": "gb",
            "schema": {
              "description": "Data need in GB for the whole trip. Overrides usage.",
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 1000
            },
            "allowEmptyValue": true,
            "allowReserved": true
          }
        ],
        "responses": {
          "200": {
            "description": "Recommendations, best first. Empty when nothing fits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListRecommendationsResponse"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request: The request is malformed or fails validation. The message names the field and how to fix it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/orders": {
      "post": {
        "operationId": "createOrder",
        "summary": "Create an order",
        "description": "Creates an order and a hosted payment page. No account needed. With a buyer key the order joins that buyer's list; without one a new buyer is created and its buyerKey returned once. With a buyer key, limited to 10 orders a minute per key (see the RateLimit headers); without one, not limited. Next: open checkoutUrl and pay, then poll getOrder with the orderSecret until status is fulfilled.",
        "tags": [
          "orders"
        ],
        "parameters": [
          {
            "in": "header",
            "name": "idempotency-key",
            "schema": {
              "type": "string",
              "pattern": "^[\\x21-\\x7E]{1,200}$",
              "description": "Any unique printable ASCII string up to 200 characters, for example a UUID."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOrderRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay of an earlier createOrder with the same Idempotency-Key. orderSecret and buyerKey are null.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateOrderResponse"
                }
              }
            },
            "headers": {
              "ratelimit": {
                "schema": {
                  "description": "Limit, remaining requests and seconds until reset, for the presented buyer key. Absent without a buyer key.",
                  "examples": [
                    "limit=10, remaining=7, reset=42"
                  ],
                  "type": "string"
                }
              },
              "ratelimit-policy": {
                "schema": {
                  "description": "Requests per window, per buyer key. Absent without a buyer key.",
                  "examples": [
                    "10;w=60"
                  ],
                  "type": "string"
                }
              },
              "idempotent-replayed": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "true",
                  "description": "Present on replays."
                }
              }
            }
          },
          "201": {
            "description": "Order created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateOrderResponse"
                }
              }
            },
            "headers": {
              "ratelimit": {
                "schema": {
                  "description": "Limit, remaining requests and seconds until reset, for the presented buyer key. Absent without a buyer key.",
                  "examples": [
                    "limit=10, remaining=7, reset=42"
                  ],
                  "type": "string"
                }
              },
              "ratelimit-policy": {
                "schema": {
                  "description": "Requests per window, per buyer key. Absent without a buyer key.",
                  "examples": [
                    "10;w=60"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request: The request is malformed or fails validation. The message names the field and how to fix it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "invalid_buyer_key: The buyer key is unknown. Omit Authorization on createOrder to get a new one; never retry with a new buyer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_buyer_key"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge: realm \"buyer key\" or \"order\".",
                "schema": {
                  "type": "string"
                },
                "required": true
              }
            }
          },
          "404": {
            "description": "not_found: No such resource. The message says which call returns valid values.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "unavailable: The package cannot be sold right now. Pick another package for the same destination. idempotency_conflict: The Idempotency-Key was already used for a different request, or for a checkout that is no longer open.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "unavailable",
                            "idempotency_conflict"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: Too many requests for this buyer key, or too many failed attempts on this order. Wait for Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "rate_limited"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "required": true
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {},
          {
            "buyerKey": []
          }
        ]
      },
      "get": {
        "operationId": "listOrders",
        "summary": "List the buyer's orders",
        "description": "Every order placed with this buyer key, newest first, with status, package and ICCID once issued. Next: getOrder with an order id and the same buyer key for install details.",
        "tags": [
          "orders"
        ],
        "responses": {
          "200": {
            "description": "The buyer's orders.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListOrdersResponse"
                }
              }
            }
          },
          "401": {
            "description": "buyer_key_required: Send the buyer key as Authorization: Bearer agsk_... It is returned once as buyerKey by createOrder. invalid_buyer_key: The buyer key is unknown. Omit Authorization on createOrder to get a new one; never retry with a new buyer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "buyer_key_required",
                            "invalid_buyer_key"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge: realm \"buyer key\" or \"order\".",
                "schema": {
                  "type": "string"
                },
                "required": true
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "buyerKey": []
          }
        ]
      }
    },
    "/api/v1/orders/{orderId}": {
      "get": {
        "operationId": "getOrder",
        "summary": "Get an order",
        "description": "Poll after payment; calling it also completes delivery right after payment. Without credentials it returns the status only (access statusOnly). With Authorization: Bearer <orderSecret> or the buyer key that bought the order it returns everything (access full). When status is fulfilled, send travelerMessage to the traveler. Wrong keys are limited to 10 a minute per order.",
        "tags": [
          "orders"
        ],
        "parameters": [
          {
            "in": "path",
            "required": true,
            "name": "orderId",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Order id (ord_...). An ICCID also works together with the buyer key that owns the eSIM."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The order, as much as the credential allows.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetOrderResponse"
                }
              }
            }
          },
          "401": {
            "description": "invalid_order_secret: This key does not open this order. Send its orderSecret or the buyer key that bought it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_order_secret"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge: realm \"buyer key\" or \"order\".",
                "schema": {
                  "type": "string"
                },
                "required": true
              }
            }
          },
          "404": {
            "description": "not_found: No such resource. The message says which call returns valid values.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: Too many requests for this buyer key, or too many failed attempts on this order. Wait for Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "rate_limited"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "required": true
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {},
          {
            "orderSecret": []
          },
          {
            "buyerKey": []
          }
        ]
      }
    },
    "/api/v1/orders/{orderId}/topup-packages": {
      "get": {
        "operationId": "listTopupPackages",
        "summary": "List top-up packages for an eSIM",
        "description": "Data add-ons the eSIM can take, cheapest first. The data goes onto the same eSIM; nothing to reinstall. Next: createTopup with a topupPackageId.",
        "tags": [
          "topups"
        ],
        "parameters": [
          {
            "in": "path",
            "required": true,
            "name": "orderId",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Order id (ord_...). An ICCID also works together with the buyer key that owns the eSIM."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Top-up packages for this eSIM.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListTopupPackagesResponse"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request: The request is malformed or fails validation. The message names the field and how to fix it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "order_secret_required: Send the order's secret key (osk_...) or the buyer key that bought it as Authorization: Bearer. invalid_order_secret: This key does not open this order. Send its orderSecret or the buyer key that bought it. invalid_buyer_key: The buyer key is unknown. Omit Authorization on createOrder to get a new one; never retry with a new buyer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "order_secret_required",
                            "invalid_order_secret",
                            "invalid_buyer_key"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge: realm \"buyer key\" or \"order\".",
                "schema": {
                  "type": "string"
                },
                "required": true
              }
            }
          },
          "404": {
            "description": "not_found: No such resource. The message says which call returns valid values. esim_not_found: The eSIM provider does not recognize this eSIM. Contact support with the order ID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found",
                            "esim_not_found"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "topups_unavailable: The eSIM cannot take top-ups (not issued yet, or not offered by the network).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "topups_unavailable"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "esim_recycled: The eSIM was recycled after it expired or went unused. Buy a new eSIM.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "esim_recycled"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: Too many requests for this buyer key, or too many failed attempts on this order. Wait for Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "rate_limited"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "required": true
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "provider_unavailable: The eSIM provider is busy or did not answer. Retry after Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "provider_unavailable"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "required": true
              }
            }
          }
        },
        "security": [
          {
            "orderSecret": []
          },
          {
            "buyerKey": []
          }
        ]
      }
    },
    "/api/v1/orders/{orderId}/topups": {
      "post": {
        "operationId": "createTopup",
        "summary": "Create a top-up order",
        "description": "Creates a top-up order and a hosted payment page, like createOrder. Payment comes first; if the data can't be added, the payment is refunded in full. Next: open checkoutUrl and pay, then poll getOrder for the new order with the eSIM order's secret key until status is fulfilled. With a buyer key it shares createOrder's limit of 10 a minute per key.",
        "tags": [
          "topups"
        ],
        "parameters": [
          {
            "in": "path",
            "required": true,
            "name": "orderId",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Order id (ord_...). An ICCID also works together with the buyer key that owns the eSIM."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTopupRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Top-up order created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateTopupResponse"
                }
              }
            },
            "headers": {
              "ratelimit": {
                "schema": {
                  "description": "Limit, remaining requests and seconds until reset, for the presented buyer key. Absent without a buyer key.",
                  "examples": [
                    "limit=10, remaining=7, reset=42"
                  ],
                  "type": "string"
                }
              },
              "ratelimit-policy": {
                "schema": {
                  "description": "Requests per window, per buyer key. Absent without a buyer key.",
                  "examples": [
                    "10;w=60"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request: The request is malformed or fails validation. The message names the field and how to fix it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "order_secret_required: Send the order's secret key (osk_...) or the buyer key that bought it as Authorization: Bearer. invalid_order_secret: This key does not open this order. Send its orderSecret or the buyer key that bought it. invalid_buyer_key: The buyer key is unknown. Omit Authorization on createOrder to get a new one; never retry with a new buyer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "order_secret_required",
                            "invalid_order_secret",
                            "invalid_buyer_key"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge: realm \"buyer key\" or \"order\".",
                "schema": {
                  "type": "string"
                },
                "required": true
              }
            }
          },
          "404": {
            "description": "not_found: No such resource. The message says which call returns valid values. esim_not_found: The eSIM provider does not recognize this eSIM. Contact support with the order ID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found",
                            "esim_not_found"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "topups_unavailable: The eSIM cannot take top-ups (not issued yet, or not offered by the network). topup_limit_reached: The eSIM has reached its top-up limit. Buy a new eSIM for more data.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "topups_unavailable",
                            "topup_limit_reached"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "esim_recycled: The eSIM was recycled after it expired or went unused. Buy a new eSIM.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "esim_recycled"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: Too many requests for this buyer key, or too many failed attempts on this order. Wait for Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "rate_limited"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "required": true
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "provider_unavailable: The eSIM provider is busy or did not answer. Retry after Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "provider_unavailable"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "required": true
              }
            }
          }
        },
        "security": [
          {
            "orderSecret": []
          },
          {
            "buyerKey": []
          }
        ]
      }
    },
    "/api/v1/orders/{orderId}/usage": {
      "get": {
        "operationId": "getUsage",
        "summary": "Get data usage for an eSIM",
        "description": "Remaining and total data, status and expiry for an issued eSIM. Readings are cached for 20 minutes (the provider refreshes no faster). Next: if data is low, listTopupPackages.",
        "tags": [
          "usage"
        ],
        "parameters": [
          {
            "in": "path",
            "required": true,
            "name": "orderId",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Order id (ord_...). An ICCID also works together with the buyer key that owns the eSIM."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The latest reading.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request: The request is malformed or fails validation. The message names the field and how to fix it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "order_secret_required: Send the order's secret key (osk_...) or the buyer key that bought it as Authorization: Bearer. invalid_order_secret: This key does not open this order. Send its orderSecret or the buyer key that bought it. invalid_buyer_key: The buyer key is unknown. Omit Authorization on createOrder to get a new one; never retry with a new buyer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "order_secret_required",
                            "invalid_order_secret",
                            "invalid_buyer_key"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge: realm \"buyer key\" or \"order\".",
                "schema": {
                  "type": "string"
                },
                "required": true
              }
            }
          },
          "404": {
            "description": "not_found: No such resource. The message says which call returns valid values. esim_not_found: The eSIM provider does not recognize this eSIM. Contact support with the order ID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found",
                            "esim_not_found"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "usage_unavailable: No usage is reported for this eSIM (not issued yet, or not reported by the network).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "usage_unavailable"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "esim_recycled: The eSIM was recycled after it expired or went unused. Buy a new eSIM.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "esim_recycled"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: Too many requests for this buyer key, or too many failed attempts on this order. Wait for Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "rate_limited"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "required": true
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "provider_unavailable: The eSIM provider is busy or did not answer. Retry after Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "provider_unavailable"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                },
                "required": true
              }
            }
          }
        },
        "security": [
          {
            "orderSecret": []
          },
          {
            "buyerKey": []
          }
        ]
      }
    },
    "/api/v1/webhook": {
      "get": {
        "operationId": "getWebhook",
        "summary": "Get the buyer's callback",
        "description": "The callback URL registered for this buyer key, if any. The signing secret is never shown again.",
        "tags": [
          "webhooks"
        ],
        "responses": {
          "200": {
            "description": "The current registration.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Webhook"
                }
              }
            }
          },
          "401": {
            "description": "buyer_key_required: Send the buyer key as Authorization: Bearer agsk_... It is returned once as buyerKey by createOrder. invalid_buyer_key: The buyer key is unknown. Omit Authorization on createOrder to get a new one; never retry with a new buyer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "buyer_key_required",
                            "invalid_buyer_key"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge: realm \"buyer key\" or \"order\".",
                "schema": {
                  "type": "string"
                },
                "required": true
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "buyerKey": []
          }
        ]
      },
      "put": {
        "operationId": "updateWebhook",
        "summary": "Register a callback for low-data events",
        "description": "Registers a public https:// URL (port 443, resolving only to public addresses) that receives signed esim.low_data events for every eSIM of this buyer. Returns the signing secret once; registering again rotates it. We try 3 times with a 5-second timeout and never follow redirects.",
        "tags": [
          "webhooks"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWebhookRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Registered. Store the secret now.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateWebhookResponse"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request: The request is malformed or fails validation. The message names the field and how to fix it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "buyer_key_required: Send the buyer key as Authorization: Bearer agsk_... It is returned once as buyerKey by createOrder. invalid_buyer_key: The buyer key is unknown. Omit Authorization on createOrder to get a new one; never retry with a new buyer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "buyer_key_required",
                            "invalid_buyer_key"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge: realm \"buyer key\" or \"order\".",
                "schema": {
                  "type": "string"
                },
                "required": true
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "buyerKey": []
          }
        ]
      },
      "delete": {
        "operationId": "deleteWebhook",
        "summary": "Remove the buyer's callback",
        "description": "Stops low-data events for this buyer key.",
        "tags": [
          "webhooks"
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteWebhookResponse"
                }
              }
            }
          },
          "401": {
            "description": "buyer_key_required: Send the buyer key as Authorization: Bearer agsk_... It is returned once as buyerKey by createOrder. invalid_buyer_key: The buyer key is unknown. Omit Authorization on createOrder to get a new one; never retry with a new buyer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "buyer_key_required",
                            "invalid_buyer_key"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge: realm \"buyer key\" or \"order\".",
                "schema": {
                  "type": "string"
                },
                "required": true
              }
            }
          },
          "500": {
            "description": "internal_error: Something went wrong on our side. Try again in a few seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong and what to do next."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "buyerKey": []
          }
        ]
      }
    }
  },
  "webhooks": {
    "esim.low_data": {
      "post": {
        "summary": "An eSIM is running low on data or about to expire",
        "description": "Sent to the URL registered with updateWebhook. Verify the AgentSIM-Signature header before trusting the body, and answer 2xx within 5 seconds.",
        "parameters": [
          {
            "name": "AgentSIM-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + \".\" + raw body)>"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received."
          }
        }
      }
    }
  }
}