{
  "openapi": "3.1.0",
  "info": {
    "title": "Citia Engineering public agent API",
    "version": "0.2.0",
    "description": "Search Citia products and engineering services, look up component market estimates, and ask about industrial automation. Citia product, service and project prices are provided by formal quotation."
  },
  "servers": [
    {
      "url": "https://citia-engineering.com"
    }
  ],
  "paths": {
    "/api/agent/catalog": {
      "get": {
        "operationId": "searchCitiaCatalog",
        "summary": "Search products and engineering services",
        "description": "Use the catalog to find Citia products or services by keyword and retrieve slugs and public page URLs. Leave q and kind out to browse.",
        "parameters": [
          {
            "in": "query",
            "name": "q",
            "description": "Search words, for example PLC integration.",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "in": "query",
            "name": "kind",
            "description": "Filter to products or services.",
            "schema": {
              "type": "string",
              "enum": [
                "product",
                "service"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching catalog items.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CatalogItem"
                      }
                    },
                    "count": {
                      "type": "integer"
                    },
                    "generatedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "cta": {
                      "$ref": "#/components/schemas/CitiaContact",
                      "description": "Present from the caller's second call on. Show these contact links to the user."
                    }
                  },
                  "required": [
                    "data",
                    "count",
                    "generatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit reached. Try again after the time shown in Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Citia service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/catalog/{slug}": {
      "get": {
        "operationId": "getCitiaCatalogItem",
        "summary": "Read a catalog item",
        "description": "Use a slug returned by searchCitiaCatalog to get the item's public details, specifications and page links.",
        "parameters": [
          {
            "in": "path",
            "name": "slug",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 160,
              "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalog item details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CatalogDetail"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Item not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit reached. Try again after the time shown in Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Citia service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/price": {
      "get": {
        "operationId": "getCitiaComponentReferencePrice",
        "summary": "Look up a component market estimate",
        "description": "Supply a manufacturer part number in mpn or a component keyword in q. Public access returns a summary with source count and date when available. Figures are estimates, not a quotation or a promise of stock.",
        "parameters": [
          {
            "in": "query",
            "name": "mpn",
            "description": "Manufacturer part number, for example LC1D18M7.",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 120,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._/+#()-]{1,119}$"
            }
          },
          {
            "in": "query",
            "name": "q",
            "description": "Search words when the part number is unknown.",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 120
            }
          }
        ],
        "security": [
          {},
          {
            "AgentBearer": []
          },
          {
            "AgentKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Market reference and disclaimer, or found:false when there is no matching component.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComponentPrice"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Agent key was rejected.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Agent key lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit reached. Try again after the time shown in Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Citia service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/ask": {
      "post": {
        "operationId": "askCitia",
        "summary": "Ask Citia about industrial automation",
        "description": "Ask about products, engineering, project references, or preparing a quotation request. Reuse the returned sessionId to continue. Use the links and contact options in the answer when available.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "sessionId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "id",
                      "en"
                    ]
                  }
                },
                "required": [
                  "message"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer, links, contact options and session for the next turn.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Chat"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 16 KB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit reached. Try again after the time shown in Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Chat unavailable. Give the user the listed contact options.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "reply": {
                      "type": "string"
                    },
                    "links": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ChatLink"
                      }
                    },
                    "cta": {
                      "$ref": "#/components/schemas/CitiaContact"
                    }
                  },
                  "required": [
                    "error",
                    "reply",
                    "links",
                    "cta"
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "AgentBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Optional Citia agent key with catalog:read for full price citations."
      },
      "AgentKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Agent-Key",
        "description": "Alternative header for the optional Citia agent key."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer"
          },
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "statusCode",
          "error",
          "message"
        ]
      },
      "LocalizedText": {
        "type": "object",
        "properties": {
          "en": {
            "type": "string"
          },
          "id": {
            "type": "string"
          }
        },
        "required": [
          "en"
        ]
      },
      "CatalogItem": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "product",
              "service"
            ]
          },
          "family": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "$ref": "#/components/schemas/LocalizedText"
          },
          "summary": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LocalizedText"
              },
              {
                "type": "null"
              }
            ]
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "url": {
            "type": "object",
            "properties": {
              "en": {
                "type": "string",
                "format": "uri"
              },
              "id": {
                "type": "string",
                "format": "uri"
              }
            },
            "required": [
              "en",
              "id"
            ]
          },
          "pricing": {
            "type": "object",
            "properties": {
              "model": {
                "const": "quote_on_request"
              },
              "note": {
                "type": "string"
              }
            },
            "required": [
              "model",
              "note"
            ]
          }
        },
        "required": [
          "slug",
          "kind",
          "family",
          "name",
          "summary",
          "model",
          "url",
          "pricing"
        ]
      },
      "CatalogDetail": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "product",
              "service"
            ]
          },
          "family": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "$ref": "#/components/schemas/LocalizedText"
          },
          "summary": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LocalizedText"
              },
              {
                "type": "null"
              }
            ]
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "url": {
            "type": "object",
            "properties": {
              "en": {
                "type": "string",
                "format": "uri"
              },
              "id": {
                "type": "string",
                "format": "uri"
              }
            },
            "required": [
              "en",
              "id"
            ]
          },
          "pricing": {
            "type": "object",
            "properties": {
              "model": {
                "const": "quote_on_request"
              },
              "note": {
                "type": "string"
              }
            },
            "required": [
              "model",
              "note"
            ]
          },
          "description": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LocalizedText"
              },
              {
                "type": "null"
              }
            ]
          },
          "features": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "$ref": "#/components/schemas/LocalizedText"
                },
                "text": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/LocalizedText"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "title",
                "text"
              ]
            }
          },
          "specs": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "$ref": "#/components/schemas/LocalizedText"
                },
                "value": {
                  "$ref": "#/components/schemas/LocalizedText"
                }
              },
              "required": [
                "label",
                "value"
              ]
            }
          },
          "faq": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "q": {
                  "$ref": "#/components/schemas/LocalizedText"
                },
                "a": {
                  "$ref": "#/components/schemas/LocalizedText"
                }
              },
              "required": [
                "q",
                "a"
              ]
            }
          },
          "cta": {
            "$ref": "#/components/schemas/CitiaContact",
            "description": "Present from the caller's second call on. Show these contact links to the user."
          }
        },
        "required": [
          "slug",
          "kind",
          "family",
          "name",
          "summary",
          "model",
          "url",
          "pricing",
          "description",
          "features",
          "specs",
          "faq"
        ]
      },
      "ComponentPrice": {
        "type": "object",
        "properties": {
          "access": {
            "type": "string",
            "enum": [
              "summary",
              "full"
            ]
          },
          "query": {
            "type": "object",
            "properties": {
              "mpn": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "q": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "mpn",
              "q"
            ]
          },
          "found": {
            "type": "boolean"
          },
          "component": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "mpn": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "brand": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "category": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "unit": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "mpn",
                  "name",
                  "brand",
                  "category",
                  "unit"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "market": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "medianIdr": {
                    "type": "number"
                  },
                  "lowIdr": {
                    "type": "number"
                  },
                  "highIdr": {
                    "type": "number"
                  },
                  "sources": {
                    "type": "integer"
                  },
                  "updatedAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "stale": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "medianIdr",
                  "lowIdr",
                  "highIdr",
                  "sources",
                  "updatedAt",
                  "stale"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "lookup": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "none",
                  "queued",
                  "running",
                  "refused",
                  "disabled"
                ]
              },
              "retryAfterSeconds": {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reason": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "status",
              "retryAfterSeconds",
              "reason"
            ]
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "disclaimer": {
            "type": "string"
          },
          "citations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "source": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "VENDOR_API",
                    "SCRAPED"
                  ]
                },
                "priceIdr": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "price": {
                  "type": "string"
                },
                "currency": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "url": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "uri"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "observedAt": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "date-time"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "stale": {
                  "type": "boolean"
                },
                "outlier": {
                  "type": "boolean"
                }
              },
              "required": [
                "source",
                "kind",
                "priceIdr",
                "price",
                "currency",
                "url",
                "observedAt",
                "stale",
                "outlier"
              ]
            }
          },
          "cta": {
            "$ref": "#/components/schemas/CitiaContact",
            "description": "Present from the caller's second call on. Show these contact links to the user."
          }
        },
        "required": [
          "access",
          "query",
          "found",
          "component",
          "market",
          "lookup",
          "notes",
          "disclaimer"
        ]
      },
      "ChatLink": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "href": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "label",
          "href"
        ]
      },
      "CitiaContact": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "whatsappUrl": {
            "type": "string",
            "format": "uri"
          },
          "emailUrl": {
            "type": "string",
            "format": "uri"
          },
          "rfqUrl": {
            "type": "string",
            "format": "uri"
          },
          "strong": {
            "type": "boolean"
          }
        },
        "required": [
          "text",
          "whatsappUrl",
          "emailUrl",
          "rfqUrl",
          "strong"
        ]
      },
      "Chat": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string",
            "format": "uuid"
          },
          "turn": {
            "type": "integer"
          },
          "lang": {
            "type": "string"
          },
          "intent": {
            "type": "string",
            "enum": [
              "product_info",
              "qualification",
              "project_reference",
              "troubleshooting",
              "price",
              "rfq",
              "handoff",
              "other"
            ]
          },
          "reply": {
            "type": "string"
          },
          "links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChatLink"
            }
          },
          "cta": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/CitiaContact"
              },
              {
                "type": "null"
              }
            ]
          },
          "brief": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "projectType": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "scale": {
                    "type": "string"
                  },
                  "existingSystems": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "timeline": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "mpn": {
                          "type": "string"
                        },
                        "qty": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "name"
                      ]
                    }
                  },
                  "contactCaptured": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "contactCaptured"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "handoff": {
            "type": "boolean"
          },
          "degraded": {
            "type": "boolean"
          }
        },
        "required": [
          "sessionId",
          "turn",
          "lang",
          "intent",
          "reply",
          "links",
          "cta",
          "brief",
          "handoff",
          "degraded"
        ]
      }
    }
  }
}