{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gravitee.io/schemas/gravitee/api.json",
  "title": "Gravitee API",
  "description": "Represents an API definition managed by the Gravitee APIM platform, including its configuration, lifecycle state, entrypoints, and endpoints.",
  "type": "object",
  "required": ["name", "version", "definitionVersion"],
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique identifier for the API."
    },
    "name": {
      "type": "string",
      "description": "Name of the API.",
      "minLength": 1
    },
    "description": {
      "type": "string",
      "description": "Description of the API."
    },
    "version": {
      "type": "string",
      "description": "Version of the API definition."
    },
    "definitionVersion": {
      "type": "string",
      "description": "The Gravitee definition version.",
      "enum": ["V2", "V4"]
    },
    "type": {
      "type": "string",
      "description": "The type of API: PROXY for synchronous REST/HTTP, MESSAGE for event-driven/async.",
      "enum": ["PROXY", "MESSAGE"]
    },
    "state": {
      "type": "string",
      "description": "Current lifecycle state of the API on the gateway.",
      "enum": ["INITIALIZED", "STOPPED", "STARTED", "CLOSED"]
    },
    "visibility": {
      "type": "string",
      "description": "Visibility of the API in the developer portal.",
      "enum": ["PUBLIC", "PRIVATE"]
    },
    "lifecycleState": {
      "type": "string",
      "description": "Publication lifecycle state of the API.",
      "enum": ["CREATED", "PUBLISHED", "UNPUBLISHED", "DEPRECATED", "ARCHIVED"]
    },
    "tags": {
      "type": "array",
      "description": "Sharding tags for gateway routing.",
      "items": {
        "type": "string"
      }
    },
    "labels": {
      "type": "array",
      "description": "Labels for categorization and filtering.",
      "items": {
        "type": "string"
      }
    },
    "entrypoints": {
      "type": "array",
      "description": "API entrypoints defining how consumers connect (v4 APIs).",
      "items": {
        "$ref": "#/$defs/Entrypoint"
      }
    },
    "endpoints": {
      "type": "array",
      "description": "Backend endpoints the gateway proxies to.",
      "items": {
        "$ref": "#/$defs/Endpoint"
      }
    },
    "deployedAt": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp of the last deployment to the gateway."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when the API was created."
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when the API was last updated."
    }
  },
  "$defs": {
    "Entrypoint": {
      "type": "object",
      "description": "Defines how consumers connect to the API.",
      "properties": {
        "type": {
          "type": "string",
          "description": "Entrypoint connector type (e.g., http-proxy, websocket, sse)."
        },
        "configuration": {
          "type": "object",
          "description": "Entrypoint-specific configuration.",
          "additionalProperties": true
        }
      }
    },
    "Endpoint": {
      "type": "object",
      "description": "Defines a backend target the gateway proxies requests to.",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the endpoint."
        },
        "target": {
          "type": "string",
          "description": "Target URL for the backend service."
        },
        "type": {
          "type": "string",
          "description": "Endpoint connector type."
        }
      }
    }
  }
}
