Portal Community

Unified Search Endpoint

GET /api/workdesk/search
Authorization: Bearer {token}

// Query parameters
?q=expense+approval      // required — minimum 2 characters
&section=tasks           // optional — tasks | history | notifications | all (default: all)
&limit=5                 // optional — results per section (default: 5, max: 20)
&page=1                  // optional — for paginating within a section result set

// Response — global search (all sections)
{
  "query": "expense approval",
  "tasks": {
    "items": [
      {
        "taskId": "3fa85f64-...",
        "type": "approval",
        "title": "Expense Report Approval — Q1 Marketing",
        "status": "pending",
        "dueAt": "2026-05-27T17:00:00Z",
        "workflowName": "Expense Approval Flow",
        "score": 0.95,                   // relevance score 0-1
        "matchHighlights": {
          "title": "Expense Report <mark>Approval</mark> — Q1 Marketing"
        }
      }
    ],
    "totalCount": 2,
    "hasMore": false
  },
  "history": {
    "items": [
      {
        "executionId": "7bc12d45-...",
        "workflowName": "Expense Approval Flow",
        "status": "completed",
        "triggeredAt": "2026-05-25T09:12:00Z",
        "score": 0.87
      }
    ],
    "totalCount": 3,
    "hasMore": true
  },
  "notifications": {
    "items": [
      {
        "notificationId": "notif-789",
        "type": "hil_task_assigned",
        "title": "New Approval Task",
        "body": "...",
        "isRead": false,
        "createdAt": "2026-05-25T10:00:00Z",
        "score": 0.72
      }
    ],
    "totalCount": 1,
    "hasMore": false
  },
  "took": 48                           // query execution time in ms
}

Section-Scoped Search

// Search only in tasks
GET /api/workdesk/search?q=budget+review&section=tasks&limit=20

// Search only in history
GET /api/workdesk/search?q=payroll&section=history&limit=20

// Response — scoped search returns full paginated results for that section only
{
  "query": "budget review",
  "section": "tasks",
  "items": [ { ... task objects ... } ],
  "totalCount": 7,
  "page": 1,
  "pageSize": 20,
  "took": 22
}

Relevance Scoring

Results within each section are ranked by relevance score (0-1, higher is more relevant):

Match TypeScore Range
Exact title match0.9 – 1.0
Partial title match (starts with)0.75 – 0.9
Partial title match (contains)0.5 – 0.75
Body / description match0.3 – 0.5
Metadata match (workflow name)0.2 – 0.4

Error Responses

HTTP StatusError CodeMeaning
400QUERY_TOO_SHORTQuery is less than 2 characters
400INVALID_SECTIONUnknown section value
400LIMIT_EXCEEDEDLimit parameter exceeds maximum of 20
401UNAUTHORIZEDMissing or invalid JWT
429RATE_LIMITEDToo many search requests — rate limit: 60/minute per user