{
  "openapi": "3.0.3",
  "info": {"title": "Open4X Batch Conversation Status", "version": "2026.09.14-status.1", "description": "Server-only delegated viewer queries. Requires conversation:read. The merchant must derive the viewer from authenticated identity and validate business authorization. Only active participants and publicly visible messages count. Unknown and inaccessible contexts are indistinguishable. No read receipts are written."},
  "servers": [{"url": "https://api.open4x.com", "description": "Production"}],
  "security": [{"ApiKeyBearer": []}],
  "paths": {
    "/v1/conversations/order-statuses": {
      "post": {
        "operationId": "getOrderConversationStatuses",
        "summary": "Batch order status for a server-authenticated participant",
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["external_participant_id", "external_order_ids"], "properties": {"external_participant_id": {"$ref": "#/components/schemas/Identifier"}, "external_order_ids": {"$ref": "#/components/schemas/Identifiers"}}}}}},
        "responses": {
          "200": {"description": "Deduplicated IDs in first-occurrence order. Cache-Control: no-store.", "content": {"application/json": {"schema": {"type": "object", "required": ["data"], "properties": {"data": {"type": "array", "items": {"allOf": [{"$ref": "#/components/schemas/Status"}, {"type": "object", "required": ["external_order_id"], "properties": {"external_order_id": {"type": "string"}}}]}}}}}}},
          "400": {"$ref": "#/components/responses/Error"}, "401": {"$ref": "#/components/responses/Error"}, "403": {"$ref": "#/components/responses/Error"}, "429": {"$ref": "#/components/responses/Error"}, "500": {"$ref": "#/components/responses/Error"}
        }
      }
    },
    "/v1/conversations/context-statuses": {
      "post": {
        "operationId": "getContextConversationStatuses",
        "summary": "Batch status for any context type",
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["external_participant_id", "context_type", "context_ids"], "properties": {"external_participant_id": {"$ref": "#/components/schemas/Identifier"}, "context_type": {"$ref": "#/components/schemas/Identifier"}, "context_ids": {"$ref": "#/components/schemas/Identifiers"}}}}}},
        "responses": {
          "200": {"description": "Deduplicated IDs in first-occurrence order. Cache-Control: no-store.", "content": {"application/json": {"schema": {"type": "object", "required": ["data"], "properties": {"data": {"type": "array", "items": {"allOf": [{"$ref": "#/components/schemas/Status"}, {"type": "object", "required": ["context_id"], "properties": {"context_id": {"type": "string"}}}]}}}}}}},
          "400": {"$ref": "#/components/responses/Error"}, "401": {"$ref": "#/components/responses/Error"}, "403": {"$ref": "#/components/responses/Error"}, "429": {"$ref": "#/components/responses/Error"}, "500": {"$ref": "#/components/responses/Error"}
        }
      }
    }
  },
  "components": {
    "securitySchemes": {"ApiKeyBearer": {"type": "http", "scheme": "bearer", "description": "Server API Key with conversation:read; not a Widget or Workbench session"}},
    "schemas": {
      "Identifier": {"type": "string", "minLength": 1, "maxLength": 200, "description": "No control characters or leading/trailing whitespace. External participant ID must match an active conversation participant."},
      "Identifiers": {"type": "array", "minItems": 1, "maxItems": 100, "items": {"$ref": "#/components/schemas/Identifier"}},
      "Status": {"type": "object", "required": ["has_conversation", "has_messages", "has_unread", "unread_count", "conversation_count"], "properties": {"has_conversation": {"type": "boolean"}, "has_messages": {"type": "boolean"}, "has_unread": {"type": "boolean"}, "unread_count": {"type": "integer", "minimum": 0}, "conversation_count": {"type": "integer", "minimum": 0}}},
      "Error": {"type": "object", "required": ["error"], "properties": {"error": {"type": "string"}, "code": {"type": "string"}, "request_id": {"type": "string"}}}
    },
    "responses": {"Error": {"description": "400 invalid input; 401 missing/invalid authentication; 403 wrong credential type or scope; 429 rate/quota limit; 500 server error. Existing gateway policies apply.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}
  }
}
