{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/geogridapi-io/json-schema/geogridapi-io-batch-schema.json",
  "title": "Batch",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/geogridapi-io-openapi.json#/components/schemas/Batch",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "object": {
      "type": "string",
      "enum": [
        "batch"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "running",
        "completed"
      ]
    },
    "mode": {
      "type": "string"
    },
    "source": {
      "type": "string",
      "enum": [
        "api",
        "mcp",
        "console"
      ]
    },
    "shape": {
      "type": "string"
    },
    "size": {
      "type": "integer"
    },
    "density": {
      "type": [
        "string",
        "null"
      ]
    },
    "radius_km": {
      "type": "number"
    },
    "items_count": {
      "type": "integer"
    },
    "counts": {
      "type": "object",
      "properties": {
        "queued": {
          "type": "integer"
        },
        "pending": {
          "type": "integer"
        },
        "running": {
          "type": "integer"
        },
        "completed": {
          "type": "integer"
        },
        "failed": {
          "type": "integer"
        }
      }
    },
    "credits_estimated": {
      "type": "integer"
    },
    "credits_charged": {
      "type": "integer"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/BatchItem"
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "launched_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "$defs": {
    "BatchItem": {
      "type": "object",
      "properties": {
        "index": {
          "type": "integer"
        },
        "keyword": {
          "type": "string"
        },
        "query": {
          "type": [
            "string",
            "null"
          ]
        },
        "place": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "place_id": {
              "type": "string"
            },
            "name": {
              "type": [
                "string",
                "null"
              ]
            },
            "address": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "status": {
          "type": "string",
          "enum": [
            "queued",
            "pending",
            "running",
            "completed",
            "failed"
          ]
        },
        "grid_id": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "points_total": {
          "type": [
            "integer",
            "null"
          ]
        },
        "points_charged": {
          "type": "integer"
        },
        "summary": {
          "$ref": "#/$defs/GridSummary"
        },
        "error": {
          "$ref": "#/$defs/GridError"
        }
      }
    },
    "GridError": {
      "type": [
        "object",
        "null"
      ],
      "description": "Why a grid (or a batch item) failed; null otherwise.",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "GridSummary": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "average_rank": {
          "type": [
            "number",
            "null"
          ],
          "description": "Mean rank over the points where the listing appears."
        },
        "average_rank_with_misses": {
          "type": [
            "number",
            "null"
          ],
          "description": "Mean rank with misses counted as 21."
        },
        "top3_points": {
          "type": "integer"
        },
        "found_points": {
          "type": "integer"
        }
      }
    }
  }
}