{
  "openapi": "3.1.0",
  "info": {
    "title": "Merger Agent API",
    "version": "1",
    "description": "Read-only, account-scoped saved contacts and deals. No messages, calendar, signatures, writes, or device-only records. REST read grants and hosted MCP OAuth credentials are separate.",
    "contact": {
      "name": "Merger support",
      "url": "https://usemerger.com/support",
      "email": "support@usemerger.com"
    }
  },
  "servers": [
    {
      "url": "https://api.buildmerger.com"
    }
  ],
  "externalDocs": {
    "url": "https://usemerger.com/developers",
    "description": "API, hosted MCP, and CLI documentation"
  },
  "paths": {
    "/api/agent/v1/capabilities": {
      "get": {
        "tags": [
          "Agent API v1"
        ],
        "summary": "Capabilities",
        "operationId": "capabilities_api_agent_v1_capabilities_get",
        "responses": {
          "200": {
            "description": "Saved account-owned records or granted capabilities.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Capabilities"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request or invalid_cursor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "invalid_agent_token: missing, expired, revoked, or invalid read token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "product_access_required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: 120 reads per minute per grant",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "agent_access_not_enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "description": "Read the operations and data coverage available to this grant.",
        "x-merger-required-scope": null
      }
    },
    "/api/agent/v1/contacts": {
      "get": {
        "tags": [
          "Agent API v1"
        ],
        "summary": "Contacts",
        "operationId": "contacts_api_agent_v1_contacts_get",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200,
              "default": "",
              "title": "Q"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 25,
              "title": "Limit"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 2000
                },
                {
                  "type": "null"
                }
              ],
              "title": "Cursor"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Saved account-owned records or granted capabilities.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactPage"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request or invalid_cursor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "invalid_agent_token: missing, expired, revoked, or invalid read token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "product_access_required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: 120 reads per minute per grant",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "agent_access_not_enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Search saved contacts with literal case-insensitive substring matching.",
        "x-merger-required-scope": "contacts.read"
      }
    },
    "/api/agent/v1/contacts/{identity}": {
      "get": {
        "tags": [
          "Agent API v1"
        ],
        "summary": "Contact",
        "operationId": "contact_api_agent_v1_contacts__identity__get",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "identity",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Identity"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Saved account-owned records or granted capabilities.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactResult"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request or invalid_cursor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "invalid_agent_token: missing, expired, revoked, or invalid read token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "product_access_required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found in this account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: 120 reads per minute per grant",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "agent_access_not_enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Read one saved contact by exact UUID.",
        "x-merger-required-scope": "contacts.read"
      }
    },
    "/api/agent/v1/deals": {
      "get": {
        "tags": [
          "Agent API v1"
        ],
        "summary": "Deals",
        "operationId": "deals_api_agent_v1_deals_get",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200,
              "default": "",
              "title": "Q"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 25,
              "title": "Limit"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 2000
                },
                {
                  "type": "null"
                }
              ],
              "title": "Cursor"
            }
          },
          {
            "name": "archived",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "title": "Archived"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Saved account-owned records or granted capabilities.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealPage"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request or invalid_cursor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "invalid_agent_token: missing, expired, revoked, or invalid read token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "product_access_required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: 120 reads per minute per grant",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "agent_access_not_enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Search saved deals; archived=false and archived=true are separate views.",
        "x-merger-required-scope": "deals.read"
      }
    },
    "/api/agent/v1/deals/{identity}": {
      "get": {
        "tags": [
          "Agent API v1"
        ],
        "summary": "Deal",
        "operationId": "deal_api_agent_v1_deals__identity__get",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "identity",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Identity"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Saved account-owned records or granted capabilities.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealResult"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request or invalid_cursor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "invalid_agent_token: missing, expired, revoked, or invalid read token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "product_access_required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found in this account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: 120 reads per minute per grant",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "agent_access_not_enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Read one saved deal by exact UUID.",
        "x-merger-required-scope": "deals.read"
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code"
            ],
            "properties": {
              "code": {
                "type": "string"
              }
            }
          }
        }
      },
      "Coverage": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "const": "saved_backend_records"
          },
          "resource": {
            "type": "string"
          },
          "excluded": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "deduplication": {
            "type": "string"
          },
          "pagination": {
            "type": "string"
          },
          "claimScope": {
            "type": "string"
          },
          "relationships": {
            "type": "string"
          },
          "missingValues": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "Contact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "displayName": {
            "type": "string"
          },
          "isMergerUser": {
            "type": "boolean"
          },
          "mergerHandle": {
            "type": [
              "string",
              "null"
            ]
          },
          "company": {
            "type": [
              "string",
              "null"
            ]
          },
          "side": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "identities": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "network": {
                  "type": "string"
                },
                "remoteIdentifier": {
                  "type": "string"
                },
                "visibility": {
                  "type": "string"
                },
                "homeserver": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "roomId": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "additionalProperties": true
            }
          }
        },
        "additionalProperties": true
      },
      "Deal": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "terms": {
            "type": [
              "string",
              "null"
            ]
          },
          "vertical": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "nextStep": {
            "type": [
              "string",
              "null"
            ]
          },
          "startDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "dueDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time"
          },
          "openedAt": {
            "type": "string",
            "format": "date"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "archivedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "partyContactIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        },
        "additionalProperties": true
      },
      "Capabilities": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "readOnly": {
            "type": "boolean",
            "const": true
          },
          "resources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "maxPageSize": {
            "type": "integer",
            "const": 100
          },
          "operations": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "unavailable": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "coverage": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "ContactPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Contact"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "hasMore": {
            "type": "boolean"
          },
          "totalMatches": {
            "type": "integer"
          },
          "returnedCount": {
            "type": "integer"
          },
          "observedAt": {
            "type": "string",
            "format": "date-time"
          },
          "coverage": {
            "$ref": "#/components/schemas/Coverage"
          },
          "filters": {
            "type": "object",
            "properties": {
              "query": {
                "type": "string"
              }
            },
            "additionalProperties": true
          }
        },
        "additionalProperties": true,
        "required": [
          "items",
          "nextCursor",
          "hasMore",
          "totalMatches",
          "returnedCount",
          "observedAt",
          "coverage",
          "filters"
        ]
      },
      "ContactResult": {
        "type": "object",
        "properties": {
          "item": {
            "$ref": "#/components/schemas/Contact"
          },
          "observedAt": {
            "type": "string",
            "format": "date-time"
          },
          "coverage": {
            "$ref": "#/components/schemas/Coverage"
          }
        },
        "additionalProperties": true,
        "required": [
          "item",
          "observedAt",
          "coverage"
        ]
      },
      "DealPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Deal"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "hasMore": {
            "type": "boolean"
          },
          "totalMatches": {
            "type": "integer"
          },
          "returnedCount": {
            "type": "integer"
          },
          "observedAt": {
            "type": "string",
            "format": "date-time"
          },
          "coverage": {
            "$ref": "#/components/schemas/Coverage"
          },
          "filters": {
            "type": "object",
            "properties": {
              "query": {
                "type": "string"
              },
              "archived": {
                "type": "boolean"
              }
            },
            "additionalProperties": true
          }
        },
        "additionalProperties": true,
        "required": [
          "items",
          "nextCursor",
          "hasMore",
          "totalMatches",
          "returnedCount",
          "observedAt",
          "coverage",
          "filters"
        ]
      },
      "DealResult": {
        "type": "object",
        "properties": {
          "item": {
            "$ref": "#/components/schemas/Deal"
          },
          "observedAt": {
            "type": "string",
            "format": "date-time"
          },
          "coverage": {
            "$ref": "#/components/schemas/Coverage"
          }
        },
        "additionalProperties": true,
        "required": [
          "item",
          "observedAt",
          "coverage"
        ]
      }
    },
    "securitySchemes": {
      "HTTPBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Merger read token issued in Merger Mod → Manage access. Hosted MCP OAuth tokens are not interchangeable with REST read tokens."
      }
    }
  },
  "x-merger-source-schema": "https://api.buildmerger.com/openapi.json"
}
