{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/peerbound/json-schema/peerbound-review-schema.json",
  "title": "Review",
  "description": "A customer review from a third-party platform (e.g., G2).",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/peerbound-reviews-api-openapi.yml#/components/schemas/Review",
  "properties": {
    "id": {
      "type": "string",
      "title": "Id",
      "description": "Unique Peerbound identifier"
    },
    "source": {
      "$ref": "#/$defs/ReviewSource",
      "description": "Source platform metadata"
    },
    "title": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Title",
      "description": "Review title"
    },
    "star_rating": {
      "type": "number",
      "title": "Star Rating",
      "description": "Star rating (0-5)"
    },
    "answers": {
      "items": {
        "$ref": "#/$defs/ReviewAnswer"
      },
      "type": "array",
      "title": "Answers",
      "description": "Q&A pairs from the review"
    },
    "reviewer": {
      "$ref": "#/$defs/Reviewer",
      "description": "Information about the reviewer"
    },
    "account": {
      "anyOf": [
        {
          "$ref": "#/$defs/LinkedAccount"
        },
        {
          "type": "null"
        }
      ],
      "description": "Associated account (customer)"
    },
    "contact": {
      "anyOf": [
        {
          "$ref": "#/$defs/LinkedContact"
        },
        {
          "type": "null"
        }
      ],
      "description": "Associated contact (person)"
    },
    "submitted_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Submitted At",
      "description": "When the review was submitted to the platform (ISO 8601)"
    },
    "is_deleted": {
      "type": "boolean",
      "title": "Is Deleted",
      "description": "Whether the review has been deleted"
    },
    "created_at": {
      "type": "string",
      "title": "Created At",
      "description": "Timestamp when the review was created (ISO 8601)"
    },
    "updated_at": {
      "type": "string",
      "title": "Updated At",
      "description": "Timestamp when the review was last updated (ISO 8601)"
    }
  },
  "type": "object",
  "required": [
    "id",
    "source",
    "star_rating",
    "answers",
    "reviewer",
    "is_deleted",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "LinkedAccount": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id",
          "description": "Unique Peerbound identifier for the account"
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "Name of the account"
        },
        "salesforce_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Salesforce Id",
          "description": "Salesforce Account ID if synced"
        },
        "hubspot_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Hubspot Id",
          "description": "HubSpot Company ID if synced"
        }
      },
      "type": "object",
      "required": [
        "id",
        "name"
      ],
      "title": "LinkedAccount",
      "description": "Account (customer company) linked to a resource.\n\nUsed for stories, reviews, and moments to reference the associated account."
    },
    "LinkedContact": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id",
          "description": "Unique Peerbound identifier for the contact"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name",
          "description": "Full name of the contact"
        },
        "email": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Email",
          "description": "Email address of the contact"
        },
        "salesforce_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Salesforce Id",
          "description": "Salesforce Contact ID if synced"
        },
        "hubspot_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Hubspot Id",
          "description": "HubSpot Contact ID if synced"
        }
      },
      "type": "object",
      "required": [
        "id"
      ],
      "title": "LinkedContact",
      "description": "Contact (person) linked to a resource.\n\nUsed for reviews and moments to reference the associated contact."
    },
    "ReviewAnswer": {
      "properties": {
        "question": {
          "type": "string",
          "title": "Question",
          "description": "The review question"
        },
        "answer": {
          "type": "string",
          "title": "Answer",
          "description": "The reviewer's answer"
        }
      },
      "type": "object",
      "required": [
        "question",
        "answer"
      ],
      "title": "ReviewAnswer",
      "description": "A question-answer pair from a review."
    },
    "ReviewSource": {
      "properties": {
        "type": {
          "type": "string",
          "const": "g2",
          "title": "Type",
          "description": "Source platform identifier"
        },
        "id": {
          "type": "string",
          "title": "Id",
          "description": "Review ID on the source platform"
        },
        "url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Url",
          "description": "Link to review on source platform"
        },
        "product_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Product Name",
          "description": "Product name on the source platform"
        }
      },
      "type": "object",
      "required": [
        "type",
        "id"
      ],
      "title": "ReviewSource",
      "description": "Source platform metadata for a review."
    },
    "Reviewer": {
      "properties": {
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name",
          "description": "Reviewer's name"
        },
        "company_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Company Name",
          "description": "Reviewer's company name"
        }
      },
      "type": "object",
      "title": "Reviewer",
      "description": "Information about the person who submitted the review."
    }
  }
}