{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/trymnemo-com/json-schema/trymnemo-com-namespace-status-schema.json",
  "title": "NamespaceStatus",
  "x-generated": "2026-11-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/trymnemo-com-openapi.json#/components/schemas/NamespaceStatus",
  "type": "object",
  "required": [
    "tenant_id",
    "storage_class",
    "durable",
    "state",
    "expires_at",
    "seconds_remaining",
    "objects_used",
    "objects_limit",
    "bytes_used",
    "bytes_limit",
    "upgrade_available"
  ],
  "properties": {
    "tenant_id": {
      "type": "string"
    },
    "storage_class": {
      "type": "string"
    },
    "durable": {
      "type": "boolean"
    },
    "state": {
      "type": "string",
      "enum": [
        "ACTIVE",
        "EXPIRED",
        "PROMOTING",
        "PERSISTENT",
        "PURGING",
        "PURGED"
      ]
    },
    "expires_at": {
      "type": "string",
      "format": "date-time",
      "description": "The namespace's original, fixed expiry. A funded namespace keeps working past it until `retained_until`."
    },
    "seconds_remaining": {
      "type": "integer",
      "description": "Seconds until `expires_at`. On a funded namespace use `retained_seconds_remaining`."
    },
    "objects_used": {
      "type": "integer"
    },
    "objects_limit": {
      "type": "integer"
    },
    "bytes_used": {
      "type": "integer"
    },
    "bytes_limit": {
      "type": "integer"
    },
    "upgrade_available": {
      "type": "boolean"
    },
    "warning": {
      "$ref": "#/$defs/ExpiryWarning"
    },
    "funded_until": {
      "type": "string",
      "format": "date-time",
      "description": "Funded namespaces only: end of the burst's funded window (credits expire then)."
    },
    "retained_until": {
      "type": "string",
      "format": "date-time",
      "description": "Funded namespaces only: funded_until + 24 h grace. Data is kept until then; verify is refused during the grace."
    },
    "retained_seconds_remaining": {
      "type": "integer",
      "description": "Funded namespaces only: seconds until retained_until."
    },
    "payment_menu": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PaymentMenuEntry"
      },
      "description": "On a deployment that takes machine payments: the offers this namespace can buy now, and the rails accepting payment for each. Authoritative for discovery: an offer or rail not listed cannot be bought now, and the namespace's own limits apply (expiry, a funded namespace is offered refills only). A listed burst_500 can still be answered 503 funded_capacity_unavailable (no challenge, nothing charged) or 503 payment_processing (a burst payment is already being confirmed)."
    }
  },
  "$defs": {
    "ExpiryWarning": {
      "type": "object",
      "description": "Attached once, to the first response after 75% of the lifetime has passed. On a funded namespace (burst_500) the one warning comes with the last 24 hours of retention (the grace), on the status call, and its expires_at is retained_until.",
      "required": [
        "code",
        "expires_at",
        "seconds_remaining",
        "action_required",
        "data_after_expiry"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "EPHEMERAL_STORAGE_EXPIRING"
          ]
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "seconds_remaining": {
          "type": "integer"
        },
        "action_required": {
          "type": "string",
          "enum": [
            "upgrade_to_persistent"
          ]
        },
        "data_after_expiry": {
          "type": "string",
          "enum": [
            "purged"
          ]
        }
      }
    },
    "PaymentMenuEntry": {
      "type": "object",
      "required": [
        "id",
        "price_usd",
        "credits",
        "route",
        "rails"
      ],
      "description": "One offer this namespace can buy right now, and the rails accepting payment for it now. Informational: the route's 402 challenge binds the price.",
      "properties": {
        "id": {
          "type": "string",
          "enum": [
            "single_verify",
            "burst_500"
          ]
        },
        "price_usd": {
          "type": "string"
        },
        "credits": {
          "type": "integer"
        },
        "route": {
          "type": "string"
        },
        "rails": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PaymentRail"
          }
        },
        "funded_window_days": {
          "type": "integer",
          "description": "burst_500 only: credits are usable for this many days from settlement."
        },
        "grace_hours": {
          "type": "integer",
          "description": "burst_500 only: hours after funded_until during which verify is refused and data is kept."
        },
        "storage_allowance_bytes": {
          "type": "integer",
          "description": "burst_500 only: accounted-byte allowance of a funded namespace."
        }
      }
    },
    "PaymentRail": {
      "type": "object",
      "required": [
        "id",
        "protocol",
        "header"
      ],
      "properties": {
        "id": {
          "type": "string",
          "enum": [
            "x402",
            "mpp_tempo",
            "stripe_spt"
          ]
        },
        "protocol": {
          "type": "string",
          "enum": [
            "x402",
            "mpp"
          ]
        },
        "scheme": {
          "type": "string",
          "description": "x402 scheme (`exact`)."
        },
        "method": {
          "type": "string",
          "description": "MPP method: `tempo` or `stripe`."
        },
        "intent": {
          "type": "string",
          "description": "MPP intent (`charge`)."
        },
        "header": {
          "type": "string",
          "description": "Where the payment is sent: `PAYMENT-SIGNATURE` (x402) or `Authorization: Payment` (MPP)."
        },
        "network": {
          "type": "string",
          "description": "CAIP-2 network, when the rail has one (eip155:8453 for x402, eip155:4217 for Tempo)."
        }
      }
    }
  }
}