Skip to content

Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.

fix(crossbeam): use typed overlap resources and exact record search

Rudy Celekli665700f1e794
diff --git a/tests/clis/crossbeam-overlaps.test.cjs b/tests/clis/crossbeam-overlaps.test.cjs
new file mode 100644
index 0000000..13a34ec
--- /dev/null
+++ b/tests/clis/crossbeam-overlaps.test.cjs
@@ -0,0 +1,53 @@
+const { test } = require('node:test')
+const assert = require('node:assert/strict')
+const { spawnSync } = require('node:child_process')
+const path = require('node:path')
+const cli = path.resolve(__dirname, '../../tools/clis/crossbeam.js')
+function run(args, network = false) {
+ const code = `global.fetch = async (url, options) => {
+ if (!${network}) throw new Error('Unexpected request');
+ return new Response(JSON.stringify({url, method: options.method}));
+ }; process.argv = ['node', ${JSON.stringify(cli)}, ...${JSON.stringify(args)}]; require(${JSON.stringify(cli)});`
+ const r = spawnSync(process.execPath, ['-e', code], {encoding: 'utf8', timeout: 5000, env: {...process.env, CROSSBEAM_API_KEY: 'test-only-token'}})
+ assert.equal(r.status, 0, r.stderr)
+ return JSON.parse(r.stdout)
+}
+test('default overlap list uses accounts and the documented own-population/partner filters', () => {
+ const result = run(['overlaps', 'list', '--partner-id', '42', '--population-id', '7'], true)
+ const url = new URL(result.url)
+ assert.equal(url.pathname, '/v1/overlaps/accounts')
+ assert.equal(url.searchParams.get('partner-id'), '42')
+ assert.deepEqual(url.searchParams.getAll('population-ids[]'), ['7'])
+ assert.equal(url.searchParams.has('partner_id'), false)
+})
+test('lead overlap pages preserve cursor and limit without changing record kind', () => {
+ const result = run(['overlaps', 'list', '--type', 'leads', '--cursor', 'a+/=cursor', '--limit', '100'], true)
+ const url = new URL(result.url)
+ assert.equal(url.pathname, '/v1/overlaps/leads')
+ assert.equal(url.searchParams.get('cursor'), 'a+/=cursor')
+ assert.equal(url.searchParams.get('limit'), '100')
+})
+test('record lookup uses the exact-match search route and partner-population namespace', () => {
+ const result = run(['overlaps', 'get', '--record-id', 'crm/123+tag', '--partner-id', '42', '--partner-population-id', '9'], true)
+ const url = new URL(result.url)
+ assert.equal(url.pathname, '/v1/overlaps/accounts/search')
+ assert.equal(url.searchParams.get('record_id'), 'crm/123+tag')
+ assert.equal(url.searchParams.get('partner-id'), '42')
+ assert.equal(url.searchParams.get('partner-population-ids[]'), '9')
+ assert.equal(url.searchParams.has('population-ids[]'), false)
+})
+test('legacy id flag remains a source-record alias on lead lookups', () => {
+ const result = run(['overlaps', 'get', '--id', 'crm123', '--type', 'leads'], true)
+ const url = new URL(result.url)
+ assert.equal(url.pathname, '/v1/overlaps/leads/search')
+ assert.equal(url.searchParams.get('record_id'), 'crm123')
+})
+test('unsupported record kind and missing source record stop before fetch', () => {
+ assert.match(run(['overlaps', 'list', '--type', 'contacts']).error, /type/)
+ assert.match(run(['overlaps', 'get']).error, /record-id/)
+})
+test('overlap preview uses the same typed endpoint and masks the access token', () => {
+ const result = run(['overlaps', 'list', '--type', 'leads', '--dry-run'])
+ assert.equal(new URL(result.url).pathname, '/v1/overlaps/leads')
+ assert.equal(result.headers.Authorization, 'Bearer ***')
+})
diff --git a/tools/clis/crossbeam.js b/tools/clis/crossbeam.js
index 053927e..5a58104 100755
--- a/tools/clis/crossbeam.js
+++ b/tools/clis/crossbeam.js
@@ -92,26 +92,34 @@ async function main() {
}
break
- case 'overlaps':
+ case 'overlaps': {
+ const type = args.type || 'accounts'
+ if (!['accounts', 'leads'].includes(type)) { result = { error: '--type must be accounts or leads' }; break }
switch (sub) {
case 'list': {
const params = new URLSearchParams()
- if (args['partner-id']) params.set('partner_id', args['partner-id'])
- if (args['population-id']) params.set('population_id', args['population-id'])
+ if (args['partner-id']) params.set('partner-id', args['partner-id'])
+ if (args['population-id']) params.set('population-ids[]', args['population-id'])
+ if (args.cursor) params.set('cursor', args.cursor)
+ if (args.limit) params.set('limit', args.limit)
const qs = params.toString()
- result = await api('GET', `/overlaps${qs ? '?' + qs : ''}`)
+ result = await api('GET', `/overlaps/${type}${qs ? '?' + qs : ''}`)
break
}
case 'get': {
- const id = args.id
- if (!id) { result = { error: '--id required' }; break }
- result = await api('GET', `/overlaps/${id}`)
+ const id = args['record-id'] || args.id
+ if (!id) { result = { error: '--record-id required (source record ID; --id is an alias)' }; break }
+ const params = new URLSearchParams({ record_id: id })
+ if (args['partner-id']) params.set('partner-id', args['partner-id'])
+ if (args['partner-population-id']) params.set('partner-population-ids[]', args['partner-population-id'])
+ result = await api('GET', `/overlaps/${type}/search?${params}`)
break
}
default:
result = { error: 'Unknown overlaps subcommand. Use: list, get' }
}
break
+ }
case 'reports':
switch (sub) {
@@ -168,8 +176,8 @@ async function main() {
get: 'populations get --id <id>',
},
overlaps: {
- list: 'overlaps list [--partner-id <id>] [--population-id <id>]',
- get: 'overlaps get --id <id>',
+ list: 'overlaps list [--type accounts|leads] [--partner-id <id>] [--population-id <own-id>] [--cursor <cursor>] [--limit <n>]',
+ get: 'overlaps get --record-id <source-record-id> [--type accounts|leads] [--partner-id <id>] [--partner-population-id <partner-id>] (--id is a record-id alias)',
},
reports: {
list: 'reports list',
diff --git a/tools/integrations/crossbeam.md b/tools/integrations/crossbeam.md
index dd4406c..f6f9167 100644
--- a/tools/integrations/crossbeam.md
+++ b/tools/integrations/crossbeam.md
@@ -43,17 +43,30 @@ Authorization: Bearer {api_key}
### List Overlaps
```bash
-GET https://api.crossbeam.com/v1/overlaps?partner_id={partner_id}&population_id={population_id}
+GET https://api.crossbeam.com/v1/overlaps/accounts?partner-id={partner_id}&population-ids[]={own_population_id}
Authorization: Bearer {api_key}
```
-### Get Overlap Details
+### Find a Source Record's Overlaps
```bash
-GET https://api.crossbeam.com/v1/overlaps/{id}
+GET https://api.crossbeam.com/v1/overlaps/accounts/search?record_id={source_record_id}
Authorization: Bearer {api_key}
```
+The CLI defaults to partner account overlaps; `--type leads` selects partner
+lead overlaps. The type describes the partner's records, not necessarily your
+own source records. Use `overlaps list --population-id` for your own population
+and `overlaps get --partner-population-id` for the partner's population filter.
+
+`overlaps get --record-id` performs exact source-record matching and returns the
+API's overlap search results. `--id` remains an alias for that source record ID;
+it is not an overlap object's ID. List responses expose `pagination.next_cursor`
+and `has_more`; pass the cursor with `--cursor` and continue until `has_more` is
+false, even if a page is empty. The search endpoint is not paged.
+
+See the [Crossbeam Partner API reference](https://developers.crossbeam.com/).
+
### Search Accounts
```bash