AppMage

ThreadRpc

ThreadRpc provides the thread-related JSON-RPC surface for creating, listing, updating, deleting, and managing chat thread membership, as well as a small set of thread-scoped file and sandbox helpers. It also includes title generation support and a read-marking action for the current user.

Endpoints

POST /api/rpc (Method: ThreadRpc.create)

  • Description: Creates a new chat thread.

  • Request Body:

    {
      "method": "ThreadRpc.create",
      "params": {
        "agentName": "string",
        "title": "string",
        "type": "ai_only | ai_human | group",
        "groupName": "string",
        "aiResponseMode": "always | mentioned | manual"
      }
    }
  • Parameters:

    Name Type Required Description
    agentName String Yes Agent name associated with the new thread.
    title String No Initial thread title.
    type String No Thread type. Allowed values are ai_only, ai_human, and group.
    groupName String No Group name for group threads.
    aiResponseMode String No AI response mode. Allowed values are always, mentioned, and manual.
  • Response:

    {
      "success": true,
      "data": {
        "...": "Depends on the underlying thread creation result."
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ThreadRpc.create",
        "params": {
          "agentName": "sales-assistant"
        }
      }'

POST /api/rpc (Method: ThreadRpc.getData)

  • Description: Lists all threads the current user participates in.

  • Request Body:

    {
      "method": "ThreadRpc.getData",
      "params": {
        "filter": {},
        "page": 1,
        "pageSize": 50
      }
    }
  • Parameters:

    Name Type Required Description
    filter Record<string, any> No Arbitrary filter object. Defaults to an empty object.
    page Number No Page number. Must be a positive integer. Defaults to 1.
    pageSize Number No Page size. Must be a positive integer. Defaults to 50.
  • Response:

    {
      "success": true,
      "data": {
        "...": "Thread list data returned by the thread listing service."
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ThreadRpc.getData",
        "params": {
          "page": 1,
          "pageSize": 50
        }
      }'

POST /api/rpc (Method: ThreadRpc.update)

  • Description: Updates thread metadata, including title, group name, group avatar, AI response mode, and status.

  • Request Body:

    {
      "method": "ThreadRpc.update",
      "params": {
        "_id": "string",
        "title": "string",
        "groupName": "string",
        "groupAvatarUrl": "string",
        "aiResponseMode": "always | mentioned | manual",
        "status": "active | archived"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes Thread identifier.
    title String No New thread title.
    groupName String No New group name.
    groupAvatarUrl String No Group avatar URL.
    aiResponseMode String No AI response mode. Allowed values are always, mentioned, and manual.
    status String No Thread status. Allowed values are active and archived.
  • Response:

    {
      "success": true,
      "data": {
        "...": "Updated thread data."
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ThreadRpc.update",
        "params": {
          "_id": "thread_123",
          "title": "New title"
        }
      }'

POST /api/rpc (Method: ThreadRpc.delete)

  • Description: Deletes a thread and all its messages.

  • Request Body:

    {
      "method": "ThreadRpc.delete",
      "params": {
        "_id": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes Thread identifier.
  • Response:

    {
      "success": true,
      "data": {
        "...": "Deletion result returned by the thread service."
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ThreadRpc.delete",
        "params": {
          "_id": "thread_123"
        }
      }'

POST /api/rpc (Method: ThreadRpc.addMember)

  • Description: Adds a participant to a thread.

  • Request Body:

    {
      "method": "ThreadRpc.addMember",
      "params": {
        "threadId": "string",
        "participantId": "string",
        "participantType": "user | agent | contact",
        "displayName": "string",
        "avatarUrl": "string | null",
        "transport": "string | null",
        "transportId": "string | null",
        "role": "member | observer | assistant"
      }
    }
  • Parameters:

    Name Type Required Description
    threadId String Yes Thread identifier.
    participantId String Yes Participant identifier.
    participantType String No Participant type. Allowed values are user, agent, and contact. Defaults to user.
    displayName String No Display name for the participant.
    avatarUrl String or Null No Participant avatar URL.
    transport String or Null No Transport name.
    transportId String or Null No Transport-specific identifier.
    role String No Participant role. Allowed values are member, observer, and assistant. Defaults to member.
  • Response:

    {
      "success": true,
      "data": {
        "...": "Updated thread data."
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ThreadRpc.addMember",
        "params": {
          "threadId": "thread_123",
          "participantId": "user_456"
        }
      }'

POST /api/rpc (Method: ThreadRpc.removeMember)

  • Description: Removes a participant from a thread.

  • Request Body:

    {
      "method": "ThreadRpc.removeMember",
      "params": {
        "threadId": "string",
        "participantId": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    threadId String Yes Thread identifier.
    participantId String Yes Participant identifier.
  • Response:

    {
      "success": true,
      "data": {
        "...": "Removal result returned by the thread service."
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ThreadRpc.removeMember",
        "params": {
          "threadId": "thread_123",
          "participantId": "user_456"
        }
      }'

POST /api/rpc (Method: ThreadRpc.markAsRead)

  • Description: Marks the thread as read up to a specific message.

  • Request Body:

    {
      "method": "ThreadRpc.markAsRead",
      "params": {
        "threadId": "string",
        "messageId": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    threadId String Yes Thread identifier.
    messageId String No Message identifier used as the read boundary.
  • Response:

    {
      "success": true,
      "data": {
        "success": true
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "ThreadRpc.markAsRead",
        "params": {
          "threadId": "thread_123",
          "messageId": "msg_789"
        }
      }'

POST /api/rpc (Method: ThreadRpc.setUserState)

  • Description: Updates scoped user preferences for a thread, including pin, star, and archive state.
  • Request Body:
    {
      "method": "ThreadRpc.setUserState",
      "params": {
        "threadId": "string",
        "preferences": {
          "is