heyreach-cli 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md ADDED
@@ -0,0 +1,385 @@
1
+ # AI Agent Guide — HeyReach CLI
2
+
3
+ > This file helps AI agents (GPT, Claude, Gemini, open-source models, etc.) install, authenticate, and use the HeyReach CLI to manage LinkedIn automation campaigns, leads, lists, conversations, and more via the HeyReach platform.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Install globally
9
+ npm install -g heyreach-cli
10
+
11
+ # Authenticate (non-interactive — best for agents)
12
+ export HEYREACH_API_KEY="your-api-key-here"
13
+
14
+ # Verify it works
15
+ heyreach status
16
+ ```
17
+
18
+ **Requirements:** Node.js 18+
19
+
20
+ ## Authentication
21
+
22
+ Set your API key via environment variable — no interactive login needed:
23
+
24
+ ```bash
25
+ export HEYREACH_API_KEY="your-api-key-here"
26
+ ```
27
+
28
+ Or pass it per-command:
29
+
30
+ ```bash
31
+ heyreach campaigns list --api-key "your-api-key-here"
32
+ ```
33
+
34
+ API keys are generated from: HeyReach → Settings → Integrations → Public API
35
+
36
+ ### Organization API (admin commands)
37
+
38
+ Organization commands (`heyreach org ...`) require a separate Organization API key:
39
+
40
+ ```bash
41
+ export HEYREACH_ORG_API_KEY="your-org-api-key-here"
42
+ ```
43
+
44
+ Or per-command: `heyreach org workspaces --org-key "your-org-key"`
45
+
46
+ ### Key facts
47
+
48
+ - Auth header is `X-API-KEY` (not Bearer token)
49
+ - API keys never expire but can be deleted/deactivated
50
+ - Workspace key and Organization key are separate — each has its own 300 req/min rate limit
51
+ - Base URL is fixed: `https://api.heyreach.io/api/public/`
52
+
53
+ ## Output Format
54
+
55
+ All commands output **JSON to stdout** by default — ready for parsing:
56
+
57
+ ```bash
58
+ # Default: compact JSON
59
+ heyreach campaigns list
60
+ # → {"totalCount":5,"items":[{"id":123,"name":"Q1 Outreach","status":"IN_PROGRESS",...}]}
61
+
62
+ # Pretty-printed JSON
63
+ heyreach campaigns list --pretty
64
+
65
+ # Select specific fields
66
+ heyreach campaigns list --fields id,name,status
67
+
68
+ # Suppress output (exit code only)
69
+ heyreach campaigns list --quiet
70
+ ```
71
+
72
+ **Exit codes:** 0 = success, 1 = error. Errors go to stderr as JSON:
73
+ ```json
74
+ {"error":"No API key found. Run \"heyreach login\" or set HEYREACH_API_KEY.","code":"AUTH_ERROR"}
75
+ ```
76
+
77
+ ## Discovering Commands
78
+
79
+ ```bash
80
+ # List all command groups
81
+ heyreach --help
82
+
83
+ # List subcommands in a group
84
+ heyreach campaigns --help
85
+
86
+ # Get help for a specific subcommand (shows options + examples)
87
+ heyreach campaigns list --help
88
+ ```
89
+
90
+ ## All Command Groups
91
+
92
+ ### campaigns (8 commands)
93
+ Manage LinkedIn outreach campaigns — list, get, pause, resume, add leads, stop leads, pull lead analytics.
94
+
95
+ ```
96
+ list List campaigns (paginated, filterable by keyword/status/account)
97
+ get Get a campaign by ID
98
+ resume Resume a paused campaign
99
+ pause Pause a running campaign
100
+ add-leads Add leads to a campaign (V2 — returns added/updated/failed counts)
101
+ stop-lead Stop a lead's progression in a campaign
102
+ get-leads Get leads from a campaign with status breakdowns
103
+ get-for-lead Find which campaigns a lead is enrolled in
104
+ ```
105
+
106
+ ### inbox (4 commands)
107
+ Read and respond to LinkedIn conversations across all connected accounts.
108
+
109
+ ```
110
+ list List conversations (filter by account, campaign, tags, seen status, search)
111
+ get Get a conversation with all messages by account ID + conversation ID
112
+ send Send a message to a LinkedIn conversation
113
+ set-seen Mark a conversation as seen or unseen
114
+ ```
115
+
116
+ ### accounts (2 commands)
117
+ Manage connected LinkedIn accounts.
118
+
119
+ ```
120
+ list List all LinkedIn accounts (paginated, searchable)
121
+ get Get a LinkedIn account by ID
122
+ ```
123
+
124
+ ### lists (9 commands)
125
+ Manage lead and company lists.
126
+
127
+ ```
128
+ list List all lists (filter by type, keyword, campaign)
129
+ get Get a list by ID
130
+ create Create an empty lead or company list
131
+ get-leads Get leads from a list (up to 1000 per request)
132
+ add-leads Add leads to a list (V2 — returns detailed counts)
133
+ delete-leads Delete leads from a list by LinkedIn member IDs
134
+ delete-leads-by-url Delete leads from a list by LinkedIn profile URLs
135
+ get-companies Get companies from a company list
136
+ get-for-lead Find which lists a lead belongs to
137
+ ```
138
+
139
+ ### stats (1 command)
140
+ Pull campaign analytics with day-by-day breakdown.
141
+
142
+ ```
143
+ overview Overall stats for date range (profile views, messages, connections, reply rates)
144
+ ```
145
+
146
+ ### leads (4 commands)
147
+ Look up and tag individual leads.
148
+
149
+ ```
150
+ get Get lead details by LinkedIn profile URL
151
+ add-tags Add tags to a lead (existing tags unchanged)
152
+ get-tags Get tags for a lead (alphabetically sorted)
153
+ replace-tags Remove all existing tags and replace with new tags
154
+ ```
155
+
156
+ ### lead-tags (1 command)
157
+ Create workspace-level tags.
158
+
159
+ ```
160
+ create Create one or multiple tags with display name and color
161
+ ```
162
+
163
+ ### webhooks (5 commands)
164
+ Subscribe to real-time LinkedIn events.
165
+
166
+ ```
167
+ create Create a webhook for a specific event type
168
+ get Get a webhook by ID
169
+ list List all webhooks (paginated)
170
+ update Update webhook configuration (name, URL, event type, active status)
171
+ delete Delete a webhook
172
+ ```
173
+
174
+ ### network (2 commands)
175
+ Query LinkedIn network connections.
176
+
177
+ ```
178
+ list Get network connections for a LinkedIn sender (uses pageNumber/pageSize pagination)
179
+ check Check if a lead is connected to a specific sender
180
+ ```
181
+
182
+ ### org (11 commands)
183
+ Organization management — requires Organization API key.
184
+
185
+ ```
186
+ workspaces List all workspaces
187
+ create-workspace Create a new workspace
188
+ update-workspace Update workspace name or seat limit
189
+ api-keys Get API/integration keys for a workspace
190
+ create-api-key Generate a new API key (PUBLIC, N8N, MAKE, ZAPIER, MCP)
191
+ users List all org users (filter by role, invitation status)
192
+ get-user Get user details by ID
193
+ workspace-users List users in a specific workspace
194
+ invite-admins Invite users as organization admins
195
+ invite-members Invite users with specific workspace permissions
196
+ invite-managers Invite external managers with workspace access
197
+ ```
198
+
199
+ ## Common Workflows
200
+
201
+ ### Find and tag a lead
202
+
203
+ ```bash
204
+ # Look up lead details
205
+ heyreach leads get --profile-url "https://linkedin.com/in/janedoe" --pretty
206
+
207
+ # Add tags
208
+ heyreach leads add-tags --profile-url "https://linkedin.com/in/janedoe" \
209
+ --tags "hot,enterprise" --create-if-missing
210
+
211
+ # Check which campaigns they're in
212
+ heyreach campaigns get-for-lead --profile-url "https://linkedin.com/in/janedoe" --pretty
213
+ ```
214
+
215
+ ### Add leads to a campaign
216
+
217
+ ```bash
218
+ # Add leads with full profile data
219
+ heyreach campaigns add-leads --campaign-id 123 --leads-json '[
220
+ {
221
+ "lead": {
222
+ "firstName": "Jane",
223
+ "lastName": "Doe",
224
+ "profileUrl": "https://linkedin.com/in/janedoe",
225
+ "companyName": "Acme Inc",
226
+ "position": "VP Sales",
227
+ "emailAddress": "jane@acme.com"
228
+ }
229
+ }
230
+ ]'
231
+ # → {"addedLeadsCount":1,"updatedLeadsCount":0,"failedLeadsCount":0}
232
+ ```
233
+
234
+ ### Monitor inbox for new replies
235
+
236
+ ```bash
237
+ # Check for unseen conversations
238
+ heyreach inbox list --seen false --pretty
239
+
240
+ # Read a conversation
241
+ heyreach inbox get --account-id 456 --conversation-id "conv-abc" --pretty
242
+
243
+ # Reply
244
+ heyreach inbox send --conversation-id "conv-abc" --account-id 456 \
245
+ --message "Thanks for connecting! Would love to schedule a quick call."
246
+
247
+ # Mark as seen
248
+ heyreach inbox set-seen --conversation-id "conv-abc" --account-id 456 --seen true
249
+ ```
250
+
251
+ ### Set up event notifications
252
+
253
+ ```bash
254
+ # Create a webhook for new message replies
255
+ heyreach webhooks create --name "Reply Hook" \
256
+ --url "https://your-endpoint.com/hook" \
257
+ --event-type MESSAGE_REPLY_RECEIVED
258
+
259
+ # Create a webhook for connection accepts (specific campaigns only)
260
+ heyreach webhooks create --name "Connections" \
261
+ --url "https://your-endpoint.com/hook" \
262
+ --event-type CONNECTION_REQUEST_ACCEPTED \
263
+ --campaign-ids "123,456"
264
+ ```
265
+
266
+ ### Pull analytics
267
+
268
+ ```bash
269
+ # Last 30 days overall stats
270
+ heyreach stats overview \
271
+ --start-date "2025-01-01T00:00:00Z" \
272
+ --end-date "2025-01-31T23:59:59Z" \
273
+ --pretty
274
+ # → { byDayStats: {...}, overallStats: { messagesSent, totalMessageReplies, ... } }
275
+ ```
276
+
277
+ ### Manage lists
278
+
279
+ ```bash
280
+ # Create a list
281
+ heyreach lists create --name "Q2 Targets"
282
+
283
+ # Add leads
284
+ heyreach lists add-leads --list-id 789 --leads-json '[
285
+ {"firstName":"Alex","lastName":"Chen","profileUrl":"https://linkedin.com/in/alexchen"}
286
+ ]'
287
+
288
+ # Search leads in a list
289
+ heyreach lists get-leads --list-id 789 --keyword "alex" --pretty
290
+
291
+ # Remove leads by profile URL
292
+ heyreach lists delete-leads-by-url --list-id 789 \
293
+ --urls "https://linkedin.com/in/alexchen"
294
+ ```
295
+
296
+ ### Organization admin
297
+
298
+ ```bash
299
+ # List workspaces (requires org key)
300
+ heyreach org workspaces --pretty
301
+
302
+ # Create a workspace with seat limit
303
+ heyreach org create-workspace --name "Sales Team" --seats-limit 10
304
+
305
+ # Invite a member with permissions
306
+ heyreach org invite-members \
307
+ --inviter-email "admin@company.com" \
308
+ --emails "user@company.com" \
309
+ --workspace-ids "123" \
310
+ --permissions-json '{"viewCampaigns":true,"editManageCampaigns":true,"viewLeadLists":true}'
311
+ ```
312
+
313
+ ## Pagination
314
+
315
+ Most list endpoints use offset/limit in the POST body:
316
+
317
+ ```bash
318
+ # First page (defaults: offset=0, limit=100)
319
+ heyreach campaigns list
320
+
321
+ # Next page
322
+ heyreach campaigns list --offset 100 --limit 100
323
+ ```
324
+
325
+ Response: `{ "totalCount": 250, "items": [...] }`
326
+
327
+ **Max items per request:** 100 (1000 for lead/company list queries)
328
+
329
+ **Exception:** Network commands use `--page` and `--page-size` instead of offset/limit.
330
+
331
+ ## Key Enums
332
+
333
+ **Campaign statuses:** DRAFT, IN_PROGRESS, PAUSED, FINISHED, CANCELED, FAILED, STARTING, SCHEDULED
334
+
335
+ **Webhook event types:** CONNECTION_REQUEST_SENT, CONNECTION_REQUEST_ACCEPTED, MESSAGE_SENT, MESSAGE_REPLY_RECEIVED, INMAIL_SENT, INMAIL_REPLY_RECEIVED, EVERY_MESSAGE_REPLY_RECEIVED, FOLLOW_SENT, LIKED_POST, VIEWED_PROFILE, CAMPAIGN_COMPLETED, LEAD_TAG_UPDATED
336
+
337
+ **List types:** USER_LIST, COMPANY_LIST
338
+
339
+ **Tag colors:** Blue, Green, Purple, Pink, Red, Cyan, Yellow, Orange
340
+
341
+ **API key types:** PUBLIC, N8N, MAKE, ZAPIER, MCP
342
+
343
+ **User roles:** Admin, Member, Manager
344
+
345
+ **Invitation statuses:** Unknown, Pending, Accepted, Expired, Revoked
346
+
347
+ ## MCP Server (for Claude, Cursor, VS Code)
348
+
349
+ The CLI includes a built-in MCP server exposing all 47 commands as tools:
350
+
351
+ ```bash
352
+ heyreach mcp
353
+ ```
354
+
355
+ MCP config for your AI assistant:
356
+ ```json
357
+ {
358
+ "mcpServers": {
359
+ "heyreach": {
360
+ "command": "npx",
361
+ "args": ["heyreach-cli", "mcp"],
362
+ "env": {
363
+ "HEYREACH_API_KEY": "your-key"
364
+ }
365
+ }
366
+ }
367
+ }
368
+ ```
369
+
370
+ ## Tips for AI Agents
371
+
372
+ 1. **Always use `--help`** on a group before guessing subcommand names
373
+ 2. **Parse JSON output** directly — it's the default format
374
+ 3. **Check exit codes** — 0 means success, 1 means error
375
+ 4. **Required options** are enforced with clear error messages before API calls
376
+ 5. **Rate limits** are handled automatically (300 req/min) with exponential backoff retry
377
+ 6. **Use `--fields`** to reduce output size when you only need specific data
378
+ 7. **Use `--quiet`** when you only care about success/failure
379
+ 8. **Use `--pretty`** for human-readable JSON output
380
+ 9. **Most list endpoints use POST** — the CLI handles this internally, just use the commands
381
+ 10. **Comma-separated inputs** work for arrays: `--statuses "IN_PROGRESS,PAUSED"`, `--tags "hot,priority"`
382
+ 11. **JSON inputs** use `--xxx-json` flags: `--leads-json`, `--tags-json`, `--permissions-json`
383
+ 12. **Org commands need a separate key** — set `HEYREACH_ORG_API_KEY` for `heyreach org ...` commands
384
+ 13. **Lead lookup is by profile URL** — use `--profile-url` to identify leads across most endpoints
385
+ 14. **V2 endpoints are used by default** — `add-leads` returns `{addedLeadsCount, updatedLeadsCount, failedLeadsCount}` instead of just a number