Skip to main content

Documentation Index

Fetch the complete documentation index at: https://agents.candu.ai/llms.txt

Use this file to discover all available pages before exploring further.

User input: “Create a segment of enterprise users who haven’t logged in for 30 days.”

Step 1: Resolve the criteria

The AI begins by looking up available traits before constructing anything. It doesn’t assume field names. It verifies them first.
Create A Segment, Step 1

Tool call 1: look up “plan” traits

GET /api/autoComplete?finder=byUserTraits&q=plan

→ { results: [{ name: "plan", type: "string", count: 5432 }] }

Tool call 2: look up “last login” traits

GET /api/autoComplete?finder=byUserTraits&q=last

→ { results: [{ name: "last_seen_at", type: "datetime", count: 5432 }] }
The AI uses autocomplete_query to verify real field names before building the payload. It doesn’t guess.

Tool call 3: create the segment shell

POST /api/dashboard/segmentsDefinition

{ "name": "Enterprise Users - Inactive 30 Days",
  "description": "Enterprise plan users who haven't logged in for 30+ days" }

→ { "id": "seg_9x8y7z6w", "definition": null }
The shell is created with no definition — that gets applied in the next call, after the user confirms.
Create A Segment, Tool Call 3

Confirmation panel

Create An Segment, Confirmation Panel

Tool call 4: apply segment definition

POST /api/dashboard/segmentsDefinition?action=update&segmentId=seg_9x8y7z6w

{
  "definition": {
    "object": "All",
    "groups": [
      { "object": "Single", "type": "UserProperty",
        "traitName": "plan", "operation": { "type": "Equals", "operand": "enterprise" } },
      { "object": "Single", "type": "UserSeen",
        "userSeenRuleType": "LastSeen", "operation": { "type": "Outside", "operand": 30 } }
    ]
  }
}

→ { "id": "seg_9x8y7z6w", "memberCount": 247 }

Step 2: Test the segment

The wizard advances automatically. At step 2 the wizard prompts: “We’ve created your segment. Let’s test it: do you have a user ID or email in mind?”

Tool call 5: look up user by email

GET /api/autoComplete?finder=byUserEmail&q=john@acme.com

→ { results: [{ userId: "usr_abc123", email: "john@acme.com" }] }

Tool call 6: check membership

GET /api/dashboard/segmentMemberships/usr_abc123

→ { isMember: true, matchedRules: [
     { type: "UserProperty", traitName: "plan", matched: true },
     { type: "UserSeen", matched: true, daysSinceLastSeen: 45 }
   ] }
The AI responds: john@acme.com is in this segment. Plan: enterprise. Last seen: 45 days ago. Your segment is working correctly.”

Execution summary

ActionEndpointPolicyTimeStatus
autocomplete_querybyUserTraits q=planAutomatic87ms200
autocomplete_querybyUserTraits q=lastAutomatic92ms200
segments_createPOST /api/dashboard/segmentsDefinitionConfirm234ms201
segments_updatePOST …?action=updateConfirm412ms200
autocomplete_querybyUserEmailAutomatic65ms200
segment_membership_getusr_abc123Automatic143ms200
6 actions · 1,033ms · 100% success The four reads ran silently. The two writes paused for user confirmation before firing.

What if something fails

Create A Segment, What If Something Fails
If the segments API times out on load, the wizard surfaces a connection error with two options: Retry, or Continue Anyway. If the user continues, the AI builds the segment from scratch without deduplication checks.