{
  "openapi": "3.1.0",
  "info": {
    "title": "The Seller Public API",
    "version": "1.0.0",
    "summary": "WhatsApp Official API cost simulation from The Seller.",
    "description": "Public, read-only endpoints from The Seller (theseller.com.br), a Brazilian WhatsApp sales operations platform. No authentication is required. Use them to estimate how much it costs to send WhatsApp template messages in Brazil through the Official WhatsApp Business API (Meta fee by category, volume tiers and The Seller's per-message fee). The Seller platform API for customers is separate and is provided to Prime plan customers.",
    "contact": {
      "name": "The Seller",
      "email": "contato@theseller.com.br",
      "url": "https://www.theseller.com.br/contato"
    }
  },
  "externalDocs": {
    "description": "Developer docs",
    "url": "https://www.theseller.com.br/developers"
  },
  "servers": [
    {
      "url": "https://www.theseller.com.br"
    }
  ],
  "security": [],
  "tags": [
    {
      "name": "whatsapp-pricing",
      "description": "WhatsApp Official API message costs in Brazil."
    }
  ],
  "paths": {
    "/api/v1/whatsapp-pricing/simulate": {
      "get": {
        "operationId": "simulateWhatsAppMessageCost",
        "tags": [
          "whatsapp-pricing"
        ],
        "summary": "Estimate the cost of sending WhatsApp template messages",
        "description": "Returns the Meta fee (with marginal volume tiers), The Seller's per-message fee and the total and average cost in BRL for a number of WhatsApp template messages sent in Brazil.",
        "parameters": [
          {
            "name": "quantity",
            "in": "query",
            "required": true,
            "description": "Number of template messages to send.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000000000
            },
            "example": 10000
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Meta template category.",
            "schema": {
              "type": "string",
              "enum": [
                "marketing",
                "utility",
                "authentication"
              ],
              "default": "marketing"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "description": "Billing currency of the Meta WhatsApp Business account.",
            "schema": {
              "type": "string",
              "enum": [
                "BRL",
                "USD"
              ],
              "default": "BRL"
            }
          },
          {
            "name": "exchangeRate",
            "in": "query",
            "required": false,
            "description": "BRL per USD, used to convert the Meta fee when currency is USD.",
            "schema": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 100,
              "default": 5.4
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cost estimate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Simulation"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "HTTP method not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/whatsapp-pricing/rates": {
      "get": {
        "operationId": "getWhatsAppRateCard",
        "tags": [
          "whatsapp-pricing"
        ],
        "summary": "Get the WhatsApp Official API rate card used for estimates",
        "description": "Returns Meta's list rates and volume tiers for Brazil by category and currency, The Seller's per-message fee and the sources.",
        "responses": {
          "200": {
            "description": "Rate card.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateCard"
                }
              }
            }
          },
          "405": {
            "description": "HTTP method not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Category": {
        "type": "string",
        "enum": [
          "marketing",
          "utility",
          "authentication"
        ]
      },
      "Currency": {
        "type": "string",
        "enum": [
          "BRL",
          "USD"
        ]
      },
      "Tier": {
        "type": "object",
        "required": [
          "quantity",
          "rate",
          "cost",
          "from",
          "to"
        ],
        "properties": {
          "quantity": {
            "type": "integer",
            "description": "Messages billed in this tier."
          },
          "rate": {
            "type": "number",
            "description": "Meta fee per message in this tier (account currency)."
          },
          "cost": {
            "type": "number",
            "description": "Meta fee for this tier (account currency)."
          },
          "from": {
            "type": "integer"
          },
          "to": {
            "type": "integer"
          }
        }
      },
      "Simulation": {
        "type": "object",
        "required": [
          "input",
          "meta",
          "theSeller",
          "totalCostBRL",
          "averageCostPerMessageBRL",
          "rateCardUpdatedAt"
        ],
        "properties": {
          "input": {
            "type": "object",
            "properties": {
              "quantity": {
                "type": "integer"
              },
              "category": {
                "$ref": "#/components/schemas/Category"
              },
              "currency": {
                "$ref": "#/components/schemas/Currency"
              },
              "exchangeRate": {
                "type": "number"
              },
              "market": {
                "type": "string",
                "const": "brazil"
              }
            }
          },
          "meta": {
            "type": "object",
            "required": [
              "currency",
              "cost",
              "costBRL",
              "effectiveRate",
              "tiers"
            ],
            "properties": {
              "currency": {
                "$ref": "#/components/schemas/Currency"
              },
              "cost": {
                "type": "number",
                "description": "Meta fee in the account currency."
              },
              "costBRL": {
                "type": "number",
                "description": "Meta fee converted to BRL."
              },
              "effectiveRate": {
                "type": "number",
                "description": "Average Meta fee per message (account currency)."
              },
              "tiers": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Tier"
                }
              }
            }
          },
          "theSeller": {
            "type": "object",
            "required": [
              "ratePerMessageBRL",
              "costBRL"
            ],
            "properties": {
              "ratePerMessageBRL": {
                "type": "number"
              },
              "costBRL": {
                "type": "number"
              }
            }
          },
          "totalCostBRL": {
            "type": "number",
            "description": "Meta fee plus The Seller fee, in BRL."
          },
          "averageCostPerMessageBRL": {
            "type": "number"
          },
          "rateCardUpdatedAt": {
            "type": "string"
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "RateCard": {
        "type": "object",
        "required": [
          "market",
          "updatedAt",
          "metaListRates",
          "theSellerRatePerMessageBRL"
        ],
        "properties": {
          "market": {
            "type": "string",
            "const": "brazil"
          },
          "updatedAt": {
            "type": "string"
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Category"
            }
          },
          "currencies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Currency"
            }
          },
          "metaListRates": {
            "type": "object",
            "description": "currency -> market -> category -> rate"
          },
          "metaVolumeTiers": {
            "type": "object",
            "description": "currency -> market -> category -> tiers"
          },
          "theSellerRatePerMessageBRL": {
            "type": "number"
          },
          "defaultExchangeRate": {
            "type": "number"
          },
          "sources": {
            "type": "object",
            "properties": {
              "pricing": {
                "type": "string",
                "format": "uri"
              },
              "billingRules": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "hint",
              "docs"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "invalid_parameter",
                  "missing_parameter",
                  "not_found",
                  "method_not_allowed"
                ]
              },
              "message": {
                "type": "string"
              },
              "hint": {
                "type": "string",
                "description": "How to fix the request."
              },
              "docs": {
                "type": "string",
                "format": "uri"
              },
              "parameter": {
                "type": "string",
                "description": "The offending parameter, when applicable."
              }
            }
          }
        }
      }
    }
  }
}