MemoryStackMemoryStack/Documentation

    Agents API

    Create and manage AI agents with persistent memory

    POST/api/v1/agents

    Create a new AI agent with a specific role and personality. Each agent gets its own memory space and can be part of a team.

    Authentication

    Requires API key in Authorization header:

    Authorization: Bearer YOUR_API_KEY

    Request Body

    {
      "name": "Research Assistant",
      "role": "researcher",
      "personality": "Analytical and detail-oriented",
      "projectId": "proj_123",  // Optional
      "teamId": "team_456"      // Optional
    }

    Parameters

    FieldTypeRequiredDescription
    namestringYesDisplay name for the agent
    rolestringYesAgent's role or type (e.g., researcher, writer)
    personalitystringNoPersonality traits and behavior description
    projectIdstringNoProject to associate agent with (defaults to "Default")
    teamIdstringNoTeam ID if agent belongs to a team

    Response

    {
      "agent": {
        "id": "agent_abc123",
        "project_id": "proj_123",
        "owner_clerk_id": "user_xyz789",
        "name": "Research Assistant",
        "agent_type": "researcher",
        "team_id": "team_456",
        "config": {
          "role": "researcher",
          "personality": "Analytical and detail-oriented"
        },
        "created_at": "2024-11-22T10:30:00Z",
        "updated_at": "2024-11-22T10:30:00Z"
      }
    }

    Example Request

    curl -X POST https://your-domain.com/api/v1/agents \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "Research Assistant",
        "role": "researcher",
        "personality": "Analytical and detail-oriented"
      }'
    GET/api/v1/agents

    List all agents owned by the authenticated user, ordered by creation date (newest first).

    Response

    {
      "agents": [
        {
          "id": "agent_abc123",
          "project_id": "proj_123",
          "owner_clerk_id": "user_xyz789",
          "name": "Research Assistant",
          "agent_type": "researcher",
          "team_id": "team_456",
          "config": {
            "role": "researcher",
            "personality": "Analytical and detail-oriented"
          },
          "created_at": "2024-11-22T10:30:00Z",
          "updated_at": "2024-11-22T10:30:00Z"
        },
        {
          "id": "agent_def456",
          "project_id": "proj_123",
          "owner_clerk_id": "user_xyz789",
          "name": "Content Writer",
          "agent_type": "writer",
          "team_id": null,
          "config": {
            "role": "writer",
            "personality": "Creative and engaging"
          },
          "created_at": "2024-11-21T15:20:00Z",
          "updated_at": "2024-11-21T15:20:00Z"
        }
      ]
    }

    Example Request

    curl -X GET https://your-domain.com/api/v1/agents \
      -H "Authorization: Bearer YOUR_API_KEY"
    GET/api/v1/agents/:id

    Retrieve a specific agent by ID. Only returns agents owned by the authenticated user.

    Path Parameters

    ParameterTypeDescription
    idstringAgent ID

    Response

    {
      "agent": {
        "id": "agent_abc123",
        "project_id": "proj_123",
        "owner_clerk_id": "user_xyz789",
        "name": "Research Assistant",
        "agent_type": "researcher",
        "team_id": "team_456",
        "config": {
          "role": "researcher",
          "personality": "Analytical and detail-oriented"
        },
        "created_at": "2024-11-22T10:30:00Z",
        "updated_at": "2024-11-22T10:30:00Z"
      }
    }

    Example Request

    curl -X GET https://your-domain.com/api/v1/agents/agent_abc123 \
      -H "Authorization: Bearer YOUR_API_KEY"
    DELETE/api/v1/agents/:id

    Delete an agent and all associated data. This action cannot be undone.

    Path Parameters

    ParameterTypeDescription
    idstringAgent ID to delete

    Response

    {
      "success": true
    }

    Example Request

    curl -X DELETE https://your-domain.com/api/v1/agents/agent_abc123 \
      -H "Authorization: Bearer YOUR_API_KEY"

    Agent Memory Integration

    Each agent has its own isolated memory space. When creating memories for an agent:

    • • Include the agent_id field when creating memories
    • • Agent memories are automatically scoped to that agent
    • • Use the Memories API with agent_id filter to retrieve agent-specific memories
    • • Agents in teams can share team-level memories via team_id

    See the Memories API documentation for details on memory management.

    Error Responses

    401 Unauthorized

    {
      "error": "Unauthorized"
    }

    404 Not Found

    {
      "error": "Agent not found"
    }

    400 Bad Request

    {
      "error": "Name and role are required"
    }

    500 Internal Server Error

    {
      "error": "Internal server error"
    }