API Examples

API Examples

Common API patterns and use cases with code examples in multiple languages.

Create and Run an Agent

cURL

AGENT_ID=...

# Run the agent
curl -X POST https://api.seclai.com/agents/$AGENT_ID/runs \
  -H "X-API-Key:  $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Research the latest developments in AI agents"
  }'

Priority Runs

Set priority to true for latency-sensitive, user-facing work. Priority runs are dispatched ahead of background work:

curl -X POST https://api.seclai.com/agents/$AGENT_ID/runs \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Summarize the latest news",
    "priority": true
  }'

Streaming Runs (SSE)

Use the /runs/stream endpoint to receive real-time Server-Sent Events. The run is always created in priority mode:

curl -N https://api.seclai.com/agents/$AGENT_ID/runs/stream \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input": "What happened today?"}'

Get Run Details with Step Outputs

Use include_step_outputs=true on GET /runs/{run_id} to include per-step outputs, timing, and credit usage:

RUN_ID=...

curl "https://api.seclai.com/agents/$AGENT_ID/runs/$RUN_ID?include_step_outputs=true" \
  -H "X-API-Key: $SECLAI_API_KEY"

Python

import requests

api_key = "YOUR_API_KEY"
headers = {
    "X-API-Key": api_key,
    "Content-Type": "application/json"
}

agent_id = "..."

# Run agent
run_response = requests.post(
    f"https://api.seclai.com/agents/{agent_id}/runs",
    headers=headers,
    json={"input": "Research the latest developments in AI agents"}
)
run = run_response.json()
print(run)

JavaScript

const apiKey = "YOUR_API_KEY";
const headers = {
  "X-API-Key": apiKey,
  "Content-Type": "application/json",
};

const agent_id = "...";

// Run agent
const runResponse = await fetch(
  `https://api.seclai.com/agents/${agent_id}/runs`,
  {
    method: "POST",
    headers,
    body: JSON.stringify({
      input: "Research the latest developments in AI agents",
    }),
  }
);
const run = await runResponse.json();
console.log(run);

Go

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    apiKey := "YOUR_API_KEY"
    baseURL := "https://api.seclai.com"

    agentId := "..."

    // Run agent
    runData := map[string]string{
        "input": "Research the latest developments in AI agents",
    }
    runJSON, _ := json.Marshal(runData)

    runReq, _ := http.NewRequest("POST",
        fmt.Sprintf("%s/agents/%s/runs", baseURL, agentId),
        bytes.NewBuffer(runJSON))
    runReq.Header.Set("X-API-Key", apiKey)
    runReq.Header.Set("Content-Type", "application/json")

    runResp, _ := http.DefaultClient.Do(runReq)
    defer runResp.Body.Close()

    var run map[string]interface{}
    json.NewDecoder(runResp.Body).Decode(&run)
    fmt.Printf("%+v\n", run)
}

Webhook Handler

Node.js + Express

import express from "express";

const app = express();
app.use(express.json());

app.post("/my-webhook-endpoint", (req, res) => {
  const payload = JSON.stringify(req.body);

  // process payload

  res.status(200).send("OK");
});

app.listen(3000);

Python + FastAPI

from fastapi import FastAPI, Request, HTTPException
import hmac
import hashlib
import os

app = FastAPI()

@app.post("/my-webhook-endpoint")
async def handle_webhook(request: Request):
    payload = await request.body()

    # process payload

    return {"status": "ok"}

Pagination

def get_all_agents(api_key):
    """Fetch all agents using pagination"""
    headers = {
        "X-API-Key": api_key,
        "Content-Type": "application/json"
    }

    all_agents = []
    offset = 0
    limit = 100

    while True:
        response = requests.get(
            f"https://api.seclai.com/agents?limit={limit}&offset={offset}",
            headers=headers
        )
        data = response.json()

        all_agents.extend(data["data"])

        if not data["has_more"]:
            break

        offset += limit

    return all_agents

Error Handling

async function createAgentWithRetry(agentData, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      const response = await fetch("https://api.seclai.com/agents", {
        method: "POST",
        headers: {
          X-API-Key: process.env.SECLAI_API_KEY,
          "Content-Type": "application/json",
        },
        body: JSON.stringify(agentData),
      });

      if (response.status === 429) {
        // Rate limited - wait and retry
        const retryAfter = response.headers.get("retry-after") || 60;
        await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000));
        continue;
      }

      if (!response.ok) {
        const error = await response.json();
        throw new Error(`API Error: ${error.error.message}`);
      }

      return await response.json();
    } catch (error) {
      if (i === maxRetries - 1) throw error;
      // Exponential backoff
      await new Promise((resolve) =>
        setTimeout(resolve, Math.pow(2, i) * 1000)
      );
    }
  }
}

Batch Operations

import asyncio
import aiohttp

async def run_multiple_agents(agent_ids, input_text):
    """Run multiple agents concurrently"""
    async with aiohttp.ClientSession() as session:
        tasks = []

        for agent_id in agent_ids:
            task = run_agent(session, agent_id, input_text)
            tasks.append(task)

        results = await asyncio.gather(*tasks)
        return results

async def run_agent(session, agent_id, input_text):
    url = f"https://api.seclai.com/agents/{agent_id}/runs"
    headers = {
        "X-API-Key": os.getenv('SECLAI_API_KEY'),
        "Content-Type": "application/json"
    }

    async with session.post(url, headers=headers, json={"input": input_text}) as resp:
        return await resp.json()

# Usage
results = asyncio.run(run_multiple_agents(
    ["agent_1", "agent_2", "agent_3"],
    "Analyze this data"
))

Alerts

List Open Alerts for an Agent

AGENT_ID=...

curl "https://api.seclai.com/alerts?status=triggered&agent_id=$AGENT_ID&limit=10" \
  -H "X-API-Key: $SECLAI_API_KEY"

Resolve an Alert with a Comment

ALERT_ID=...

# Resolve the alert
curl -X POST "https://api.seclai.com/alerts/$ALERT_ID/status" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"status": "resolved", "note": "Upstream API recovered"}'

# Add a comment explaining the resolution
curl -X POST "https://api.seclai.com/alerts/$ALERT_ID/comments" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"body": "Root cause was a transient upstream API failure, now recovered."}'

Create an Alert Configuration

AGENT_ID=...

curl -X POST "https://api.seclai.com/alerts/configs" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "alert_type": "consecutive_failures",
    "agent_id": "'$AGENT_ID'",
    "threshold": {"count": 3},
    "distribution_type": "owner"
  }'

Export Agent Definition

Export as JSON File

Download a portable JSON snapshot of an agent's full definition, including trigger configuration, alert configs, evaluation criteria, governance policies, and a dependency manifest.

AGENT_ID=...

# Download as a file (default: download=true sets Content-Disposition header)
curl -OJ "https://api.seclai.com/api/agents/$AGENT_ID/export" \
  -H "X-API-Key: $SECLAI_API_KEY"

# Get JSON response without download header
curl "https://api.seclai.com/api/agents/$AGENT_ID/export?download=false" \
  -H "X-API-Key: $SECLAI_API_KEY"

Export and Save with Python

import json, os, requests

def export_agent(agent_id, output_dir="."):
    resp = requests.get(
        f"https://api.seclai.com/api/agents/{agent_id}/export?download=false",
        headers={"X-API-Key": os.getenv("SECLAI_API_KEY")},
    )
    resp.raise_for_status()
    data = resp.json()

    name = data["agent"]["name"].replace(" ", "_")[:80]
    path = os.path.join(output_dir, f"{name}.json")
    with open(path, "w") as f:
        json.dump(data, f, indent=2)

    print(f"Exported to {path}")
    print(f"  Dependencies: {sum(len(v) for v in data['dependencies'].values())} entities")
    return data

export_agent("your-agent-id")

Agent AI Assistant

Generate a Step Configuration

Use the AI assistant to generate or refine a single step's configuration:

For Prompt Call step generation, the assistant convention is:

  • {{agent.input}} = original user question/message
  • {{input}} = previous-step output/current-step input context
  • Core instruction logic should be in system_template
AGENT_ID=...

curl -X POST "https://api.seclai.com/agents/$AGENT_ID/ai-assistant/step-config" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "step_type": "transform",
    "user_input": "Create rules that extract the article title and clean up HTML entities"
  }'

Response:

{
  "conversation_id": "conv_abc123",
  "step_type": "transform",
  "note": "I created two transform rules: one to extract titles and another to clean HTML entities.",
  "success": true,
  "resulting_config": {
    "rules": [
      { "pattern": "<title>(.*?)</title>", "substitution": "$1" },
      { "pattern": "&amp;|&lt;|&gt;", "substitution": "" }
    ]
  }
}

Model Lifecycle Controls

Update Agent-Level Lifecycle Defaults

Use PATCH /agents/{agent_id} to define defaults inherited by Prompt Call and Insight steps.

AGENT_ID=...

curl -X PATCH "https://api.seclai.com/agents/$AGENT_ID" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt_model_auto_upgrade_strategy": "middle_of_road",
    "prompt_model_auto_rollback_enabled": true,
    "prompt_model_auto_rollback_triggers": [
      "agent_eval_fail",
      "governance_block"
    ]
  }'

Set Step-Level Overrides in Agent Definition

Step-level values override agent defaults.

{
  "id": "summarize",
  "step_type": "prompt_call",
  "name": "Summarize Content",
  "model": "anthropic_claude_sonnet_4_6",
  "auto_upgrade_strategy": "early_adopter",
  "auto_rollback_enabled": true,
  "auto_rollback_triggers": ["agent_eval_fail", "governance_flag"],
  "simple_format": true,
  "prompt_template": "Summarize: {{input}}"
}

Valid strategy values:

  • none
  • early_adopter
  • middle_of_road
  • cautious_adopter

Valid rollback trigger values:

  • agent_eval_fail
  • governance_flag
  • governance_block
  • agent_run_failed

Generate a Full Agent Workflow

AGENT_ID=...

curl -X POST "https://api.seclai.com/agents/$AGENT_ID/ai-assistant/generate-steps" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_input": "Create a workflow that retrieves articles from a knowledge base, summarizes them with an LLM, and sends a daily email digest",
    "mode": "generate_full",
    "trigger_type": "schedule"
  }'

Accept or Decline an AI Suggestion

After reviewing a proposed configuration, mark it as accepted or declined:

AGENT_ID=...
CONVERSATION_ID=...

curl -X PATCH "https://api.seclai.com/agents/$AGENT_ID/ai-assistant/$CONVERSATION_ID" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"accepted": true}'

Note: Accepting a suggestion only records your decision — it does not automatically apply the configuration. To apply the proposed config, use the standard PUT /agents/{agent_id}/definition endpoint with the config from the AI's resulting_config.

View AI Conversation History

AGENT_ID=...

curl "https://api.seclai.com/agents/$AGENT_ID/ai-assistant/conversations?step_type=transform&limit=5" \
  -H "X-API-Key: $SECLAI_API_KEY"

Agent Evaluations

Create Evaluation Criteria with a Custom Pass Threshold

AGENT_ID=...

curl -X POST "https://api.seclai.com/agents/$AGENT_ID/evaluation-criteria" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "step_id": "final-answer",
    "description": "Quality gate for final answer",
    "evaluation_prompt": "Check factual accuracy and completeness.",
    "pass_threshold": 0.75,
    "evaluation_tier": "balanced",
    "enabled": true
  }'

Test Draft Evaluation Settings Before Saving

AGENT_ID=...

curl -X POST "https://api.seclai.com/agents/$AGENT_ID/evaluation-criteria/test-draft" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "step_output": "Draft answer text to evaluate",
    "evaluation_prompt": "Check factual accuracy and completeness.",
    "pass_threshold": 0.8,
    "evaluation_tier": "balanced"
  }'

List Evaluation Results

AGENT_ID=...

curl "https://api.seclai.com/agents/$AGENT_ID/evaluation-results?page=1&limit=20" \
  -H "X-API-Key: $SECLAI_API_KEY"

Add evaluate_step to an Agent Definition

Use optimistic locking: fetch definition, then update with expected_change_id.

AGENT_ID=...

# 1) Fetch current definition and change_id
curl "https://api.seclai.com/agents/$AGENT_ID/definition" \
  -H "X-API-Key: $SECLAI_API_KEY"

# 2) Update definition with evaluate_step
curl -X PUT "https://api.seclai.com/agents/$AGENT_ID/definition" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "expected_change_id": "<change-id-from-previous-call>",
    "definition": {
      "name": "My Agent",
      "steps": [
        {
          "id": "generate-report",
          "step_type": "prompt_call",
          "model": "openai_gpt_5",
          "simple_format": true,
          "prompt_template": "Generate a report for: {{agent.input}}"
        },
        {
          "id": "quality-check",
          "step_type": "evaluate_step",
          "target_step_id": "generate-report",
          "evaluation_prompt": "Score factual accuracy and completeness",
          "pass_threshold": 0.7,
          "evaluation_tier": "balanced"
        }
      ]
    }
  }'

Solutions

List Solutions

curl "https://api.seclai.com/solutions?page=1&limit=20" \
  -H "X-API-Key: $SECLAI_API_KEY"

Create a Solution

curl -X POST "https://api.seclai.com/solutions" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "News Monitoring Pipeline",
    "description": "End-to-end news monitoring with sources, knowledge bases, and agents"
  }'

Get a Solution

SOLUTION_ID=...

curl "https://api.seclai.com/solutions/$SOLUTION_ID" \
  -H "X-API-Key: $SECLAI_API_KEY"

Update a Solution

SOLUTION_ID=...

curl -X PATCH "https://api.seclai.com/solutions/$SOLUTION_ID" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Pipeline Name"
  }'

Delete a Solution

SOLUTION_ID=...

curl -X DELETE "https://api.seclai.com/solutions/$SOLUTION_ID" \
  -H "X-API-Key: $SECLAI_API_KEY"
SOLUTION_ID=...

# Link agents
curl -X POST "https://api.seclai.com/solutions/$SOLUTION_ID/agents" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ids": ["agent-id-1", "agent-id-2"]}'

# Link knowledge bases
curl -X POST "https://api.seclai.com/solutions/$SOLUTION_ID/knowledge-bases" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ids": ["kb-id-1"]}'

# Link source connections
curl -X POST "https://api.seclai.com/solutions/$SOLUTION_ID/source-connections" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ids": ["source-id-1", "source-id-2"]}'
SOLUTION_ID=...

# Unlink agents
curl -X DELETE "https://api.seclai.com/solutions/$SOLUTION_ID/agents" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ids": ["agent-id-1"]}'

Content Sources

List Sources

curl "https://api.seclai.com/sources?page=1&limit=20" \
  -H "X-API-Key: $SECLAI_API_KEY"

Create a Source

curl -X POST "https://api.seclai.com/sources" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "TechCrunch RSS",
    "source_type": "rss",
    "url_id": "'$URL_ID'",
    "polling": "daily"
  }'

Get a Source

SOURCE_ID=...

curl "https://api.seclai.com/sources/$SOURCE_ID" \
  -H "X-API-Key: $SECLAI_API_KEY"

Update a Source

SOURCE_ID=...

curl -X PUT "https://api.seclai.com/sources/$SOURCE_ID" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Renamed Source", "polling": "hourly"}'

Delete a Source

SOURCE_ID=...

curl -X DELETE "https://api.seclai.com/sources/$SOURCE_ID" \
  -H "X-API-Key: $SECLAI_API_KEY"

Upload Inline Text to a Source

SOURCE_ID=...

curl -X POST "https://api.seclai.com/sources/$SOURCE_ID/upload-inline-text" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Article content goes here...",
    "title": "My Article",
    "content_type": "text/plain"
  }'

Upload a File to a Source

SOURCE_ID=...

curl -X POST "https://api.seclai.com/sources/$SOURCE_ID/upload" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -F "file=@document.pdf" \
  -F "title=My Document"

Migrate Custom Index Embeddings

Embedding migration is available via both the API-key REST endpoint and the user-authenticated endpoint.

API-key endpoint:

SOURCE_ID=...

curl -X POST "https://api.seclai.com/api/sources/$SOURCE_ID/embedding-migration" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "target_embedding_model": "openai_text_embedding_3_large",
    "target_dimensions": 1024,
    "notification_recipients": ["owner@example.com"]
  }'

Check migration status:

SOURCE_ID=...

curl "https://api.seclai.com/api/sources/$SOURCE_ID/embedding-migration" \
  -H "X-API-Key: $SECLAI_API_KEY"

User-authenticated endpoint (session token):

SOURCE_ID=...
ACCESS_TOKEN=...

curl -X POST "https://api.seclai.com/sources/$SOURCE_ID/embedding-migration" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "target_embedding_model": "openai_text_embedding_3_large",
    "target_dimensions": 1024,
    "notification_recipients": ["owner@example.com"]
  }'

Knowledge Bases

List Knowledge Bases

curl "https://api.seclai.com/knowledge_bases?page=1&limit=20" \
  -H "X-API-Key: $SECLAI_API_KEY"

Create a Knowledge Base

curl -X POST "https://api.seclai.com/knowledge_bases" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Tech News KB",
    "description": "Aggregated tech news sources",
    "source_ids": ["source-id-1", "source-id-2"],
    "top_n": 20,
    "top_k": 5,
    "score_threshold": 0.3
  }'

Get a Knowledge Base

KNOWLEDGE_BASE_ID=...

curl "https://api.seclai.com/knowledge_bases/$KNOWLEDGE_BASE_ID" \
  -H "X-API-Key: $SECLAI_API_KEY"

Update a Knowledge Base

KNOWLEDGE_BASE_ID=...

curl -X PUT "https://api.seclai.com/knowledge_bases/$KNOWLEDGE_BASE_ID" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Renamed KB", "top_k": 10, "score_threshold": 0.5}'

Delete a Knowledge Base

KNOWLEDGE_BASE_ID=...

curl -X DELETE "https://api.seclai.com/knowledge_bases/$KNOWLEDGE_BASE_ID" \
  -H "X-API-Key: $SECLAI_API_KEY"

Contents

Get Content Details

CONTENT_VERSION_ID=...

curl "https://api.seclai.com/contents/$CONTENT_VERSION_ID?start=0&end=5000" \
  -H "X-API-Key: $SECLAI_API_KEY"

List Content Embeddings

CONTENT_VERSION_ID=...

curl "https://api.seclai.com/contents/$CONTENT_VERSION_ID/embeddings?page=1&limit=20" \
  -H "X-API-Key: $SECLAI_API_KEY"

Delete Content

CONTENT_VERSION_ID=...

curl -X DELETE "https://api.seclai.com/contents/$CONTENT_VERSION_ID" \
  -H "X-API-Key: $SECLAI_API_KEY"

Memory Banks

Memory banks give agents persistent memory. See Memory Banks for full details.

List Memory Banks

curl "https://api.seclai.com/memory_banks?page=1&limit=20&sort=created_at&order=desc" \
  -H "X-API-Key: $SECLAI_API_KEY"

Create a Memory Bank

curl -X POST https://api.seclai.com/memory_banks \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Customer Context",
    "mode": "balanced",
    "compaction_prompt": "Summarize key facts and preferences, discarding small talk.",
    "max_turns": 50,
    "retention_days": 90
  }'

Update a Memory Bank

MEMORY_BANK_ID=...

curl -X PUT "https://api.seclai.com/memory_banks/$MEMORY_BANK_ID" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Renamed Bank",
    "compaction_prompt": "Keep only essential facts."
  }'

Get a Memory Bank

MEMORY_BANK_ID=...

curl "https://api.seclai.com/memory_banks/$MEMORY_BANK_ID" \
  -H "X-API-Key: $SECLAI_API_KEY"

Delete a Memory Bank

MEMORY_BANK_ID=...

curl -X DELETE "https://api.seclai.com/memory_banks/$MEMORY_BANK_ID" \
  -H "X-API-Key: $SECLAI_API_KEY"

Delete a Memory Bank's Content Source

Clears all stored memory entries without deleting the bank itself. A new source is created on the next write.

MEMORY_BANK_ID=...

curl -X DELETE "https://api.seclai.com/memory_banks/$MEMORY_BANK_ID/source" \
  -H "X-API-Key: $SECLAI_API_KEY"

Get Agents Using a Memory Bank

MEMORY_BANK_ID=...

curl "https://api.seclai.com/memory_banks/$MEMORY_BANK_ID/agents" \
  -H "X-API-Key: $SECLAI_API_KEY"

List Memory Bank Templates

Returns pre-built template configurations for common memory bank use cases.

curl "https://api.seclai.com/memory_banks/templates" \
  -H "X-API-Key: $SECLAI_API_KEY"

Get Entry Statistics

Returns aggregated statistics for a memory bank including entry counts, token and age distributions, and top keys/speakers/tags. Defaults to the last 30 days.

MEMORY_BANK_ID=...

curl "https://api.seclai.com/memory_banks/$MEMORY_BANK_ID/stats?days=30" \
  -H "X-API-Key: $SECLAI_API_KEY"

Test a Compaction Prompt

Test a compaction prompt against an existing bank's entries or with generated sample entries. Returns original entries, compaction summary, surviving entries, and an LLM-as-judge evaluation.

# Against an existing bank
MEMORY_BANK_ID=...

curl -X POST "https://api.seclai.com/memory_banks/$MEMORY_BANK_ID/test-compaction" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"compaction_prompt": "Keep only key facts and user preferences."}'

# Standalone (no bank required)
curl -X POST "https://api.seclai.com/memory_banks/test-compaction" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"compaction_prompt": "Summarize concisely.", "generate_direction": "Customer support chat about billing", "entry_count": 5}'

Solution AI Assistants

Solution AI assistants use a propose-then-accept workflow. You describe what you want, the assistant generates a plan with proposed actions, and you review and accept or decline the plan before any changes are made.

There are three scoped assistants:

  • Source assistant — manages content sources within a solution
  • Knowledge base assistant — manages knowledge bases (and may propose new sources)
  • Solution assistant — comprehensive planning across sources, knowledge bases, and agents

Generate a Source Plan

SOLUTION_ID=...

curl -X POST "https://api.seclai.com/solutions/$SOLUTION_ID/ai-assistant/source" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_input": "Add RSS feed sources for TechCrunch and Ars Technica with daily polling"
  }'

Response:

{
  "conversation_id": "abc123-...",
  "note": "I'll create two RSS feed sources with daily polling for TechCrunch and Ars Technica.",
  "proposed_actions": [
    {
      "action_type": "create_source",
      "description": "Create RSS feed source for TechCrunch",
      "params": {
        "name": "TechCrunch",
        "url": "https://techcrunch.com/feed/",
        "polling": "daily"
      },
      "is_destructive": false
    },
    {
      "action_type": "create_source",
      "description": "Create RSS feed source for Ars Technica",
      "params": {
        "name": "Ars Technica",
        "url": "https://feeds.arstechnica.com/arstechnica/index",
        "polling": "daily"
      },
      "is_destructive": false
    }
  ],
  "requires_delete_confirmation": false,
  "success": true
}

Generate a Knowledge Base Plan

SOLUTION_ID=...

curl -X POST "https://api.seclai.com/solutions/$SOLUTION_ID/ai-assistant/knowledge-base" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_input": "Create a knowledge base from all the news sources in this solution"
  }'

Generate a Comprehensive Solution Plan

SOLUTION_ID=...

curl -X POST "https://api.seclai.com/solutions/$SOLUTION_ID/ai-assistant/generate" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_input": "Set up a complete news monitoring pipeline: add sources for major tech blogs, create a knowledge base, and configure a daily summarizer agent"
  }'

Accept a Proposed Plan

After reviewing the proposed actions, accept the plan to execute it:

SOLUTION_ID=...
CONVERSATION_ID=...

curl -X POST "https://api.seclai.com/solutions/$SOLUTION_ID/ai-assistant/$CONVERSATION_ID/accept" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

If the plan contains destructive actions (deletions), you must explicitly confirm:

curl -X POST "https://api.seclai.com/solutions/$SOLUTION_ID/ai-assistant/$CONVERSATION_ID/accept" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"confirm_deletions": true}'

Response:

{
  "conversation_id": "abc123-...",
  "executed_actions": [
    {
      "action_type": "create_source",
      "description": "Created RSS feed source for TechCrunch",
      "resource_id": "src-001-...",
      "resource_type": "source",
      "success": true,
      "error": null
    }
  ],
  "success": true,
  "error": null
}

Decline a Proposed Plan

SOLUTION_ID=...
CONVERSATION_ID=...

curl -X POST "https://api.seclai.com/solutions/$SOLUTION_ID/ai-assistant/$CONVERSATION_ID/decline" \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Next Steps