featurebase-node 0.9.0 → 0.11.0
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/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/resources/support/conversations/conversations.d.mts +106 -95
- package/resources/support/conversations/conversations.d.mts.map +1 -1
- package/resources/support/conversations/conversations.d.ts +106 -95
- package/resources/support/conversations/conversations.d.ts.map +1 -1
- package/resources/support/conversations/conversations.js +21 -15
- package/resources/support/conversations/conversations.js.map +1 -1
- package/resources/support/conversations/conversations.mjs +21 -15
- package/resources/support/conversations/conversations.mjs.map +1 -1
- package/resources/users/companies/companies.d.mts +237 -1
- package/resources/users/companies/companies.d.mts.map +1 -1
- package/resources/users/companies/companies.d.ts +237 -1
- package/resources/users/companies/companies.d.ts.map +1 -1
- package/resources/users/companies/companies.js +94 -0
- package/resources/users/companies/companies.js.map +1 -1
- package/resources/users/companies/companies.mjs +94 -0
- package/resources/users/companies/companies.mjs.map +1 -1
- package/resources/users/companies/index.d.mts +1 -1
- package/resources/users/companies/index.d.mts.map +1 -1
- package/resources/users/companies/index.d.ts +1 -1
- package/resources/users/companies/index.d.ts.map +1 -1
- package/resources/users/companies/index.js.map +1 -1
- package/resources/users/companies/index.mjs.map +1 -1
- package/resources/users/contacts/contacts.d.mts +261 -1
- package/resources/users/contacts/contacts.d.mts.map +1 -1
- package/resources/users/contacts/contacts.d.ts +261 -1
- package/resources/users/contacts/contacts.d.ts.map +1 -1
- package/resources/users/contacts/contacts.js +99 -0
- package/resources/users/contacts/contacts.js.map +1 -1
- package/resources/users/contacts/contacts.mjs +99 -0
- package/resources/users/contacts/contacts.mjs.map +1 -1
- package/resources/users/contacts/index.d.mts +1 -1
- package/resources/users/contacts/index.d.mts.map +1 -1
- package/resources/users/contacts/index.d.ts +1 -1
- package/resources/users/contacts/index.d.ts.map +1 -1
- package/resources/users/contacts/index.js.map +1 -1
- package/resources/users/contacts/index.mjs.map +1 -1
- package/resources/users/index.d.mts +2 -2
- package/resources/users/index.d.mts.map +1 -1
- package/resources/users/index.d.ts +2 -2
- package/resources/users/index.d.ts.map +1 -1
- package/resources/users/index.js.map +1 -1
- package/resources/users/index.mjs.map +1 -1
- package/resources/users/users.d.mts +4 -4
- package/resources/users/users.d.mts.map +1 -1
- package/resources/users/users.d.ts +4 -4
- package/resources/users/users.d.ts.map +1 -1
- package/resources/users/users.js.map +1 -1
- package/resources/users/users.mjs.map +1 -1
- package/src/resources/support/conversations/conversations.ts +121 -112
- package/src/resources/users/companies/companies.ts +289 -0
- package/src/resources/users/companies/index.ts +2 -0
- package/src/resources/users/contacts/contacts.ts +320 -0
- package/src/resources/users/contacts/index.ts +2 -0
- package/src/resources/users/index.ts +4 -0
- package/src/resources/users/users.ts +8 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
|
@@ -411,6 +411,101 @@ export class Companies extends APIResource {
|
|
|
411
411
|
]),
|
|
412
412
|
});
|
|
413
413
|
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Search companies with a structured filter AST, sorting, and cursor pagination.
|
|
417
|
+
*
|
|
418
|
+
* ### Structured query AST
|
|
419
|
+
*
|
|
420
|
+
* Each clause has the shape `{ field, operator, value }`. You can pass a single
|
|
421
|
+
* clause or wrap up to 15 in a top-level `AND` group:
|
|
422
|
+
*
|
|
423
|
+
* ```json
|
|
424
|
+
* {
|
|
425
|
+
* "query": {
|
|
426
|
+
* "operator": "AND",
|
|
427
|
+
* "value": [
|
|
428
|
+
* { "field": "plan", "operator": "IN", "value": ["enterprise", "pro"] },
|
|
429
|
+
* { "field": "monthly_spend", "operator": ">", "value": 1000 }
|
|
430
|
+
* ]
|
|
431
|
+
* },
|
|
432
|
+
* "sort": "monthly_spend:desc",
|
|
433
|
+
* "limit": 20
|
|
434
|
+
* }
|
|
435
|
+
* ```
|
|
436
|
+
*
|
|
437
|
+
* Top-level `OR` groups and nested groups are not supported in this version.
|
|
438
|
+
*
|
|
439
|
+
* ### Supported fields and operators
|
|
440
|
+
*
|
|
441
|
+
* | Field | Type | Operators |
|
|
442
|
+
* | --------------- | ----------------------------------- | --------------------------- |
|
|
443
|
+
* | `external_id` | string (caller-provided company id) | `=`, `!=`, `IN`, `NIN` |
|
|
444
|
+
* | `name` | string | `=`, `!=`, `IN`, `NIN`, `~` |
|
|
445
|
+
* | `monthly_spend` | number | `=`, `!=`, `>`, `<` |
|
|
446
|
+
* | `plan` | string | `=`, `!=`, `IN`, `NIN` |
|
|
447
|
+
* | `industry` | string | `=`, `!=`, `IN`, `NIN` |
|
|
448
|
+
* | `website` | string | `=`, `!=`, `IN`, `NIN` |
|
|
449
|
+
* | `company_size` | number | `=`, `!=`, `>`, `<` |
|
|
450
|
+
* | `linked_users` | number | `=`, `!=`, `>`, `<` |
|
|
451
|
+
* | `last_activity` | unix seconds | `=`, `!=`, `>`, `<` |
|
|
452
|
+
* | `created_at` | unix seconds | `=`, `!=`, `>`, `<` |
|
|
453
|
+
*
|
|
454
|
+
* The `name ~ "..."` operator runs a word-aware substring search via the
|
|
455
|
+
* underlying text index. Other string operators (`!~`, `^`, `$`) are reserved for
|
|
456
|
+
* future use and currently return `400`.
|
|
457
|
+
*
|
|
458
|
+
* A query consisting only of `!=` or `NIN` clauses is rejected with
|
|
459
|
+
* `query_too_broad` to prevent full-org scans. Combine the negation with at least
|
|
460
|
+
* one positive clause (`=`, `IN`, `>`, `<`) instead.
|
|
461
|
+
*
|
|
462
|
+
* ### Sort
|
|
463
|
+
*
|
|
464
|
+
* Allowed values:
|
|
465
|
+
*
|
|
466
|
+
* - `created_at:desc` (default), `created_at:asc`
|
|
467
|
+
* - `monthly_spend:desc`, `monthly_spend:asc`
|
|
468
|
+
* - `last_activity:desc`, `last_activity:asc`
|
|
469
|
+
*
|
|
470
|
+
* The chosen sort axis is encoded in the cursor; switching `sort` mid-pagination
|
|
471
|
+
* returns `400 invalid_cursor`. Restart pagination without a cursor when changing
|
|
472
|
+
* sort.
|
|
473
|
+
*
|
|
474
|
+
* ### Pagination
|
|
475
|
+
*
|
|
476
|
+
* Cursor-based, `limit` between 1 and 100 (default 10). `totalCount` is
|
|
477
|
+
* approximate and capped at 5000; `totalCountCapped` is `true` when the real count
|
|
478
|
+
* may be higher.
|
|
479
|
+
*
|
|
480
|
+
* ### Response
|
|
481
|
+
*
|
|
482
|
+
* Returns a standard list envelope with company rows identical to
|
|
483
|
+
* `GET /v2/companies/{id}`.
|
|
484
|
+
*
|
|
485
|
+
* ### Version Availability
|
|
486
|
+
*
|
|
487
|
+
* This endpoint is only available in API version 2026-01-01.nova and newer.
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* ```ts
|
|
491
|
+
* const response = await client.users.companies.search();
|
|
492
|
+
* ```
|
|
493
|
+
*/
|
|
494
|
+
search(params: CompanySearchParams, options?: RequestOptions): APIPromise<CompanySearchResponse> {
|
|
495
|
+
const { 'Featurebase-Version': featurebaseVersion, ...body } = params;
|
|
496
|
+
return this._client.post('/v2/companies/search', {
|
|
497
|
+
body,
|
|
498
|
+
...options,
|
|
499
|
+
headers: buildHeaders([
|
|
500
|
+
{
|
|
501
|
+
...(featurebaseVersion?.toString() != null ?
|
|
502
|
+
{ 'Featurebase-Version': featurebaseVersion?.toString() }
|
|
503
|
+
: undefined),
|
|
504
|
+
},
|
|
505
|
+
options?.headers,
|
|
506
|
+
]),
|
|
507
|
+
});
|
|
508
|
+
}
|
|
414
509
|
}
|
|
415
510
|
|
|
416
511
|
export type CompaniesCursorPage = CursorPage<Company>;
|
|
@@ -504,6 +599,110 @@ export interface DeletedCompany {
|
|
|
504
599
|
object: 'company';
|
|
505
600
|
}
|
|
506
601
|
|
|
602
|
+
export interface CompanySearchResponse {
|
|
603
|
+
/**
|
|
604
|
+
* Array of search results
|
|
605
|
+
*/
|
|
606
|
+
data: Array<CompanySearchResponse.Data>;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Cursor for fetching the next page (null if no more results)
|
|
610
|
+
*/
|
|
611
|
+
nextCursor: string | null;
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Object type identifier
|
|
615
|
+
*/
|
|
616
|
+
object: 'list';
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Total number of companies matching the query, capped at 5000. When the actual
|
|
620
|
+
* total is at or above the cap, `totalCountCapped` is true and the value is
|
|
621
|
+
* exactly the cap.
|
|
622
|
+
*/
|
|
623
|
+
totalCount?: number;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* True when `totalCount` is exactly the cap and the real count may be higher. UI
|
|
627
|
+
* can render as e.g. "5000+".
|
|
628
|
+
*/
|
|
629
|
+
totalCountCapped?: boolean;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
export namespace CompanySearchResponse {
|
|
633
|
+
export interface Data {
|
|
634
|
+
/**
|
|
635
|
+
* Featurebase internal ID
|
|
636
|
+
*/
|
|
637
|
+
id: string;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* External company ID from your system
|
|
641
|
+
*/
|
|
642
|
+
companyId: string;
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Company employee headcount
|
|
646
|
+
*/
|
|
647
|
+
companySize: number | null;
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* ISO date when company was created
|
|
651
|
+
*/
|
|
652
|
+
createdAt: string | null;
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Industry
|
|
656
|
+
*/
|
|
657
|
+
industry: string | null;
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* ISO date of last activity
|
|
661
|
+
*/
|
|
662
|
+
lastActivity: string | null;
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Number of users linked to this company
|
|
666
|
+
*/
|
|
667
|
+
linkedUsers: number | null;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Monthly spend
|
|
671
|
+
*/
|
|
672
|
+
monthlySpend: number | null;
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Company name
|
|
676
|
+
*/
|
|
677
|
+
name: string;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Object type identifier
|
|
681
|
+
*/
|
|
682
|
+
object: 'company';
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Plan or tier name
|
|
686
|
+
*/
|
|
687
|
+
plan: string | null;
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* ISO date when company was last updated
|
|
691
|
+
*/
|
|
692
|
+
updatedAt: string | null;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Company website URL
|
|
696
|
+
*/
|
|
697
|
+
website: string | null;
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Custom field values
|
|
701
|
+
*/
|
|
702
|
+
customFields?: { [key: string]: unknown };
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
|
|
507
706
|
export interface CompanyRetrieveParams {
|
|
508
707
|
/**
|
|
509
708
|
* API version for this request. Defaults to your organization's configured API
|
|
@@ -605,18 +804,108 @@ export interface CompanyDeleteByCompanyIDParams {
|
|
|
605
804
|
'Featurebase-Version'?: '2026-01-01.nova' | '2025-12-12.clover';
|
|
606
805
|
}
|
|
607
806
|
|
|
807
|
+
export interface CompanySearchParams {
|
|
808
|
+
/**
|
|
809
|
+
* Body param: An opaque cursor for pagination. Use the `nextCursor` value from a
|
|
810
|
+
* previous response to fetch the next page of results.
|
|
811
|
+
*/
|
|
812
|
+
cursor?: string;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Body param: A limit on the number of objects to be returned, between 1 and 100.
|
|
816
|
+
*/
|
|
817
|
+
limit?: number;
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Body param: Structured filter AST. Either a single filter clause or one
|
|
821
|
+
* top-level AND group (max 15 clauses). Top-level OR groups are not yet supported.
|
|
822
|
+
*/
|
|
823
|
+
query?: CompanySearchParams.SearchFilter | CompanySearchParams.SearchFilterGroup;
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Body param: Sort field + direction. Defaults to `created_at:desc`. The chosen
|
|
827
|
+
* sort axis is encoded in the cursor; switching `sort` mid-pagination returns
|
|
828
|
+
* `400 invalid_cursor`.
|
|
829
|
+
*/
|
|
830
|
+
sort?:
|
|
831
|
+
| 'created_at:desc'
|
|
832
|
+
| 'created_at:asc'
|
|
833
|
+
| 'monthly_spend:desc'
|
|
834
|
+
| 'monthly_spend:asc'
|
|
835
|
+
| 'last_activity:desc'
|
|
836
|
+
| 'last_activity:asc';
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Header param: API version for this request. Defaults to your organization's
|
|
840
|
+
* configured API version if not specified.
|
|
841
|
+
*/
|
|
842
|
+
'Featurebase-Version'?: '2026-01-01.nova' | '2025-12-12.clover';
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
export namespace CompanySearchParams {
|
|
846
|
+
export interface SearchFilter {
|
|
847
|
+
/**
|
|
848
|
+
* Field name to filter on (e.g. `state`, `tag_ids`, `created_at`)
|
|
849
|
+
*/
|
|
850
|
+
field: string;
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* Comparison operator
|
|
854
|
+
*/
|
|
855
|
+
operator: '=' | '!=' | 'IN' | 'NIN' | '>' | '<' | '>=' | '<=' | '~' | '!~' | '^' | '$';
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Value to compare against (primitive or array of primitives)
|
|
859
|
+
*/
|
|
860
|
+
value: string | number | boolean | Array<string | number> | null;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
export interface SearchFilterGroup {
|
|
864
|
+
/**
|
|
865
|
+
* Group operator: AND (all match) or OR (any match)
|
|
866
|
+
*/
|
|
867
|
+
operator: 'AND' | 'OR';
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Array of filter clauses (1-15 entries)
|
|
871
|
+
*/
|
|
872
|
+
value: Array<SearchFilterGroup.Value>;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
export namespace SearchFilterGroup {
|
|
876
|
+
export interface Value {
|
|
877
|
+
/**
|
|
878
|
+
* Field name to filter on (e.g. `state`, `tag_ids`, `created_at`)
|
|
879
|
+
*/
|
|
880
|
+
field: string;
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* Comparison operator
|
|
884
|
+
*/
|
|
885
|
+
operator: '=' | '!=' | 'IN' | 'NIN' | '>' | '<' | '>=' | '<=' | '~' | '!~' | '^' | '$';
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Value to compare against (primitive or array of primitives)
|
|
889
|
+
*/
|
|
890
|
+
value: string | number | boolean | Array<string | number> | null;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
608
895
|
Companies.Contacts = Contacts;
|
|
609
896
|
|
|
610
897
|
export declare namespace Companies {
|
|
611
898
|
export {
|
|
612
899
|
type Company as Company,
|
|
613
900
|
type DeletedCompany as DeletedCompany,
|
|
901
|
+
type CompanySearchResponse as CompanySearchResponse,
|
|
614
902
|
type CompaniesCursorPage as CompaniesCursorPage,
|
|
615
903
|
type CompanyRetrieveParams as CompanyRetrieveParams,
|
|
616
904
|
type CompanyListParams as CompanyListParams,
|
|
617
905
|
type CompanyDeleteParams as CompanyDeleteParams,
|
|
618
906
|
type CompanyCreateOrUpdateParams as CompanyCreateOrUpdateParams,
|
|
619
907
|
type CompanyDeleteByCompanyIDParams as CompanyDeleteByCompanyIDParams,
|
|
908
|
+
type CompanySearchParams as CompanySearchParams,
|
|
620
909
|
};
|
|
621
910
|
|
|
622
911
|
export {
|
|
@@ -4,11 +4,13 @@ export {
|
|
|
4
4
|
Companies,
|
|
5
5
|
type Company,
|
|
6
6
|
type DeletedCompany,
|
|
7
|
+
type CompanySearchResponse,
|
|
7
8
|
type CompanyRetrieveParams,
|
|
8
9
|
type CompanyListParams,
|
|
9
10
|
type CompanyDeleteParams,
|
|
10
11
|
type CompanyCreateOrUpdateParams,
|
|
11
12
|
type CompanyDeleteByCompanyIDParams,
|
|
13
|
+
type CompanySearchParams,
|
|
12
14
|
type CompaniesCursorPage,
|
|
13
15
|
} from './companies';
|
|
14
16
|
export {
|
|
@@ -438,6 +438,106 @@ export class Contacts extends APIResource {
|
|
|
438
438
|
});
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
+
/**
|
|
442
|
+
* Search contacts (customers and leads) with a structured filter AST, sorting, and
|
|
443
|
+
* cursor pagination.
|
|
444
|
+
*
|
|
445
|
+
* ### Structured query AST
|
|
446
|
+
*
|
|
447
|
+
* Each clause has the shape `{ field, operator, value }`. You can pass a single
|
|
448
|
+
* clause or wrap up to 15 in a top-level `AND` group:
|
|
449
|
+
*
|
|
450
|
+
* ```json
|
|
451
|
+
* {
|
|
452
|
+
* "query": {
|
|
453
|
+
* "operator": "AND",
|
|
454
|
+
* "value": [
|
|
455
|
+
* { "field": "type", "operator": "=", "value": "customer" },
|
|
456
|
+
* { "field": "last_activity", "operator": ">", "value": 1735689600 }
|
|
457
|
+
* ]
|
|
458
|
+
* },
|
|
459
|
+
* "sort": "last_activity:desc",
|
|
460
|
+
* "limit": 20
|
|
461
|
+
* }
|
|
462
|
+
* ```
|
|
463
|
+
*
|
|
464
|
+
* Top-level `OR` groups and nested groups are not supported in this version.
|
|
465
|
+
*
|
|
466
|
+
* ### Supported fields and operators
|
|
467
|
+
*
|
|
468
|
+
* | Field | Type | Operators |
|
|
469
|
+
* | ------------------ | -------------------------------- | --------------------------- |
|
|
470
|
+
* | `external_id` | string (caller-provided user id) | `=`, `!=`, `IN`, `NIN` |
|
|
471
|
+
* | `email` | string | `=`, `!=`, `IN`, `NIN` |
|
|
472
|
+
* | `name` | string | `=`, `!=`, `IN`, `NIN`, `~` |
|
|
473
|
+
* | `type` | enum (`customer`, `lead`) | `=`, `!=`, `IN`, `NIN` |
|
|
474
|
+
* | `company_ids` | id (Featurebase company `id`) | `=`, `!=`, `IN`, `NIN` |
|
|
475
|
+
* | `posts_created` | number | `=`, `!=`, `>`, `<` |
|
|
476
|
+
* | `comments_created` | number | `=`, `!=`, `>`, `<` |
|
|
477
|
+
* | `last_activity` | unix seconds | `=`, `!=`, `>`, `<` |
|
|
478
|
+
* | `created_at` | unix seconds | `=`, `!=`, `>`, `<` |
|
|
479
|
+
*
|
|
480
|
+
* The `name ~ "..."` operator runs a word-aware substring search via the
|
|
481
|
+
* underlying text index. Other string operators (`!~`, `^`, `$`) are reserved for
|
|
482
|
+
* future use and currently return `400`.
|
|
483
|
+
*
|
|
484
|
+
* A query consisting only of `!=` or `NIN` clauses on unbounded fields is rejected
|
|
485
|
+
* with `query_too_broad` to prevent full-org scans. Combine the negation with at
|
|
486
|
+
* least one positive clause (`=`, `IN`, `>`, `<`) instead. The closed-enum field
|
|
487
|
+
* `type` is exempt from this guard.
|
|
488
|
+
*
|
|
489
|
+
* Contacts that have been merged into another contact (lead-to-customer rollup)
|
|
490
|
+
* are always excluded from results.
|
|
491
|
+
*
|
|
492
|
+
* ### Sort
|
|
493
|
+
*
|
|
494
|
+
* Allowed values:
|
|
495
|
+
*
|
|
496
|
+
* - `last_activity:desc` (default), `last_activity:asc`
|
|
497
|
+
* - `created_at:desc`, `created_at:asc`
|
|
498
|
+
* - `posts_created:desc`, `posts_created:asc`
|
|
499
|
+
* - `comments_created:desc`, `comments_created:asc`
|
|
500
|
+
*
|
|
501
|
+
* The chosen sort axis is encoded in the cursor; switching `sort` mid-pagination
|
|
502
|
+
* returns `400 invalid_cursor`. Restart pagination without a cursor when changing
|
|
503
|
+
* sort.
|
|
504
|
+
*
|
|
505
|
+
* ### Pagination
|
|
506
|
+
*
|
|
507
|
+
* Cursor-based, `limit` between 1 and 100 (default 10). `totalCount` is
|
|
508
|
+
* approximate and capped at 5000; `totalCountCapped` is `true` when the real count
|
|
509
|
+
* may be higher.
|
|
510
|
+
*
|
|
511
|
+
* ### Response
|
|
512
|
+
*
|
|
513
|
+
* Returns a standard list envelope with contact rows identical to
|
|
514
|
+
* `GET /v2/contacts/{id}`.
|
|
515
|
+
*
|
|
516
|
+
* ### Version Availability
|
|
517
|
+
*
|
|
518
|
+
* This endpoint is only available in API version 2026-01-01.nova and newer.
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* ```ts
|
|
522
|
+
* const response = await client.users.contacts.search();
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
search(params: ContactSearchParams, options?: RequestOptions): APIPromise<ContactSearchResponse> {
|
|
526
|
+
const { 'Featurebase-Version': featurebaseVersion, ...body } = params;
|
|
527
|
+
return this._client.post('/v2/contacts/search', {
|
|
528
|
+
body,
|
|
529
|
+
...options,
|
|
530
|
+
headers: buildHeaders([
|
|
531
|
+
{
|
|
532
|
+
...(featurebaseVersion?.toString() != null ?
|
|
533
|
+
{ 'Featurebase-Version': featurebaseVersion?.toString() }
|
|
534
|
+
: undefined),
|
|
535
|
+
},
|
|
536
|
+
options?.headers,
|
|
537
|
+
]),
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
|
|
441
541
|
/**
|
|
442
542
|
* Unblocks a contact by their Featurebase ID from the messenger/inbox.
|
|
443
543
|
*
|
|
@@ -679,6 +779,134 @@ export interface ContactBlockResponse {
|
|
|
679
779
|
*/
|
|
680
780
|
export type ContactCreateOrUpdateResponse = Contact | (null & {});
|
|
681
781
|
|
|
782
|
+
export interface ContactSearchResponse {
|
|
783
|
+
/**
|
|
784
|
+
* Array of search results
|
|
785
|
+
*/
|
|
786
|
+
data: Array<ContactSearchResponse.Data>;
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Cursor for fetching the next page (null if no more results)
|
|
790
|
+
*/
|
|
791
|
+
nextCursor: string | null;
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Object type identifier
|
|
795
|
+
*/
|
|
796
|
+
object: 'list';
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Total number of contacts matching the query, capped at 5000. When the actual
|
|
800
|
+
* total is at or above the cap, `totalCountCapped` is true and the value is
|
|
801
|
+
* exactly the cap.
|
|
802
|
+
*/
|
|
803
|
+
totalCount?: number;
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* True when `totalCount` is exactly the cap and the real count may be higher.
|
|
807
|
+
*/
|
|
808
|
+
totalCountCapped?: boolean;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
export namespace ContactSearchResponse {
|
|
812
|
+
export interface Data {
|
|
813
|
+
/**
|
|
814
|
+
* Unique identifier
|
|
815
|
+
*/
|
|
816
|
+
id: string;
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Contact display name
|
|
820
|
+
*/
|
|
821
|
+
name: string;
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Object type identifier
|
|
825
|
+
*/
|
|
826
|
+
object: 'contact';
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Type of contact
|
|
830
|
+
*/
|
|
831
|
+
type: 'customer' | 'lead';
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Number of comments created
|
|
835
|
+
*/
|
|
836
|
+
commentsCreated?: number;
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Companies the contact belongs to
|
|
840
|
+
*/
|
|
841
|
+
companies?: Array<CompaniesAPI.Company>;
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Custom field values on the contact
|
|
845
|
+
*/
|
|
846
|
+
customFields?: { [key: string]: unknown };
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Contact description/bio
|
|
850
|
+
*/
|
|
851
|
+
description?: string;
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Contact email
|
|
855
|
+
*/
|
|
856
|
+
email?: string | null;
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Last activity ISO timestamp
|
|
860
|
+
*/
|
|
861
|
+
lastActivity?: string;
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Contact locale
|
|
865
|
+
*/
|
|
866
|
+
locale?: string;
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* Whether manually opted out from changelog
|
|
870
|
+
*/
|
|
871
|
+
manuallyOptedOutFromChangelog?: boolean;
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* Organization ID the contact belongs to
|
|
875
|
+
*/
|
|
876
|
+
organizationId?: string;
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Number of posts created
|
|
880
|
+
*/
|
|
881
|
+
postsCreated?: number;
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Profile picture URL
|
|
885
|
+
*/
|
|
886
|
+
profilePicture?: string | null;
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Contact roles
|
|
890
|
+
*/
|
|
891
|
+
roles?: Array<string>;
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* Whether subscribed to changelog
|
|
895
|
+
*/
|
|
896
|
+
subscribedToChangelog?: boolean;
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* External user ID from SSO
|
|
900
|
+
*/
|
|
901
|
+
userId?: string;
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Whether email is verified
|
|
905
|
+
*/
|
|
906
|
+
verified?: boolean;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
682
910
|
export interface ContactUnblockResponse {
|
|
683
911
|
/**
|
|
684
912
|
* Unique identifier of the unblocked contact
|
|
@@ -885,6 +1113,96 @@ export namespace ContactCreateOrUpdateParams {
|
|
|
885
1113
|
}
|
|
886
1114
|
}
|
|
887
1115
|
|
|
1116
|
+
export interface ContactSearchParams {
|
|
1117
|
+
/**
|
|
1118
|
+
* Body param: An opaque cursor for pagination. Use the `nextCursor` value from a
|
|
1119
|
+
* previous response to fetch the next page of results.
|
|
1120
|
+
*/
|
|
1121
|
+
cursor?: string;
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* Body param: A limit on the number of objects to be returned, between 1 and 100.
|
|
1125
|
+
*/
|
|
1126
|
+
limit?: number;
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Body param: Structured filter AST. Either a single filter clause or one
|
|
1130
|
+
* top-level AND group (max 15 clauses). Top-level OR groups are not yet supported.
|
|
1131
|
+
*/
|
|
1132
|
+
query?: ContactSearchParams.SearchFilter | ContactSearchParams.SearchFilterGroup;
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Body param: Sort field + direction. Defaults to `last_activity:desc` (matches
|
|
1136
|
+
* the dashboard's default contact ordering). The chosen sort axis is encoded in
|
|
1137
|
+
* the cursor; switching `sort` mid-pagination returns `400 invalid_cursor`.
|
|
1138
|
+
*/
|
|
1139
|
+
sort?:
|
|
1140
|
+
| 'created_at:desc'
|
|
1141
|
+
| 'created_at:asc'
|
|
1142
|
+
| 'last_activity:desc'
|
|
1143
|
+
| 'last_activity:asc'
|
|
1144
|
+
| 'posts_created:desc'
|
|
1145
|
+
| 'posts_created:asc'
|
|
1146
|
+
| 'comments_created:desc'
|
|
1147
|
+
| 'comments_created:asc';
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Header param: API version for this request. Defaults to your organization's
|
|
1151
|
+
* configured API version if not specified.
|
|
1152
|
+
*/
|
|
1153
|
+
'Featurebase-Version'?: '2026-01-01.nova' | '2025-12-12.clover';
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
export namespace ContactSearchParams {
|
|
1157
|
+
export interface SearchFilter {
|
|
1158
|
+
/**
|
|
1159
|
+
* Field name to filter on (e.g. `state`, `tag_ids`, `created_at`)
|
|
1160
|
+
*/
|
|
1161
|
+
field: string;
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* Comparison operator
|
|
1165
|
+
*/
|
|
1166
|
+
operator: '=' | '!=' | 'IN' | 'NIN' | '>' | '<' | '>=' | '<=' | '~' | '!~' | '^' | '$';
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Value to compare against (primitive or array of primitives)
|
|
1170
|
+
*/
|
|
1171
|
+
value: string | number | boolean | Array<string | number> | null;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
export interface SearchFilterGroup {
|
|
1175
|
+
/**
|
|
1176
|
+
* Group operator: AND (all match) or OR (any match)
|
|
1177
|
+
*/
|
|
1178
|
+
operator: 'AND' | 'OR';
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Array of filter clauses (1-15 entries)
|
|
1182
|
+
*/
|
|
1183
|
+
value: Array<SearchFilterGroup.Value>;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
export namespace SearchFilterGroup {
|
|
1187
|
+
export interface Value {
|
|
1188
|
+
/**
|
|
1189
|
+
* Field name to filter on (e.g. `state`, `tag_ids`, `created_at`)
|
|
1190
|
+
*/
|
|
1191
|
+
field: string;
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* Comparison operator
|
|
1195
|
+
*/
|
|
1196
|
+
operator: '=' | '!=' | 'IN' | 'NIN' | '>' | '<' | '>=' | '<=' | '~' | '!~' | '^' | '$';
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* Value to compare against (primitive or array of primitives)
|
|
1200
|
+
*/
|
|
1201
|
+
value: string | number | boolean | Array<string | number> | null;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
|
|
888
1206
|
export interface ContactUnblockParams {
|
|
889
1207
|
/**
|
|
890
1208
|
* API version for this request. Defaults to your organization's configured API
|
|
@@ -904,6 +1222,7 @@ export declare namespace Contacts {
|
|
|
904
1222
|
type ContactRetrieveResponse as ContactRetrieveResponse,
|
|
905
1223
|
type ContactBlockResponse as ContactBlockResponse,
|
|
906
1224
|
type ContactCreateOrUpdateResponse as ContactCreateOrUpdateResponse,
|
|
1225
|
+
type ContactSearchResponse as ContactSearchResponse,
|
|
907
1226
|
type ContactUnblockResponse as ContactUnblockResponse,
|
|
908
1227
|
type ContactListDataCursorPage as ContactListDataCursorPage,
|
|
909
1228
|
type ContactRetrieveParams as ContactRetrieveParams,
|
|
@@ -911,6 +1230,7 @@ export declare namespace Contacts {
|
|
|
911
1230
|
type ContactDeleteParams as ContactDeleteParams,
|
|
912
1231
|
type ContactBlockParams as ContactBlockParams,
|
|
913
1232
|
type ContactCreateOrUpdateParams as ContactCreateOrUpdateParams,
|
|
1233
|
+
type ContactSearchParams as ContactSearchParams,
|
|
914
1234
|
type ContactUnblockParams as ContactUnblockParams,
|
|
915
1235
|
};
|
|
916
1236
|
|
|
@@ -14,12 +14,14 @@ export {
|
|
|
14
14
|
type ContactRetrieveResponse,
|
|
15
15
|
type ContactBlockResponse,
|
|
16
16
|
type ContactCreateOrUpdateResponse,
|
|
17
|
+
type ContactSearchResponse,
|
|
17
18
|
type ContactUnblockResponse,
|
|
18
19
|
type ContactRetrieveParams,
|
|
19
20
|
type ContactListParams,
|
|
20
21
|
type ContactDeleteParams,
|
|
21
22
|
type ContactBlockParams,
|
|
22
23
|
type ContactCreateOrUpdateParams,
|
|
24
|
+
type ContactSearchParams,
|
|
23
25
|
type ContactUnblockParams,
|
|
24
26
|
type ContactListDataCursorPage,
|
|
25
27
|
} from './contacts';
|