{
  "openapi": "3.1.0",
  "info": {
    "title": "Refer2u Developer API",
    "version": "1.0.0",
    "description": "Profile-scoped REST API for Refer2u CRM data. Authenticate with Bearer API keys (ru2_live_*)."
  },
  "servers": [{ "url": "https://www.refer2u.com/api/v1" }],
  "security": [{ "bearerAuth": [] }],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Profile-scoped API key from Dashboard → Integrations → Developer API"
      }
    },
    "schemas": {
      "Contact": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "firstName": { "type": "string" },
          "lastName": { "type": "string" },
          "email": { "type": "string", "nullable": true },
          "companyId": { "type": "string", "nullable": true }
        }
      },
      "Company": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string" },
          "domain": { "type": "string", "nullable": true }
        }
      },
      "Partner": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "type": { "type": "string", "enum": ["individual", "organization"] },
          "name": { "type": "string" },
          "stage": { "type": "string", "nullable": true },
          "status": { "type": "string", "nullable": true }
        }
      },
      "Connection": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "fromContactId": { "type": "string", "nullable": true },
          "toContactId": { "type": "string", "nullable": true },
          "note": { "type": "string", "nullable": true },
          "status": { "type": "string", "nullable": true }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string" }
        }
      }
    }
  },
  "paths": {
    "/contacts": {
      "get": { "summary": "List contacts", "tags": ["Contacts"], "responses": { "200": { "description": "OK" } } },
      "post": { "summary": "Create contact", "tags": ["Contacts"], "responses": { "201": { "description": "Created" } } }
    },
    "/contacts/{id}": {
      "get": { "summary": "Get contact", "tags": ["Contacts"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } },
      "patch": { "summary": "Update contact", "tags": ["Contacts"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } },
      "delete": { "summary": "Delete contact", "tags": ["Contacts"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } }
    },
    "/contacts/search": {
      "get": { "summary": "Search contacts", "tags": ["Contacts"], "responses": { "200": { "description": "OK" } } }
    },
    "/companies": {
      "get": { "summary": "List companies", "tags": ["Companies"], "responses": { "200": { "description": "OK" } } },
      "post": { "summary": "Create company", "tags": ["Companies"], "responses": { "201": { "description": "Created" } } }
    },
    "/companies/{id}": {
      "get": { "summary": "Get company", "tags": ["Companies"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } },
      "patch": { "summary": "Update company", "tags": ["Companies"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } },
      "delete": { "summary": "Delete company", "tags": ["Companies"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } }
    },
    "/partners": {
      "get": { "summary": "List partners", "tags": ["Partners"], "responses": { "200": { "description": "OK" } } },
      "post": { "summary": "Create partner", "tags": ["Partners"], "responses": { "201": { "description": "Created" } } }
    },
    "/partners/{id}": {
      "get": { "summary": "Get partner", "tags": ["Partners"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } },
      "patch": { "summary": "Update partner", "tags": ["Partners"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } },
      "delete": { "summary": "Delete partner", "tags": ["Partners"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } }
    },
    "/connections": {
      "get": { "summary": "List connections", "tags": ["Connections"], "responses": { "200": { "description": "OK" } } },
      "post": { "summary": "Create connection", "tags": ["Connections"], "responses": { "201": { "description": "Created" } } }
    },
    "/connections/{id}": {
      "get": { "summary": "Get connection", "tags": ["Connections"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } },
      "patch": { "summary": "Update connection", "tags": ["Connections"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } },
      "delete": { "summary": "Delete connection", "tags": ["Connections"], "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "OK" } } }
    },
    "/hooks/subscribe": {
      "post": { "summary": "Subscribe to webhook events", "tags": ["Webhooks"], "responses": { "201": { "description": "Created" } } }
    }
  }
}
