{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/depixapp-com/json-schema/depixapp-com-product-get-response-schema.json",
  "title": "ProductGetResponse",
  "description": "Single product with checkout aggregates. NOTE: `product` mirrors the full database row (SELECT *), so additional columns may appear as the schema evolves — additionalProperties is intentionally open here.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/depixapp-com-products-api-openapi.yml#/components/schemas/ProductGetResponse",
  "type": "object",
  "required": [
    "product",
    "stats"
  ],
  "properties": {
    "product": {
      "type": "object",
      "description": "Full product row.",
      "properties": {
        "id": {
          "type": "string",
          "description": "Product id (prd_*)."
        },
        "merchant_id": {
          "type": "string",
          "description": "Owning merchant id."
        },
        "charge_state": {
          "allOf": [
            {
              "$ref": "#/$defs/ChargeState"
            }
          ],
          "description": "Derived payable state — charge rows only. Present here as well as on the list so a single-row read can answer what is owed today."
        },
        "slug": {
          "type": "string",
          "description": "URL slug."
        },
        "name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Product name."
        },
        "amount": {
          "type": "integer",
          "description": "Price in cents."
        },
        "description": {
          "type": [
            "string",
            "null"
          ],
          "description": "Product description."
        },
        "image_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Product image URL."
        },
        "callback_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Webhook endpoint for this product's checkouts."
        },
        "redirect_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Post-payment redirect."
        },
        "metadata": {
          "type": [
            "object",
            "string",
            "null"
          ],
          "description": "Metadata (parsed to an object when valid JSON)."
        },
        "expires_in": {
          "type": "integer",
          "description": "Checkout QR lifetime in seconds."
        },
        "active": {
          "type": "integer",
          "description": "1 = active, 0 = deactivated (raw SQLite boolean).",
          "enum": [
            0,
            1
          ]
        },
        "is_live": {
          "type": "integer",
          "description": "1 = live, 0 = sandbox (raw SQLite boolean).",
          "enum": [
            0,
            1
          ]
        },
        "position": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Pinned position on the public page (null = not pinned)."
        },
        "created_at": {
          "type": "string",
          "description": "Creation timestamp (RFC 3339 UTC)."
        },
        "updated_at": {
          "type": "string",
          "description": "Last update timestamp (RFC 3339 UTC)."
        }
      }
    },
    "stats": {
      "type": "object",
      "description": "Checkout aggregates for the product.",
      "required": [
        "total",
        "completed",
        "pending",
        "completed_amount"
      ],
      "additionalProperties": false,
      "properties": {
        "total": {
          "type": "integer",
          "description": "Total checkouts created from this product."
        },
        "completed": {
          "type": "integer",
          "description": "Completed checkouts."
        },
        "pending": {
          "type": "integer",
          "description": "Pending checkouts."
        },
        "completed_amount": {
          "type": "integer",
          "description": "Sum of completed amounts in cents."
        }
      }
    }
  },
  "$defs": {
    "ChargeState": {
      "type": "object",
      "description": "Derived payable state of a charge (kind='charge' product). Settlement is FIFO over the due-date series: the current cycle is selected by the number of cycles that EVER settled (a checkout that reached approved or completed — a later reversal does not rewind the series; re-billing a reversed cycle is the merchant's decision, not the API's) PLUS un-expired pending QRs, since a minted QR reserves the cycle it was priced for and two open QRs must never bill the same competência; the total is base + one-time fine + linear pro-rata interest (base × monthlyBps/10000 × daysLate/30), computed on the América/São_Paulo calendar (the due date itself is not late; lateness starts the next day) and clamped at the R$ 6.000 per-transaction cap.",
      "required": [
        "settled"
      ],
      "additionalProperties": false,
      "properties": {
        "settled": {
          "type": "boolean",
          "description": "True when a one-time charge is fully paid (every other field is then absent)."
        },
        "cycle_due_date": {
          "type": "string",
          "description": "Due date (YYYY-MM-DD) of the current — oldest unsettled — cycle."
        },
        "days_late": {
          "type": "integer",
          "description": "Days past the due date on the São Paulo calendar (0 = not late)."
        },
        "base_cents": {
          "type": "integer",
          "description": "Configured base amount in cents."
        },
        "fine_cents": {
          "type": "integer",
          "description": "One-time late fine in cents (0 when not late)."
        },
        "interest_cents": {
          "type": "integer",
          "description": "Accrued pro-rata interest in cents (0 when not late)."
        },
        "total_today_cents": {
          "type": "integer",
          "description": "What a QR created now charges: base + fine + interest, capped at 600000."
        },
        "capped": {
          "type": "boolean",
          "description": "True when base + encargos exceeded the per-transaction cap and the total was clamped."
        },
        "status": {
          "type": "string",
          "description": "Cycle status.",
          "enum": [
            "late",
            "due_today",
            "upcoming"
          ]
        },
        "open_past_due_cycles": {
          "type": "integer",
          "description": "Cycles already due and still unpaid (>1 means competências accumulated)."
        },
        "in_flight": {
          "type": "boolean",
          "description": "True when a processing checkout exists (Pix paid, settling) — present on list rows only."
        }
      }
    }
  }
}