{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/email-validation-org/json-schema/email-validation-org-usage-response-schema.json",
  "title": "UsageResponse",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/email-validation-org-openapi.json#/components/schemas/UsageResponse",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "from",
    "to",
    "group_by",
    "totals",
    "items"
  ],
  "properties": {
    "from": {
      "type": "string",
      "format": "date",
      "description": "First day included (UTC)."
    },
    "to": {
      "type": "string",
      "format": "date",
      "description": "Last day included (UTC)."
    },
    "group_by": {
      "type": "string",
      "enum": [
        "day",
        "key"
      ],
      "description": "One item per `day` or per API `key`."
    },
    "totals": {
      "$ref": "#/$defs/UsageTotals"
    },
    "items": {
      "type": "array",
      "description": "One item per day (`group_by=day`) or per API key (`group_by=key`).",
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/UsageDay"
          },
          {
            "$ref": "#/$defs/UsageByKey"
          }
        ]
      }
    }
  },
  "$defs": {
    "StatusCountsApprox": {
      "type": "object",
      "description": "Results by status (approximate; may lag by up to an hour).",
      "additionalProperties": false,
      "properties": {
        "valid": {
          "type": "integer",
          "minimum": 0
        },
        "invalid": {
          "type": "integer",
          "minimum": 0
        },
        "catch_all": {
          "type": "integer",
          "minimum": 0
        },
        "unknown": {
          "type": "integer",
          "minimum": 0
        },
        "disposable": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "valid",
        "invalid",
        "catch_all",
        "unknown",
        "disposable"
      ]
    },
    "UsageByKey": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "key_id",
        "name",
        "last4",
        "credits_used"
      ],
      "properties": {
        "key_id": {
          "type": "string",
          "pattern": "^key_[0-9A-Za-z]{22}$",
          "description": "API key id (never the key itself)."
        },
        "name": {
          "type": [
            "string",
            "null"
          ],
          "description": "The name you gave the key (null for a deleted key)."
        },
        "last4": {
          "type": [
            "string",
            "null"
          ],
          "description": "Last 4 characters of the key, as shown in the dashboard."
        },
        "credits_used": {
          "type": "integer",
          "minimum": 0,
          "description": "Credits used with this key in the range, from the credit ledger (exact). Bulk jobs and dashboard checks are not attributed to a key."
        }
      }
    },
    "UsageDay": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "date",
        "credits_used",
        "by_status"
      ],
      "properties": {
        "date": {
          "type": "string",
          "format": "date"
        },
        "credits_used": {
          "type": "integer",
          "minimum": 0,
          "description": "Credits used that day, from the credit ledger (exact)."
        },
        "by_status": {
          "$ref": "#/$defs/StatusCountsApprox"
        }
      }
    },
    "UsageTotals": {
      "type": "object",
      "description": "Totals of the whole account for the range, whatever `group_by`: API, MCP, dashboard and bulk usage. With `group_by=key` they can be larger than the sum of the items, because bulk jobs and dashboard checks are not tied to a key.",
      "additionalProperties": false,
      "required": [
        "credits_used",
        "by_status"
      ],
      "properties": {
        "credits_used": {
          "type": "integer",
          "minimum": 0,
          "description": "Credits used in the range, from the credit ledger (exact)."
        },
        "by_status": {
          "$ref": "#/$defs/StatusCountsApprox"
        }
      }
    }
  }
}