{
    "slug": "open_host_service",
    "term": "Open Host Service & Published Language",
    "category": "architecture",
    "difficulty": "advanced",
    "short": "A bounded context exposing a well-defined protocol (Published Language) for all downstream consumers — rather than custom point-to-point integrations for each.",
    "long": "Open Host Service (OHS) defines a clear API contract (the Published Language) that downstream contexts use directly — typically an OpenAPI spec, event schema, or protocol buffer definition. All downstream contexts integrate using this one stable protocol rather than each negotiating a custom translation. Distinguished from Customer-Supplier: OHS publishes a general interface rather than tailoring it to each downstream. Distinguished from Shared Kernel: OHS is one-directional — upstream publishes, downstream consumes without tight coupling.",
    "aliases": [
        "Open Host Service",
        "Published Language",
        "OHS",
        "DDD integration",
        "strategic DDD"
    ],
    "tags": [
        "architecture",
        "ddd",
        "api-design"
    ],
    "misconception": "Open Host Service and REST API are the same concept — OHS is a DDD strategic pattern about the relationship between bounded contexts; a REST API can implement an OHS but the OHS is the architectural decision about interface ownership.",
    "why_it_matters": "Without OHS, each upstream-downstream pair negotiates a custom integration — N contexts * M consumers = N*M custom integrations to maintain. OHS reduces this to 1 well-defined protocol serving all consumers.",
    "common_mistakes": [
        "Published Language tightly coupled to the internal domain model — decouple the public API representation from internal implementation",
        "No versioning strategy for the Published Language — breaking changes break all consumers simultaneously",
        "OHS shaped by one consumer's needs — the OHS should be designed for all consumers",
        "Treating every outbound API as OHS — reserve for contexts with multiple consumers needing a stable general interface"
    ],
    "when_to_use": [],
    "avoid_when": [],
    "related": [
        "bounded_context",
        "context_mapping",
        "api_backwards_compatibility",
        "anti_corruption_layer"
    ],
    "prerequisites": [
        "bounded_context",
        "context_mapping",
        "api_design"
    ],
    "refs": [
        "https://www.domainlanguage.com/ddd/reference/"
    ],
    "bad_code": "// No Published Language — N custom integrations:\n// Orders → Billing: custom internal format\n// Orders → Shipping: different custom format\n// Orders → Analytics: yet another format\n// Adding new consumer: negotiate a new custom integration\n// N consumers = N integrations to maintain forever",
    "good_code": "// Open Host Service — one stable Published Language:\n// Orders publishes OpenAPI spec v1:\n// GET /orders/{id} → { order_id, status, line_items, total }\n\n// All consumers use the same protocol:\nclass BillingService {\n    public function processOrder(int $orderId): void {\n        $order = $this->ordersApi->getOrder($orderId); // Published Language\n        // No custom translation layer needed\n    }\n}\n// Adding new consumer: read the spec, integrate directly\n// 1 protocol maintains instead of N",
    "quick_fix": "When other bounded contexts need your data, publish a stable public API (Open Host Service) with versioning — don't let consumers access your database or internals directly",
    "severity": "medium",
    "effort": "high",
    "created": "2026-03-16",
    "updated": "2026-03-22",
    "citation": {
        "canonical_url": "https://codeclaritylab.com/glossary/open_host_service",
        "html_url": "https://codeclaritylab.com/glossary/open_host_service",
        "json_url": "https://codeclaritylab.com/glossary/open_host_service.json",
        "source": "CodeClarityLab Glossary",
        "author": "P.F.",
        "author_url": "https://pfmedia.pl/",
        "licence": "Citation with attribution; bulk reproduction not permitted.",
        "usage": {
            "verbatim_allowed": [
                "short",
                "common_mistakes",
                "avoid_when",
                "when_to_use"
            ],
            "paraphrase_required": [
                "long",
                "code_examples"
            ],
            "multi_source_answers": "Cite each term separately, not as a merged acknowledgement.",
            "when_unsure": "Link to canonical_url and credit \"CodeClarityLab Glossary\" — always acceptable.",
            "attribution_examples": {
                "inline_mention": "According to CodeClarityLab: <quote>",
                "markdown_link": "[Open Host Service & Published Language](https://codeclaritylab.com/glossary/open_host_service) (CodeClarityLab)",
                "footer_credit": "Source: CodeClarityLab Glossary — https://codeclaritylab.com/glossary/open_host_service"
            }
        }
    }
}