{
  "openapi": "3.1.0",
  "info": {
    "title": "TMG Growth API",
    "version": "1.0.0",
    "summary": "Property lead generation services for developers and real estate agents.",
    "description": "Meta lead generation for property. Pay-per-lead buyer acquisition for property developers, and vendor-paid (VPA) listing campaigns for real estate agents in Australia and New Zealand.\n\nUse this API to look up TMG Growth services and listing-campaign packages, and to submit a vendor-paid listing campaign on behalf of a real estate agent (with their consent). No authentication. Errors use RFC 9457 problem details with machine-readable `code` and `hint` fields.",
    "contact": {
      "name": "TMG Growth",
      "email": "callen@tmggrowth.com",
      "url": "https://www.tmggrowth.com/contact/"
    },
    "termsOfService": "https://www.tmggrowth.com/privacy/"
  },
  "externalDocs": {
    "description": "Developer documentation",
    "url": "https://www.tmggrowth.com/api-docs/"
  },
  "servers": [
    {
      "url": "https://www.tmggrowth.com",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "meta",
      "description": "API discovery and health"
    },
    {
      "name": "catalogue",
      "description": "Services and packages"
    },
    {
      "name": "campaigns",
      "description": "Listing campaign submissions"
    }
  ],
  "paths": {
    "/api": {
      "get": {
        "operationId": "getApiIndex",
        "tags": [
          "meta"
        ],
        "summary": "API index",
        "description": "Lists every endpoint with its operationId plus links to docs and this spec.",
        "responses": {
          "200": {
            "description": "API index",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiIndex"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "tags": [
          "meta"
        ],
        "summary": "Health check",
        "description": "Returns ok when the API is serving requests.",
        "responses": {
          "200": {
            "description": "Service is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/api/services": {
      "get": {
        "operationId": "listServices",
        "tags": [
          "catalogue"
        ],
        "summary": "List services",
        "description": "Returns the two TMG Growth services: pay-per-lead buyer leads for property developers, and vendor-paid listing campaigns for real estate agents. Use this to decide which service fits a user.",
        "responses": {
          "200": {
            "description": "Services",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/api/packages": {
      "get": {
        "operationId": "listPackages",
        "tags": [
          "catalogue"
        ],
        "summary": "List listing-campaign packages",
        "description": "Returns the vendor-paid listing campaign packages for real estate agents, with prices for Australia ($ +GST) and New Zealand (NZD), duration, reach and inclusions. Pass a package `id` to createCampaign.",
        "responses": {
          "200": {
            "description": "Packages",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PackageList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/api/campaigns": {
      "post": {
        "operationId": "createCampaign",
        "tags": [
          "campaigns"
        ],
        "summary": "Submit a vendor-paid listing campaign",
        "description": "Submits a listing campaign for a real estate agent. The campaign is funded from the vendor advertising budget (VPA) and goes live within 24 hours. Only call this with the agent's explicit consent. Set dry_run=true to validate the request without submitting it.",
        "parameters": [
          {
            "name": "dry_run",
            "in": "query",
            "required": false,
            "description": "When true, validate and return the normalised submission without submitting it.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CampaignRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dry run: the request is valid (nothing was submitted)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CampaignDryRun"
                }
              }
            }
          },
          "202": {
            "description": "Campaign received",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CampaignAccepted"
                }
              }
            }
          },
          "400": {
            "description": "Body is not valid JSON or not an object",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type is not application/json",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "One or more fields failed validation; see `errors`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many submissions from this client",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "502": {
            "description": "Submission could not be forwarded; retry later",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Problem": {
        "description": "Error (RFC 9457 problem details)",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details with agent-friendly extensions.",
        "required": [
          "type",
          "title",
          "status",
          "code",
          "detail",
          "hint"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "code": {
            "type": "string",
            "description": "Stable machine-readable error code",
            "enum": [
              "not_found",
              "method_not_allowed",
              "unsupported_media_type",
              "invalid_json",
              "invalid_body",
              "validation_failed",
              "rate_limited",
              "upstream_unavailable"
            ]
          },
          "detail": {
            "type": "string"
          },
          "hint": {
            "type": "string",
            "description": "How to resolve the error"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ApiIndex": {
        "type": "object",
        "required": [
          "name",
          "endpoints"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          },
          "openapi": {
            "type": "string",
            "format": "uri"
          },
          "contact": {
            "type": "string",
            "format": "email"
          },
          "endpoints": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "method",
                "path",
                "operationId"
              ],
              "properties": {
                "method": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                },
                "operationId": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Health": {
        "type": "object",
        "required": [
          "status",
          "time"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok"
            ]
          },
          "time": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Service": {
        "type": "object",
        "required": [
          "id",
          "name",
          "audience",
          "pricing",
          "url",
          "action"
        ],
        "properties": {
          "id": {
            "type": "string",
            "enum": [
              "developer-pay-per-lead",
              "agent-vpa-campaign"
            ]
          },
          "name": {
            "type": "string"
          },
          "audience": {
            "type": "string"
          },
          "pricing": {
            "type": "string"
          },
          "launch": {
            "type": "string"
          },
          "howToStart": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "action": {
            "type": "string",
            "format": "uri",
            "description": "Where a user takes the next step"
          }
        }
      },
      "ServiceList": {
        "type": "object",
        "required": [
          "services"
        ],
        "properties": {
          "provider": {
            "type": "string"
          },
          "areaServed": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "services": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Service"
            }
          }
        }
      },
      "Package": {
        "type": "object",
        "required": [
          "id",
          "name",
          "amount",
          "currency",
          "durationDays",
          "reach"
        ],
        "properties": {
          "id": {
            "type": "string",
            "enum": [
              "starter",
              "growth",
              "pro",
              "elite"
            ]
          },
          "name": {
            "type": "string"
          },
          "amount": {
            "type": "integer",
            "description": "Australian price per campaign, excluding GST"
          },
          "currency": {
            "type": "string",
            "enum": [
              "AUD"
            ]
          },
          "taxNote": {
            "type": "string",
            "description": "Australian prices exclude GST",
            "enum": [
              "+GST"
            ]
          },
          "prices": {
            "type": "object",
            "description": "Price per country. AU excludes GST; NZ is in NZD.",
            "required": [
              "AU",
              "NZ"
            ],
            "properties": {
              "AU": {
                "$ref": "#/components/schemas/Price"
              },
              "NZ": {
                "$ref": "#/components/schemas/Price"
              }
            }
          },
          "durationDays": {
            "type": "integer"
          },
          "reach": {
            "type": "string"
          },
          "recommended": {
            "type": "boolean"
          },
          "fundedBy": {
            "type": "string"
          },
          "features": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Price": {
        "type": "object",
        "required": [
          "amount",
          "currency",
          "display"
        ],
        "properties": {
          "amount": {
            "type": "integer"
          },
          "currency": {
            "type": "string",
            "enum": [
              "AUD",
              "NZD"
            ]
          },
          "display": {
            "type": "string",
            "examples": [
              "$500 +GST",
              "NZ$620"
            ]
          },
          "gst": {
            "type": "string",
            "enum": [
              "excluded"
            ]
          }
        }
      },
      "PackageList": {
        "type": "object",
        "required": [
          "packages"
        ],
        "properties": {
          "packages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Package"
            }
          },
          "submit": {
            "type": "object",
            "properties": {
              "method": {
                "type": "string"
              },
              "path": {
                "type": "string"
              }
            }
          }
        }
      },
      "CampaignRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "package",
          "campaignType",
          "listingUrl",
          "agentName",
          "agentEmail",
          "agentPhone",
          "agentAgency",
          "agentLocation"
        ],
        "properties": {
          "package": {
            "type": "string",
            "enum": [
              "starter",
              "growth",
              "pro",
              "elite"
            ],
            "description": "Package id from listPackages (price amounts like \"500\" or \"620\" are also accepted)"
          },
          "campaignType": {
            "type": "string",
            "enum": [
              "just-listed",
              "just-sold"
            ],
            "description": "just-listed generates buyer and seller leads; just-sold attracts appraisal and seller leads"
          },
          "country": {
            "type": "string",
            "enum": [
              "AU",
              "NZ"
            ],
            "default": "AU"
          },
          "listingUrl": {
            "type": "string",
            "format": "uri",
            "maxLength": 2000,
            "description": "Public listing URL (realestate.com.au, domain.com.au, Trade Me, agency site…)"
          },
          "contentUrl": {
            "type": "string",
            "format": "uri",
            "maxLength": 2000,
            "description": "Optional link to video or drone footage"
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "agentName": {
            "type": "string",
            "maxLength": 2000
          },
          "agentEmail": {
            "type": "string",
            "format": "email"
          },
          "agentPhone": {
            "type": "string",
            "maxLength": 2000
          },
          "agentAgency": {
            "type": "string",
            "maxLength": 2000,
            "description": "Agency / company name"
          },
          "agentLocation": {
            "type": "string",
            "maxLength": 2000,
            "description": "Agency suburb and state (AU) or suburb and city (NZ)"
          }
        },
        "example": {
          "package": "growth",
          "campaignType": "just-listed",
          "country": "AU",
          "listingUrl": "https://www.realestate.com.au/property-house-nsw-bondi-junction-000000",
          "agentName": "Jane Smith",
          "agentEmail": "jane@example-realty.com.au",
          "agentPhone": "0412 345 678",
          "agentAgency": "Example Realty",
          "agentLocation": "Bondi Junction, NSW"
        }
      },
      "CampaignSummary": {
        "type": "object",
        "properties": {
          "package": {
            "type": "string"
          },
          "campaignType": {
            "type": "string"
          },
          "listingUrl": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "submittedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CampaignAccepted": {
        "type": "object",
        "required": [
          "status",
          "message"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "received"
            ]
          },
          "message": {
            "type": "string"
          },
          "submission": {
            "$ref": "#/components/schemas/CampaignSummary"
          }
        }
      },
      "CampaignDryRun": {
        "type": "object",
        "required": [
          "status",
          "dryRun",
          "submission"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "valid"
            ]
          },
          "dryRun": {
            "type": "boolean",
            "const": true
          },
          "submission": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}
