openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: IntegrateWise OS internal operations API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: leads description: CRM lead operations - name: clients description: Client operations - name: deals description: Deal / pipeline operations - name: ai description: Twin assistant operations - name: context description: Contextual memory — unified context packets, memory writes, goals & metrics paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /leads: get: operationId: listLeads tags: [leads] summary: List leads responses: "200": description: A list of leads content: application/json: schema: type: array items: $ref: "#/components/schemas/Lead" post: operationId: createLead tags: [leads] summary: Create a lead requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LeadInput" responses: "201": description: Lead created content: application/json: schema: $ref: "#/components/schemas/Lead" "400": description: Invalid request content: application/json: schema: $ref: "#/components/schemas/Error" /leads/{id}: get: operationId: getLead tags: [leads] summary: Get a lead with linked context parameters: - $ref: "#/components/parameters/IdParam" responses: "200": description: Lead detail content: application/json: schema: $ref: "#/components/schemas/LeadDetail" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" patch: operationId: updateLead tags: [leads] summary: Update a lead parameters: - $ref: "#/components/parameters/IdParam" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LeadUpdate" responses: "200": description: Updated lead content: application/json: schema: $ref: "#/components/schemas/Lead" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" /leads/{id}/qualify: post: operationId: qualifyLead tags: [leads] summary: Mark a lead as qualified parameters: - $ref: "#/components/parameters/IdParam" requestBody: required: false content: application/json: schema: $ref: "#/components/schemas/QualifyLeadInput" responses: "200": description: Qualified lead content: application/json: schema: $ref: "#/components/schemas/Lead" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" /leads/{id}/convert: post: operationId: convertLead tags: [leads] summary: Convert a lead into a client and an open deal parameters: - $ref: "#/components/parameters/IdParam" requestBody: required: false content: application/json: schema: $ref: "#/components/schemas/ConvertLeadInput" responses: "200": description: Conversion result content: application/json: schema: $ref: "#/components/schemas/ConvertResult" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" /leads/{id}/activities: get: operationId: listLeadActivities tags: [leads] summary: List activities for a lead parameters: - $ref: "#/components/parameters/IdParam" responses: "200": description: Activities content: application/json: schema: type: array items: $ref: "#/components/schemas/Activity" post: operationId: createLeadActivity tags: [leads] summary: Log an activity on a lead parameters: - $ref: "#/components/parameters/IdParam" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ActivityInput" responses: "201": description: Activity created content: application/json: schema: $ref: "#/components/schemas/Activity" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" /leads/{id}/intelligence: get: operationId: getLeadIntelligence tags: [leads] summary: Live, grounded lead intelligence (Obtain It) description: > Proactively answers whether to pursue a lead by reading live company facts (Apollo) and the organisation's ICP and lead-selection policy (the single Notion wiki) through the platform intelligence gateway. Strictly grounded: every claim is tagged evidence or inference, unknowns are explicit, and nothing is stored or fabricated. When the gateway is not configured or unreachable it returns status gateway_unavailable with HTTP 200 (never fake or stale data). parameters: - $ref: "#/components/parameters/IdParam" responses: "200": description: Lead intelligence (may report an unavailable gateway) content: application/json: schema: $ref: "#/components/schemas/LeadIntelligence" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/Error" /clients: get: operationId: listClients tags: [clients] summary: List clients responses: "200": description: A list of clients content: application/json: schema: type: array items: $ref: "#/components/schemas/Client" /deals: get: operationId: listDeals tags: [deals] summary: List deals responses: "200": description: A list of deals content: application/json: schema: type: array items: $ref: "#/components/schemas/Deal" /ai/chat: post: operationId: twinChat tags: [ai] summary: Ask the Twin assistant, grounded in entity context requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/TwinChatInput" responses: "200": description: Twin reply content: application/json: schema: $ref: "#/components/schemas/TwinReply" "400": description: Invalid request content: application/json: schema: $ref: "#/components/schemas/Error" /context/packet: get: operationId: getContextPacket tags: [context] summary: Assemble a contextual-memory packet for a subject description: > Composes structured CRM records, unified memory atoms, the goal/metric anchor, and a best-effort remote Spine reachability read into ONE provenance-tagged projection for a subject. Owns no truth; every store reports its own availability (live | empty | unavailable) and nothing is guessed. Coverage quantifies how deep the memory is for the subject. parameters: - name: subjectType in: query required: true schema: { type: string } - name: subjectId in: query required: true schema: { type: string } - name: query in: query required: false schema: { type: string } - name: limit in: query required: false schema: { type: integer, minimum: 1, maximum: 100 } - name: tenantId in: query required: false schema: { type: string } responses: "200": description: A contextual-memory packet content: application/json: schema: $ref: "#/components/schemas/ContextPacket" /context/remember: post: operationId: rememberContext tags: [context] summary: Write a memory atom (idempotent) into the unified memory description: > The single doorway through which contextual memory grows. Re-writing the same source fact matches idempotently (created=false) so memory compounds without duplicating. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RememberInput" responses: "201": description: Memory atom written (or matched idempotently) content: application/json: schema: $ref: "#/components/schemas/RememberResult" "400": description: Invalid request content: application/json: schema: $ref: "#/components/schemas/Error" /context/goals: get: operationId: listContextGoals tags: [context] summary: List goals for the tenant parameters: - name: tenantId in: query required: false schema: { type: string } responses: "200": description: Goals content: application/json: schema: type: array items: $ref: "#/components/schemas/ContextGoal" /context/metrics: get: operationId: listContextMetrics tags: [context] summary: List metrics (each anchored to a goal) for the tenant parameters: - name: tenantId in: query required: false schema: { type: string } responses: "200": description: Metrics content: application/json: schema: type: array items: $ref: "#/components/schemas/ContextMetric" /context/coverage: get: operationId: getContextCoverage tags: [context] summary: Coverage summary for a subject (how deep the memory is) parameters: - name: subjectType in: query required: true schema: { type: string } - name: subjectId in: query required: true schema: { type: string } - name: tenantId in: query required: false schema: { type: string } responses: "200": description: Coverage content: application/json: schema: $ref: "#/components/schemas/ContextCoverage" components: parameters: IdParam: name: id in: path required: true schema: type: string schemas: HealthStatus: type: object properties: status: type: string required: - status Error: type: object properties: error: type: string required: - error Lead: type: object required: - id - firstName - score - status - source - createdAt - updatedAt properties: id: { type: string } firstName: { type: string } lastName: { type: ["string", "null"] } company: { type: ["string", "null"] } jobTitle: { type: ["string", "null"] } email: { type: ["string", "null"] } phone: { type: ["string", "null"] } linkedinUrl: { type: ["string", "null"] } score: { type: integer } status: { type: string } source: { type: string } tags: type: ["array", "null"] items: { type: string } notes: { type: ["string", "null"] } owner: { type: ["string", "null"] } clientId: { type: ["string", "null"] } convertedDealId: { type: ["string", "null"] } createdAt: { type: string, format: date-time } updatedAt: { type: string, format: date-time } LeadInput: type: object required: - firstName properties: firstName: { type: string, minLength: 1 } lastName: { type: string } company: { type: string } jobTitle: { type: string } email: { type: string } phone: { type: string } linkedinUrl: { type: string } score: { type: integer } status: { type: string } source: { type: string } tags: type: array items: { type: string } notes: { type: string } owner: { type: string } LeadUpdate: type: object properties: firstName: { type: string, minLength: 1 } lastName: { type: string } company: { type: string } jobTitle: { type: string } email: { type: string } phone: { type: string } linkedinUrl: { type: string } score: { type: integer } status: { type: string } source: { type: string } tags: type: array items: { type: string } notes: { type: string } owner: { type: string } QualifyLeadInput: type: object properties: score: { type: integer } note: { type: string } ConvertLeadInput: type: object properties: clientName: { type: string } dealTitle: { type: string } valueCents: { type: integer } LeadDetail: type: object required: - lead - activities - tasks properties: lead: $ref: "#/components/schemas/Lead" client: anyOf: - $ref: "#/components/schemas/Client" - type: "null" deal: anyOf: - $ref: "#/components/schemas/Deal" - type: "null" activities: type: array items: $ref: "#/components/schemas/Activity" tasks: type: array items: $ref: "#/components/schemas/Task" ConvertResult: type: object required: - lead - client - deal properties: lead: $ref: "#/components/schemas/Lead" client: $ref: "#/components/schemas/Client" deal: $ref: "#/components/schemas/Deal" Client: type: object required: - id - name - status - healthScore - mrrCents - createdAt - updatedAt properties: id: { type: string } name: { type: string } industry: { type: ["string", "null"] } website: { type: ["string", "null"] } status: { type: string } healthScore: { type: integer } mrrCents: { type: integer } owner: { type: ["string", "null"] } tags: type: ["array", "null"] items: { type: string } notes: { type: ["string", "null"] } createdAt: { type: string, format: date-time } updatedAt: { type: string, format: date-time } Deal: type: object required: - id - title - stage - valueCents - probability - createdAt - updatedAt properties: id: { type: string } title: { type: string } clientId: { type: ["string", "null"] } leadId: { type: ["string", "null"] } stage: { type: string } valueCents: { type: integer } probability: { type: integer } closeDate: { type: ["string", "null"] } owner: { type: ["string", "null"] } notes: { type: ["string", "null"] } createdAt: { type: string, format: date-time } updatedAt: { type: string, format: date-time } Activity: type: object required: - id - type - summary - occurredAt - createdAt properties: id: { type: string } type: { type: string } summary: { type: string } body: { type: ["string", "null"] } actor: { type: ["string", "null"] } leadId: { type: ["string", "null"] } dealId: { type: ["string", "null"] } clientId: { type: ["string", "null"] } contactId: { type: ["string", "null"] } projectId: { type: ["string", "null"] } sessionId: { type: ["string", "null"] } occurredAt: { type: string, format: date-time } createdAt: { type: string, format: date-time } ActivityInput: type: object required: - summary properties: type: { type: string } summary: { type: string, minLength: 1 } body: { type: string } Task: type: object required: - id - title - status - priority - createdAt - updatedAt properties: id: { type: string } title: { type: string } description: { type: ["string", "null"] } status: { type: string } priority: { type: string } dueDate: { type: ["string", "null"] } assignedTo: { type: ["string", "null"] } leadId: { type: ["string", "null"] } dealId: { type: ["string", "null"] } clientId: { type: ["string", "null"] } projectId: { type: ["string", "null"] } completedAt: { type: ["string", "null"], format: date-time } createdAt: { type: string, format: date-time } updatedAt: { type: string, format: date-time } TwinMessage: type: object required: - role - content properties: role: { type: string } content: { type: string } TwinSuggestion: type: object required: - title - detail properties: title: { type: string } detail: { type: string } kind: { type: string } TwinChatInput: type: object required: - message properties: message: { type: string, minLength: 1 } entityType: { type: string } entityId: { type: string } history: type: array items: $ref: "#/components/schemas/TwinMessage" TwinReply: type: object required: - reply - suggestions properties: reply: { type: string } suggestions: type: array items: $ref: "#/components/schemas/TwinSuggestion" LeadIntelligence: type: object required: - status - leadId - verdict - fitScore - computedAt - summary - signals - answers - sources - gateway properties: status: type: string enum: [ready, gateway_unavailable, insufficient_context, error] leadId: { type: string } verdict: type: string enum: [approach, hold, pass, unknown] fitScore: { type: ["integer", "null"] } computedAt: { type: string, format: date-time } summary: { type: ["string", "null"] } signals: type: array items: $ref: "#/components/schemas/IntelligenceSignal" answers: type: array items: $ref: "#/components/schemas/IntelligenceAnswer" sources: type: array items: $ref: "#/components/schemas/IntelligenceSource" gateway: $ref: "#/components/schemas/GatewayStatus" IntelligenceSignal: type: object required: - id - label - hit - basis - text - citations properties: id: { type: string } label: { type: string } hit: { type: ["boolean", "null"] } basis: type: string enum: [evidence, inference, unknown] text: { type: string } citations: type: array items: { type: string } IntelligenceAnswer: type: object required: - question - basis - answer - citations properties: question: type: string enum: - why_qualified - why_first_fit - problem - current_solution - in_our_track - recommended_action basis: type: string enum: [evidence, inference, unknown] answer: { type: string } citations: type: array items: { type: string } unknownReason: { type: ["string", "null"] } IntelligenceSource: type: object required: - name - kind - status properties: name: type: string enum: [Apollo, Notion] kind: type: string enum: [company_facts, icp, policy] asOf: { type: ["string", "null"], format: date-time } url: { type: ["string", "null"] } status: type: string enum: [live, unavailable] GatewayStatus: type: object required: - status properties: status: type: string enum: [connected, unavailable] message: { type: ["string", "null"] } retryAfterSeconds: { type: ["integer", "null"] } ContextStoreStatus: type: string enum: [live, empty, unavailable] ContextFragment: type: object required: - id - origin - kind - title - body - source - provenance - salience - score - occurredAt properties: id: { type: string } origin: { type: string, enum: [record, memory] } kind: { type: string } title: { type: string } body: { type: string } source: { type: object, additionalProperties: true } provenance: { type: object, additionalProperties: true } salience: { type: number } score: { type: ["number", "null"] } occurredAt: { type: ["string", "null"], format: date-time } ContextGoal: type: object required: - id - type - domain - name - status properties: id: { type: string } type: { type: string } domain: { type: string } name: { type: string } description: { type: ["string", "null"] } status: { type: string } cadence: { type: ["string", "null"] } ContextMetricGoal: type: ["object", "null"] required: - id - name properties: id: { type: string } name: { type: string } ContextMetric: type: object required: - id - name - domain - status - statusReason - goal properties: id: { type: string } name: { type: string } domain: { type: string } unit: { type: ["string", "null"] } formula: { type: ["string", "null"] } status: { type: string, enum: [ok, insufficient_data] } statusReason: { type: string } goal: { $ref: "#/components/schemas/ContextMetricGoal" } ContextSpine: type: object required: - availability - note - toolsCount properties: availability: { $ref: "#/components/schemas/ContextStoreStatus" } note: { type: string } toolsCount: { type: ["integer", "null"] } ContextCoverageGap: type: object required: - store - hint properties: store: { type: string } hint: { type: string } ContextCoverage: type: object required: - stores - contributingStores - totalStores - depthScore - gaps properties: stores: type: object additionalProperties: { type: integer } contributingStores: { type: integer } totalStores: { type: integer } depthScore: { type: number } gaps: type: array items: $ref: "#/components/schemas/ContextCoverageGap" ContextAvailability: type: object required: - structured - memory - goals - metrics - spine - embedding properties: structured: { $ref: "#/components/schemas/ContextStoreStatus" } memory: { $ref: "#/components/schemas/ContextStoreStatus" } goals: { $ref: "#/components/schemas/ContextStoreStatus" } metrics: { $ref: "#/components/schemas/ContextStoreStatus" } spine: { $ref: "#/components/schemas/ContextStoreStatus" } embedding: { $ref: "#/components/schemas/ContextStoreStatus" } ContextSubject: type: object required: - tenantId - subjectType - subjectId - label - ref properties: tenantId: { type: string } subjectType: { type: string } subjectId: { type: string } label: { type: string } ref: { type: object, additionalProperties: true } ContextPacket: type: object required: - subject - query - fragments - goals - metrics - spine - coverage - availability - generatedAt properties: subject: { $ref: "#/components/schemas/ContextSubject" } query: { type: ["string", "null"] } fragments: type: array items: $ref: "#/components/schemas/ContextFragment" goals: type: array items: $ref: "#/components/schemas/ContextGoal" metrics: type: array items: $ref: "#/components/schemas/ContextMetric" spine: { $ref: "#/components/schemas/ContextSpine" } coverage: { $ref: "#/components/schemas/ContextCoverage" } availability: { $ref: "#/components/schemas/ContextAvailability" } generatedAt: { type: string, format: date-time } RememberSubjectRef: type: object required: - entity_type - entity_id properties: tenant_id: { type: string } entity_type: { type: string } entity_id: { type: string } source: { type: string } external_id: { type: string } RememberSource: type: object properties: connector: { type: string } source_id: { type: string } entity_type: { type: string } external_id: { type: string } RememberInput: type: object required: - subjectRef - kind - title - body properties: tenantId: { type: string } subjectRef: { $ref: "#/components/schemas/RememberSubjectRef" } kind: type: string enum: [fact, interaction, decision, signal, preference] title: { type: string, minLength: 1 } body: { type: string, minLength: 1 } source: { $ref: "#/components/schemas/RememberSource" } goalRefs: type: array items: { type: string } salience: { type: number } entityRef: { type: object, additionalProperties: true } expiresAt: { type: ["string", "null"] } MemoryAtomSummary: type: object required: - id - subjectType - subjectId - kind - title - createdAt properties: id: { type: string } subjectType: { type: string } subjectId: { type: string } kind: { type: string } title: { type: string } createdAt: { type: string, format: date-time } RememberEmbeddingStatus: type: object required: - available - reason properties: available: { type: boolean } reason: { type: string } RememberResult: type: object required: - atom - created - embedding properties: atom: { $ref: "#/components/schemas/MemoryAtomSummary" } created: { type: boolean } embedding: { $ref: "#/components/schemas/RememberEmbeddingStatus" }