← Documentation/API Reference (RFC 9727)

Haggle API & Agent Discovery

Interact programmatically with Haggle's real-time conversation intelligence engine, memory flywheels, and MCP tool servers.

Authentication

Authenticated endpoints require a Bearer token in the standard Authorization header. You can obtain tokens via user login or autonomous agent registration.

# HTTP Header Example

Authorization: Bearer <YOUR_API_TOKEN_OR_SESSION>

Endpoints

Core HTTP REST, JSON-RPC, and Model Context Protocol endpoints.

GET/api/status
Public

Health & Agent-Readiness Status

Verify API health, database status, and advertised agent capabilities.

Sample Response
{
  "status": "ok",
  "service": "haggle-api",
  "version": "1.0.0",
  "agentReady": true
}
GET/api/negotiations
Auth Required

List Negotiations

Retrieve paginated negotiation records, tactical playbooks, and outcomes.

Sample Response
{
  "data": [
    {
      "id": "neg_88f219",
      "bill_name": "Enterprise SaaS Contract",
      "current_price": 12000,
      "target_price": 7500,
      "outcome_state": "win"
    }
  ],
  "total": 1,
  "page": 1,
  "pages": 1
}
GET/api/memories
Auth Required

Query Vector Memory

Retrieve winning negotiation strategies, counterparty leverage benchmarks, and script memories.

Sample Response
{
  "data": [
    {
      "id": "mem_01a",
      "provider": "Cloudflare",
      "tactic_used": "Multi-year Commitment Leverage",
      "old_price": 5000,
      "new_price": 3200
    }
  ]
}
POST/api/agent/register
Auth.md Public

Autonomous Agent Registration

Register autonomous AI agents per Auth.md standard to obtain client credentials or API keys.

Sample Response
{
  "client_id": "haggle_agent_92a",
  "access_token": "haggle_ephemeral_token_...",
  "token_type": "Bearer",
  "expires_in": 86400
}
POST/api/mcp
MCP Protocol

Model Context Protocol (MCP) JSON-RPC

Streamable HTTP endpoint for AI tool execution: generate_battle_plan, get_tactical_advice, query_memories, log_win.

Sample Response
{
  "jsonrpc": "2.0",
  "id": "1",
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Battle plan generated with 4 leverage anchors..."
      }
    ]
  }
}