unitpost 0.5.0 → 0.6.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/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- declare const SDK_VERSION = "0.5.0";
1
+ declare const SDK_VERSION = "0.6.0";
2
2
  interface ApiFieldError {
3
3
  /** Dotted path to the offending field, e.g. "template.variables.first_name". */
4
4
  field: string;
@@ -275,7 +275,7 @@ type BatchSendResult = {
275
275
  data: Array<{
276
276
  id: string;
277
277
  }>;
278
- /** Items that weren't sent, by their index in the request: one whose every `to` address is on a reserved domain (example.com, example.net, example.org), or one the sending engine couldn't take (retry just those). */
278
+ /** Items that weren't sent, by their index in the request: one whose every `to` address is on a reserved domain (example.com, example.net, example.org), one the sending engine couldn't take, or one the batch never reached (a batch sent with an `Idempotency-Key` stops starting items 5 minutes after its request began). Send just those again in a new request with a new `Idempotency-Key`: the original key replays this answer. */
279
279
  failed: Array<{
280
280
  index: number;
281
281
  error: string;
@@ -952,6 +952,7 @@ type ContactImport = {
952
952
  status: "pending" | "processing" | "completed" | "failed" | "canceled";
953
953
  total: number;
954
954
  imported: number;
955
+ updated: number;
955
956
  skipped: number;
956
957
  failed: number;
957
958
  invalid: Array<{
@@ -959,6 +960,7 @@ type ContactImport = {
959
960
  reason: string;
960
961
  }>;
961
962
  error: string | null;
963
+ update_existing: boolean;
962
964
  created_at: string;
963
965
  updated_at: string;
964
966
  };
@@ -968,9 +970,11 @@ type ContactImportCreate = {
968
970
  first_name?: string;
969
971
  last_name?: string;
970
972
  custom_fields?: Record<string, string | number | boolean | null>;
971
- /** Create this contact already unsubscribed (`true`, or a string `true`/`1`/`yes`/`y`). One-way: it never clears an opt-out, and an existing contact is skipped entirely. */
973
+ /** Create this contact already unsubscribed (`true`, or a string `true`/`1`/`yes`/`y`). Applies only to a contact the import creates: it never clears an opt-out, and an existing contact's subscription is left as it is, even with `update_existing`. */
972
974
  unsubscribed?: boolean | string;
973
975
  }>;
976
+ /** Update contacts that already exist instead of skipping them. A row whose email belongs to a contact sets the `first_name` and `last_name` it carries (a blank one is ignored) and merges its `custom_fields` key by key: keys the row leaves out keep their values. The contact's subscription is never changed (`unsubscribed` applies only to contacts the import creates). Counted in `updated`; a row that changes nothing is counted in `skipped`. Default `false`: existing contacts are skipped. */
977
+ update_existing?: boolean;
974
978
  };
975
979
  type ContactSegment = {
976
980
  object: "contact_segment";
@@ -982,6 +986,21 @@ type ContactSegment = {
982
986
  subscribed: boolean;
983
987
  unsubscribed_at: string | null;
984
988
  };
989
+ /** Set one custom field on many contacts: `key`, `value` and exactly one of `contact_ids`, `emails` or `segment_id`. */
990
+ type ContactSetField = {
991
+ /** The custom field's key (`plan`). It must exist: create it with POST /contact-fields first. */
992
+ key: string;
993
+ /** The value, typed against the field the way an import types it: a number field takes `42` or `"42"`, a boolean `true` / `"yes"`, a date an ISO 8601 date. `null` clears the field. */
994
+ value: string | number | boolean | null;
995
+ /** Default false: overwrite every value. True: set it only where the contact has no value of its own (the key is missing or null; a contact that shows the field's default has none). Not with `value: null`. */
996
+ only_empty?: boolean;
997
+ /** Contacts of this workspace (`con_…`), up to 1,000. */
998
+ contact_ids?: Array<string>;
999
+ /** Contacts of this workspace by email address, up to 1,000. */
1000
+ emails?: Array<string>;
1001
+ /** Every member of this segment (`seg_…`), however many. Also needs `segments:read`. */
1002
+ segment_id?: string;
1003
+ };
985
1004
  type ContactsExport = {
986
1005
  /** Free text: email, first and last name, and with 3+ digits the SMS number. */
987
1006
  q?: string;
@@ -1422,7 +1441,7 @@ type FileCreate = {
1422
1441
  purpose: "sms_opt_in_evidence" | "sms_document" | "image";
1423
1442
  /** A public https address to fetch the file from (no redirects, no private addresses, 12 seconds). One of `url`, `data`, or neither (an upload session). */
1424
1443
  url?: string;
1425
- /** The bytes, base64 (no `data:` prefix), with `content_type`. A request over ~6 MB is refused before it arrives, so this fits about 4 MB; agents should prefer `url` or an upload session for anything but small files. */
1444
+ /** The bytes, base64 (no `data:` prefix), with `content_type`. Base64 grows bytes by a third, and a request body may be up to 30 MB. A `url` or an upload session carries no bytes in the request. */
1426
1445
  data?: string;
1427
1446
  /** Required with `data` and for an upload session (it is signed into the PUT); refused with `url`. */
1428
1447
  content_type?: "image/png" | "application/pdf" | "image/jpeg" | "image/gif" | "image/webp";
@@ -1434,7 +1453,7 @@ type FileCreate = {
1434
1453
  type ImageUpload = {
1435
1454
  /** A public https image to fetch (no redirects, no private addresses). PNG, JPEG, GIF or WebP, up to 5 MB and 16,384 px a side (50 megapixels at most); anything else is a 422 naming `url`. */
1436
1455
  url?: string;
1437
- /** The image bytes, base64 (no `data:` prefix). Base64 adds a third, and a request over ~6 MB is refused before it arrives, so this fits about 4 MB of image; send larger images (up to 5 MB) by `url`. At most 16,384 px a side and 50 megapixels; anything else is a 422 naming `data`. */
1456
+ /** The image bytes, base64 (no `data:` prefix), up to 5 MB of image. Base64 grows bytes by a third, and a request body may be up to 30 MB. At most 16,384 px a side and 50 megapixels; anything else is a 422 naming `data`. */
1438
1457
  data?: string;
1439
1458
  /** A file made with `POST /files` and purpose `image` (`file_…`): how an agent hands over a local image without base64 (an upload session), or an image up to 5 MB. Checked by its bytes when it was made, and again here. */
1440
1459
  file_id?: string;
@@ -1484,7 +1503,7 @@ type LibraryImage = {
1484
1503
  type LibraryImageCreate = {
1485
1504
  /** A public https image to fetch (no redirects, no private addresses). PNG, JPEG, GIF or WebP, up to 5 MB and 16,384 px a side (50 megapixels at most); anything else is a 422 naming `url`. */
1486
1505
  url?: string;
1487
- /** The image bytes, base64 (no `data:` prefix). Base64 adds a third, and a request over ~6 MB is refused before it arrives, so this fits about 4 MB of image; send larger images (up to 5 MB) by `url`. At most 16,384 px a side and 50 megapixels; anything else is a 422 naming `data`. */
1506
+ /** The image bytes, base64 (no `data:` prefix), up to 5 MB of image. Base64 grows bytes by a third, and a request body may be up to 30 MB. At most 16,384 px a side and 50 megapixels; anything else is a 422 naming `data`. */
1488
1507
  data?: string;
1489
1508
  /** A file made with `POST /files` and purpose `image` (`file_…`): how an agent hands over a local image without base64 (an upload session), or an image up to 5 MB. Checked by its bytes when it was made, and again here. */
1490
1509
  file_id?: string;
@@ -1854,10 +1873,46 @@ type SegmentMember = {
1854
1873
  subscribed: boolean;
1855
1874
  unsubscribed_at: string | null;
1856
1875
  };
1876
+ /** Add one contact. */
1857
1877
  type SegmentMemberAdd = {
1878
+ /** The contact: its id (`con_…`) or email. */
1858
1879
  contact: string;
1880
+ /** The new member's per-segment subscription (default true). A contact that is already a member keeps its own. */
1859
1881
  subscribed?: boolean;
1860
1882
  };
1883
+ /** Who to add: exactly one of `contact`, `contact_ids` or `emails`. */
1884
+ type SegmentMemberAddBody = {
1885
+ /** One contact: its id (`con_…`) or email. */
1886
+ contact?: string;
1887
+ /** Many contacts of this workspace by id (`con_…`), up to 1,000. */
1888
+ contact_ids?: Array<string>;
1889
+ /** Many contacts of this workspace by email address, up to 1,000. */
1890
+ emails?: Array<string>;
1891
+ /** A new member's per-segment subscription (default true). A contact that is already a member keeps its own. */
1892
+ subscribed?: boolean;
1893
+ };
1894
+ /** Add many contacts: exactly one of `contact_ids` or `emails`. */
1895
+ type SegmentMembersAdd = {
1896
+ /** Many contacts of this workspace by id (`con_…`), up to 1,000. */
1897
+ contact_ids?: Array<string>;
1898
+ /** Many contacts of this workspace by email address, up to 1,000. */
1899
+ emails?: Array<string>;
1900
+ /** New members' per-segment subscription (default true). A contact that is already a member keeps its own. */
1901
+ subscribed?: boolean;
1902
+ };
1903
+ type SegmentMembersAdded = {
1904
+ object: "list";
1905
+ /** Each listed contact's membership, in the order sent (a contact listed twice appears once). */
1906
+ data: Array<{
1907
+ object: "segment_member";
1908
+ contact_id: string;
1909
+ subscribed: boolean;
1910
+ unsubscribed_at: string | null;
1911
+ }>;
1912
+ has_more: false;
1913
+ /** How many of them this call added; the others were already members and kept their state. */
1914
+ added: number;
1915
+ };
1861
1916
  type SegmentMemberUpdate = {
1862
1917
  /** `false` opts the contact out of this segment's sends without removing it; `true` opts it back in. */
1863
1918
  subscribed: boolean;
@@ -3456,6 +3511,7 @@ type models_ContactFieldUpdate = ContactFieldUpdate;
3456
3511
  type models_ContactImport = ContactImport;
3457
3512
  type models_ContactImportCreate = ContactImportCreate;
3458
3513
  type models_ContactSegment = ContactSegment;
3514
+ type models_ContactSetField = ContactSetField;
3459
3515
  type models_ContactTopic = ContactTopic;
3460
3516
  type models_ContactTopicList = ContactTopicList;
3461
3517
  type models_ContactTopicSet = ContactTopicSet;
@@ -3505,7 +3561,10 @@ type models_Segment = Segment;
3505
3561
  type models_SegmentCreate = SegmentCreate;
3506
3562
  type models_SegmentMember = SegmentMember;
3507
3563
  type models_SegmentMemberAdd = SegmentMemberAdd;
3564
+ type models_SegmentMemberAddBody = SegmentMemberAddBody;
3508
3565
  type models_SegmentMemberUpdate = SegmentMemberUpdate;
3566
+ type models_SegmentMembersAdd = SegmentMembersAdd;
3567
+ type models_SegmentMembersAdded = SegmentMembersAdded;
3509
3568
  type models_SegmentPreview = SegmentPreview;
3510
3569
  type models_SegmentPreviewRequest = SegmentPreviewRequest;
3511
3570
  type models_SegmentUpdate = SegmentUpdate;
@@ -3599,7 +3658,7 @@ type models_Whoami = Whoami;
3599
3658
  type models_WorkspaceKeyMint = WorkspaceKeyMint;
3600
3659
  type models_WorkspaceUpdate = WorkspaceUpdate;
3601
3660
  declare namespace models {
3602
- export type { models_Activity as Activity, models_ApiKey as ApiKey, models_ApiKeyCreate as ApiKeyCreate, models_ApiKeyCreated as ApiKeyCreated, models_ApiKeyUsage as ApiKeyUsage, models_Batch as Batch, models_BatchSend as BatchSend, models_BatchSendResult as BatchSendResult, models_BrandImport as BrandImport, models_BrandImportAccept as BrandImportAccept, models_BrandImportAccepted as BrandImportAccepted, models_BrandImportCreate as BrandImportCreate, models_BrandKit as BrandKit, models_BrandKitCreate as BrandKitCreate, models_BrandKitGraphicAdd as BrandKitGraphicAdd, models_BrandKitGraphicAdded as BrandKitGraphicAdded, models_BrandKitList as BrandKitList, models_BrandKitUpdate as BrandKitUpdate, Branding$1 as Branding, models_BrandingUpdate as BrandingUpdate, models_Campaign as Campaign, models_CampaignAffectedRecipient as CampaignAffectedRecipient, models_CampaignCreate as CampaignCreate, models_CampaignDuplicate as CampaignDuplicate, models_CampaignQualityRemoval as CampaignQualityRemoval, models_CampaignRecipient as CampaignRecipient, models_CampaignReschedule as CampaignReschedule, models_CampaignReviewRequest as CampaignReviewRequest, models_CampaignSend as CampaignSend, models_CampaignStats as CampaignStats, models_CampaignUpdate as CampaignUpdate, models_Contact as Contact, models_ContactActivity as ContactActivity, models_ContactAddress as ContactAddress, models_ContactCreate as ContactCreate, models_ContactField as ContactField, models_ContactFieldCreate as ContactFieldCreate, models_ContactFieldRename as ContactFieldRename, models_ContactFieldUpdate as ContactFieldUpdate, models_ContactImport as ContactImport, models_ContactImportCreate as ContactImportCreate, models_ContactSegment as ContactSegment, models_ContactTopic as ContactTopic, models_ContactTopicList as ContactTopicList, models_ContactTopicSet as ContactTopicSet, models_ContactTopicsUpdate as ContactTopicsUpdate, models_ContactUpdate as ContactUpdate, models_ContactsExport as ContactsExport, models_Domain as Domain, models_DomainCreate as DomainCreate, models_DomainDiagnosis as DomainDiagnosis, models_DomainUpdate as DomainUpdate, Email$1 as Email, models_EmailEvent as EmailEvent, models_EmailPatch as EmailPatch, models_EmailStats as EmailStats, models_EmailThread as EmailThread, models_EmailThreadDeleted as EmailThreadDeleted, models_EmailThreadDetail as EmailThreadDetail, models_EmailThreadReplyRequest as EmailThreadReplyRequest, models_EmailThreadReplyResult as EmailThreadReplyResult, Error$1 as Error, models_File as File, models_FileCreate as FileCreate, models_ImageUpload as ImageUpload, models_Job as Job, models_JobDownload as JobDownload, models_LibraryImage as LibraryImage, models_LibraryImageCreate as LibraryImageCreate, models_LibraryImageUpdate as LibraryImageUpdate, models_MintedWorkspaceKey as MintedWorkspaceKey, models_OrganizationPlanQuote as OrganizationPlanQuote, models_OrganizationPlanQuoteConfirm as OrganizationPlanQuoteConfirm, models_OrganizationPlanQuoteCreate as OrganizationPlanQuoteCreate, models_OrganizationPlanStop as OrganizationPlanStop, OrganizationSharedPlan$1 as OrganizationSharedPlan, models_OrganizationSharedPlanRemoval as OrganizationSharedPlanRemoval, models_OrganizationSharedPlanWorkspace as OrganizationSharedPlanWorkspace, models_OrganizationSharedPlanWorkspaceAdd as OrganizationSharedPlanWorkspaceAdd, models_OrganizationSharedPlanWorkspaceUpdate as OrganizationSharedPlanWorkspaceUpdate, models_OrganizationWebhookDelivery as OrganizationWebhookDelivery, models_OrganizationWorkspace as OrganizationWorkspace, models_OrganizationWorkspaceCreate as OrganizationWorkspaceCreate, models_OrganizationWorkspaceUpdate as OrganizationWorkspaceUpdate, models_OrganizationWorkspaceUsage as OrganizationWorkspaceUsage, models_ReceivedAttachmentUrl as ReceivedAttachmentUrl, models_ReceivedEmail as ReceivedEmail, models_ReceivedEmailRaw as ReceivedEmailRaw, models_ReceivedEmailSummary as ReceivedEmailSummary, models_RequestLog as RequestLog, models_Segment as Segment, models_SegmentCreate as SegmentCreate, models_SegmentMember as SegmentMember, models_SegmentMemberAdd as SegmentMemberAdd, models_SegmentMemberUpdate as SegmentMemberUpdate, models_SegmentPreview as SegmentPreview, models_SegmentPreviewRequest as SegmentPreviewRequest, models_SegmentUpdate as SegmentUpdate, models_SendEmail as SendEmail, models_SendResult as SendResult, models_Sender as Sender, models_SenderCreate as SenderCreate, models_SenderUpdate as SenderUpdate, Sms$1 as Sms, models_SmsAddContact as SmsAddContact, models_SmsBillableResource as SmsBillableResource, models_SmsBrand as SmsBrand, models_SmsBrandCreate as SmsBrandCreate, models_SmsBrandDocument as SmsBrandDocument, models_SmsBrandDocumentCreate as SmsBrandDocumentCreate, models_SmsBrandDocumentDeleted as SmsBrandDocumentDeleted, models_SmsBrandDocumentUrl as SmsBrandDocumentUrl, models_SmsBrandPatch as SmsBrandPatch, models_SmsCampaign as SmsCampaign, models_SmsCampaignCreate as SmsCampaignCreate, models_SmsCampaignRecipient as SmsCampaignRecipient, models_SmsCampaignReschedule as SmsCampaignReschedule, models_SmsCampaignResubmit as SmsCampaignResubmit, models_SmsCampaignSend as SmsCampaignSend, models_SmsCampaignUpdate as SmsCampaignUpdate, models_SmsCampaignValidation as SmsCampaignValidation, models_SmsConsent as SmsConsent, models_SmsConsentRecord as SmsConsentRecord, models_SmsConsentRecorded as SmsConsentRecorded, models_SmsConsentSetup as SmsConsentSetup, models_SmsJoinKeyword as SmsJoinKeyword, models_SmsJoinKeywordCreate as SmsJoinKeywordCreate, models_SmsJoinKeywordCreated as SmsJoinKeywordCreated, models_SmsJoinKeywordList as SmsJoinKeywordList, models_SmsMessagingProgram as SmsMessagingProgram, models_SmsMessagingProgramCreate as SmsMessagingProgramCreate, models_SmsMessagingProgramUpdate as SmsMessagingProgramUpdate, models_SmsNumber as SmsNumber, models_SmsNumberRelease as SmsNumberRelease, models_SmsNumberRequest as SmsNumberRequest, models_SmsNumberResubmission as SmsNumberResubmission, models_SmsNumberRetry as SmsNumberRetry, models_SmsOptInRequest as SmsOptInRequest, models_SmsPatch as SmsPatch, models_SmsQuote as SmsQuote, models_SmsQuoteConfirm as SmsQuoteConfirm, models_SmsQuoteCreate as SmsQuoteCreate, models_SmsRegistration as SmsRegistration, models_SmsRegistrationRemove as SmsRegistrationRemove, models_SmsRegistrationReplace as SmsRegistrationReplace, models_SmsRegistrationResubmission as SmsRegistrationResubmission, models_SmsSend as SmsSend, models_SmsStats as SmsStats, models_SmsTemplate as SmsTemplate, models_SmsTemplateCreate as SmsTemplateCreate, models_SmsTemplateTestSend as SmsTemplateTestSend, models_SmsTemplateTestSendResult as SmsTemplateTestSendResult, models_SmsTemplateUpdate as SmsTemplateUpdate, models_SmsTemplateUsage as SmsTemplateUsage, models_SmsTestDestination as SmsTestDestination, models_SmsTollFreeResubmit as SmsTollFreeResubmit, SpendCaps$1 as SpendCaps, models_SpendCapsUpdate as SpendCapsUpdate, models_Suppression as Suppression, models_SuppressionBulkResult as SuppressionBulkResult, models_SuppressionCreate as SuppressionCreate, models_Template as Template, models_TemplateCreate as TemplateCreate, models_TemplateDuplicate as TemplateDuplicate, models_TemplateFromLibrary as TemplateFromLibrary, models_TemplateRender as TemplateRender, models_TemplateRenderInput as TemplateRenderInput, models_TemplateTestSend as TemplateTestSend, models_TemplateTestSendResult as TemplateTestSendResult, models_TemplateUpdate as TemplateUpdate, models_TemplateUsage as TemplateUsage, models_TemplateVersion as TemplateVersion, models_Topic as Topic, models_TopicCreate as TopicCreate, models_TopicOptOut as TopicOptOut, models_TopicUpdate as TopicUpdate, Usage$1 as Usage, models_Webhook as Webhook, models_WebhookCreate as WebhookCreate, models_WebhookCreated as WebhookCreated, models_WebhookDelivery as WebhookDelivery, models_WebhookDeliveryReplay as WebhookDeliveryReplay, models_WebhookFlush as WebhookFlush, models_WebhookFlushResult as WebhookFlushResult, models_WebhookSecretRotated as WebhookSecretRotated, models_WebhookTestResult as WebhookTestResult, models_WebhookUpdate as WebhookUpdate, models_Whoami as Whoami, Workspace$1 as Workspace, models_WorkspaceKeyMint as WorkspaceKeyMint, models_WorkspaceUpdate as WorkspaceUpdate };
3661
+ export type { models_Activity as Activity, models_ApiKey as ApiKey, models_ApiKeyCreate as ApiKeyCreate, models_ApiKeyCreated as ApiKeyCreated, models_ApiKeyUsage as ApiKeyUsage, models_Batch as Batch, models_BatchSend as BatchSend, models_BatchSendResult as BatchSendResult, models_BrandImport as BrandImport, models_BrandImportAccept as BrandImportAccept, models_BrandImportAccepted as BrandImportAccepted, models_BrandImportCreate as BrandImportCreate, models_BrandKit as BrandKit, models_BrandKitCreate as BrandKitCreate, models_BrandKitGraphicAdd as BrandKitGraphicAdd, models_BrandKitGraphicAdded as BrandKitGraphicAdded, models_BrandKitList as BrandKitList, models_BrandKitUpdate as BrandKitUpdate, Branding$1 as Branding, models_BrandingUpdate as BrandingUpdate, models_Campaign as Campaign, models_CampaignAffectedRecipient as CampaignAffectedRecipient, models_CampaignCreate as CampaignCreate, models_CampaignDuplicate as CampaignDuplicate, models_CampaignQualityRemoval as CampaignQualityRemoval, models_CampaignRecipient as CampaignRecipient, models_CampaignReschedule as CampaignReschedule, models_CampaignReviewRequest as CampaignReviewRequest, models_CampaignSend as CampaignSend, models_CampaignStats as CampaignStats, models_CampaignUpdate as CampaignUpdate, models_Contact as Contact, models_ContactActivity as ContactActivity, models_ContactAddress as ContactAddress, models_ContactCreate as ContactCreate, models_ContactField as ContactField, models_ContactFieldCreate as ContactFieldCreate, models_ContactFieldRename as ContactFieldRename, models_ContactFieldUpdate as ContactFieldUpdate, models_ContactImport as ContactImport, models_ContactImportCreate as ContactImportCreate, models_ContactSegment as ContactSegment, models_ContactSetField as ContactSetField, models_ContactTopic as ContactTopic, models_ContactTopicList as ContactTopicList, models_ContactTopicSet as ContactTopicSet, models_ContactTopicsUpdate as ContactTopicsUpdate, models_ContactUpdate as ContactUpdate, models_ContactsExport as ContactsExport, models_Domain as Domain, models_DomainCreate as DomainCreate, models_DomainDiagnosis as DomainDiagnosis, models_DomainUpdate as DomainUpdate, Email$1 as Email, models_EmailEvent as EmailEvent, models_EmailPatch as EmailPatch, models_EmailStats as EmailStats, models_EmailThread as EmailThread, models_EmailThreadDeleted as EmailThreadDeleted, models_EmailThreadDetail as EmailThreadDetail, models_EmailThreadReplyRequest as EmailThreadReplyRequest, models_EmailThreadReplyResult as EmailThreadReplyResult, Error$1 as Error, models_File as File, models_FileCreate as FileCreate, models_ImageUpload as ImageUpload, models_Job as Job, models_JobDownload as JobDownload, models_LibraryImage as LibraryImage, models_LibraryImageCreate as LibraryImageCreate, models_LibraryImageUpdate as LibraryImageUpdate, models_MintedWorkspaceKey as MintedWorkspaceKey, models_OrganizationPlanQuote as OrganizationPlanQuote, models_OrganizationPlanQuoteConfirm as OrganizationPlanQuoteConfirm, models_OrganizationPlanQuoteCreate as OrganizationPlanQuoteCreate, models_OrganizationPlanStop as OrganizationPlanStop, OrganizationSharedPlan$1 as OrganizationSharedPlan, models_OrganizationSharedPlanRemoval as OrganizationSharedPlanRemoval, models_OrganizationSharedPlanWorkspace as OrganizationSharedPlanWorkspace, models_OrganizationSharedPlanWorkspaceAdd as OrganizationSharedPlanWorkspaceAdd, models_OrganizationSharedPlanWorkspaceUpdate as OrganizationSharedPlanWorkspaceUpdate, models_OrganizationWebhookDelivery as OrganizationWebhookDelivery, models_OrganizationWorkspace as OrganizationWorkspace, models_OrganizationWorkspaceCreate as OrganizationWorkspaceCreate, models_OrganizationWorkspaceUpdate as OrganizationWorkspaceUpdate, models_OrganizationWorkspaceUsage as OrganizationWorkspaceUsage, models_ReceivedAttachmentUrl as ReceivedAttachmentUrl, models_ReceivedEmail as ReceivedEmail, models_ReceivedEmailRaw as ReceivedEmailRaw, models_ReceivedEmailSummary as ReceivedEmailSummary, models_RequestLog as RequestLog, models_Segment as Segment, models_SegmentCreate as SegmentCreate, models_SegmentMember as SegmentMember, models_SegmentMemberAdd as SegmentMemberAdd, models_SegmentMemberAddBody as SegmentMemberAddBody, models_SegmentMemberUpdate as SegmentMemberUpdate, models_SegmentMembersAdd as SegmentMembersAdd, models_SegmentMembersAdded as SegmentMembersAdded, models_SegmentPreview as SegmentPreview, models_SegmentPreviewRequest as SegmentPreviewRequest, models_SegmentUpdate as SegmentUpdate, models_SendEmail as SendEmail, models_SendResult as SendResult, models_Sender as Sender, models_SenderCreate as SenderCreate, models_SenderUpdate as SenderUpdate, Sms$1 as Sms, models_SmsAddContact as SmsAddContact, models_SmsBillableResource as SmsBillableResource, models_SmsBrand as SmsBrand, models_SmsBrandCreate as SmsBrandCreate, models_SmsBrandDocument as SmsBrandDocument, models_SmsBrandDocumentCreate as SmsBrandDocumentCreate, models_SmsBrandDocumentDeleted as SmsBrandDocumentDeleted, models_SmsBrandDocumentUrl as SmsBrandDocumentUrl, models_SmsBrandPatch as SmsBrandPatch, models_SmsCampaign as SmsCampaign, models_SmsCampaignCreate as SmsCampaignCreate, models_SmsCampaignRecipient as SmsCampaignRecipient, models_SmsCampaignReschedule as SmsCampaignReschedule, models_SmsCampaignResubmit as SmsCampaignResubmit, models_SmsCampaignSend as SmsCampaignSend, models_SmsCampaignUpdate as SmsCampaignUpdate, models_SmsCampaignValidation as SmsCampaignValidation, models_SmsConsent as SmsConsent, models_SmsConsentRecord as SmsConsentRecord, models_SmsConsentRecorded as SmsConsentRecorded, models_SmsConsentSetup as SmsConsentSetup, models_SmsJoinKeyword as SmsJoinKeyword, models_SmsJoinKeywordCreate as SmsJoinKeywordCreate, models_SmsJoinKeywordCreated as SmsJoinKeywordCreated, models_SmsJoinKeywordList as SmsJoinKeywordList, models_SmsMessagingProgram as SmsMessagingProgram, models_SmsMessagingProgramCreate as SmsMessagingProgramCreate, models_SmsMessagingProgramUpdate as SmsMessagingProgramUpdate, models_SmsNumber as SmsNumber, models_SmsNumberRelease as SmsNumberRelease, models_SmsNumberRequest as SmsNumberRequest, models_SmsNumberResubmission as SmsNumberResubmission, models_SmsNumberRetry as SmsNumberRetry, models_SmsOptInRequest as SmsOptInRequest, models_SmsPatch as SmsPatch, models_SmsQuote as SmsQuote, models_SmsQuoteConfirm as SmsQuoteConfirm, models_SmsQuoteCreate as SmsQuoteCreate, models_SmsRegistration as SmsRegistration, models_SmsRegistrationRemove as SmsRegistrationRemove, models_SmsRegistrationReplace as SmsRegistrationReplace, models_SmsRegistrationResubmission as SmsRegistrationResubmission, models_SmsSend as SmsSend, models_SmsStats as SmsStats, models_SmsTemplate as SmsTemplate, models_SmsTemplateCreate as SmsTemplateCreate, models_SmsTemplateTestSend as SmsTemplateTestSend, models_SmsTemplateTestSendResult as SmsTemplateTestSendResult, models_SmsTemplateUpdate as SmsTemplateUpdate, models_SmsTemplateUsage as SmsTemplateUsage, models_SmsTestDestination as SmsTestDestination, models_SmsTollFreeResubmit as SmsTollFreeResubmit, SpendCaps$1 as SpendCaps, models_SpendCapsUpdate as SpendCapsUpdate, models_Suppression as Suppression, models_SuppressionBulkResult as SuppressionBulkResult, models_SuppressionCreate as SuppressionCreate, models_Template as Template, models_TemplateCreate as TemplateCreate, models_TemplateDuplicate as TemplateDuplicate, models_TemplateFromLibrary as TemplateFromLibrary, models_TemplateRender as TemplateRender, models_TemplateRenderInput as TemplateRenderInput, models_TemplateTestSend as TemplateTestSend, models_TemplateTestSendResult as TemplateTestSendResult, models_TemplateUpdate as TemplateUpdate, models_TemplateUsage as TemplateUsage, models_TemplateVersion as TemplateVersion, models_Topic as Topic, models_TopicCreate as TopicCreate, models_TopicOptOut as TopicOptOut, models_TopicUpdate as TopicUpdate, Usage$1 as Usage, models_Webhook as Webhook, models_WebhookCreate as WebhookCreate, models_WebhookCreated as WebhookCreated, models_WebhookDelivery as WebhookDelivery, models_WebhookDeliveryReplay as WebhookDeliveryReplay, models_WebhookFlush as WebhookFlush, models_WebhookFlushResult as WebhookFlushResult, models_WebhookSecretRotated as WebhookSecretRotated, models_WebhookTestResult as WebhookTestResult, models_WebhookUpdate as WebhookUpdate, models_Whoami as Whoami, Workspace$1 as Workspace, models_WorkspaceKeyMint as WorkspaceKeyMint, models_WorkspaceUpdate as WorkspaceUpdate };
3603
3662
  }
3604
3663
 
3605
3664
  /**
@@ -4383,6 +4442,18 @@ declare class Contacts extends Resource {
4383
4442
  * runs is a `409` `job_in_progress`. `segment_id` also needs `segments:read`.
4384
4443
  */
4385
4444
  export(body?: ContactsExport): Result<Job>;
4445
+ /**
4446
+ * Set one custom field to the same value on many contacts, as the Contacts
4447
+ * page's Set field does, as a background job (202, the `Job`): `key`,
4448
+ * `value` (typed against the field; `null` clears it), optional
4449
+ * `only_empty`, and exactly one of `contact_ids` or `emails` (up to 1,000,
4450
+ * each a contact of this workspace) or `segment_id` (every member, however
4451
+ * many; also needs `segments:read`). Each contact whose value changes gets
4452
+ * `contact.updated`; consent is never touched. Follow it with
4453
+ * `jobs.get(id)`. Pass an `idempotencyKey` so a retry answers the same job;
4454
+ * one is generated when you don't.
4455
+ */
4456
+ setField(body: ContactSetField, opts?: SendOptions): Result<Job>;
4386
4457
  }
4387
4458
  declare class ContactFields extends Resource {
4388
4459
  list(params?: ListParams): Result<ListResponse<ContactField>>;
@@ -4446,8 +4517,20 @@ declare class Segments extends Resource {
4446
4517
  update(id: string, body: SegmentUpdate): Result<Segment>;
4447
4518
  delete(id: string): Result<null>;
4448
4519
  listMembers(id: string, params?: ListParams): Result<ListResponse<SegmentMember>>;
4449
- /** Add a contact (by id or email) to the segment. Idempotent. */
4520
+ /**
4521
+ * Add a contact (by id or email, `{ contact }`) to the segment, which
4522
+ * answers its membership; or many at once (`{ contact_ids }` or
4523
+ * `{ emails }`, up to 1,000, all checked first), which answers each listed
4524
+ * contact's membership and `added`. Idempotent: an existing member keeps
4525
+ * its state.
4526
+ */
4527
+ addMember(id: string, body: SegmentMembersAdd & ({
4528
+ contact_ids: string[];
4529
+ } | {
4530
+ emails: string[];
4531
+ })): Result<SegmentMembersAdded>;
4450
4532
  addMember(id: string, body: SegmentMemberAdd): Result<SegmentMember>;
4533
+ addMember(id: string, body: SegmentMemberAddBody): Result<SegmentMember | SegmentMembersAdded>;
4451
4534
  /** Remove a contact (by id or email) from the segment. */
4452
4535
  removeMember(id: string, contact: string): Result<null>;
4453
4536
  /**
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const SDK_VERSION = "0.5.0";
1
+ declare const SDK_VERSION = "0.6.0";
2
2
  interface ApiFieldError {
3
3
  /** Dotted path to the offending field, e.g. "template.variables.first_name". */
4
4
  field: string;
@@ -275,7 +275,7 @@ type BatchSendResult = {
275
275
  data: Array<{
276
276
  id: string;
277
277
  }>;
278
- /** Items that weren't sent, by their index in the request: one whose every `to` address is on a reserved domain (example.com, example.net, example.org), or one the sending engine couldn't take (retry just those). */
278
+ /** Items that weren't sent, by their index in the request: one whose every `to` address is on a reserved domain (example.com, example.net, example.org), one the sending engine couldn't take, or one the batch never reached (a batch sent with an `Idempotency-Key` stops starting items 5 minutes after its request began). Send just those again in a new request with a new `Idempotency-Key`: the original key replays this answer. */
279
279
  failed: Array<{
280
280
  index: number;
281
281
  error: string;
@@ -952,6 +952,7 @@ type ContactImport = {
952
952
  status: "pending" | "processing" | "completed" | "failed" | "canceled";
953
953
  total: number;
954
954
  imported: number;
955
+ updated: number;
955
956
  skipped: number;
956
957
  failed: number;
957
958
  invalid: Array<{
@@ -959,6 +960,7 @@ type ContactImport = {
959
960
  reason: string;
960
961
  }>;
961
962
  error: string | null;
963
+ update_existing: boolean;
962
964
  created_at: string;
963
965
  updated_at: string;
964
966
  };
@@ -968,9 +970,11 @@ type ContactImportCreate = {
968
970
  first_name?: string;
969
971
  last_name?: string;
970
972
  custom_fields?: Record<string, string | number | boolean | null>;
971
- /** Create this contact already unsubscribed (`true`, or a string `true`/`1`/`yes`/`y`). One-way: it never clears an opt-out, and an existing contact is skipped entirely. */
973
+ /** Create this contact already unsubscribed (`true`, or a string `true`/`1`/`yes`/`y`). Applies only to a contact the import creates: it never clears an opt-out, and an existing contact's subscription is left as it is, even with `update_existing`. */
972
974
  unsubscribed?: boolean | string;
973
975
  }>;
976
+ /** Update contacts that already exist instead of skipping them. A row whose email belongs to a contact sets the `first_name` and `last_name` it carries (a blank one is ignored) and merges its `custom_fields` key by key: keys the row leaves out keep their values. The contact's subscription is never changed (`unsubscribed` applies only to contacts the import creates). Counted in `updated`; a row that changes nothing is counted in `skipped`. Default `false`: existing contacts are skipped. */
977
+ update_existing?: boolean;
974
978
  };
975
979
  type ContactSegment = {
976
980
  object: "contact_segment";
@@ -982,6 +986,21 @@ type ContactSegment = {
982
986
  subscribed: boolean;
983
987
  unsubscribed_at: string | null;
984
988
  };
989
+ /** Set one custom field on many contacts: `key`, `value` and exactly one of `contact_ids`, `emails` or `segment_id`. */
990
+ type ContactSetField = {
991
+ /** The custom field's key (`plan`). It must exist: create it with POST /contact-fields first. */
992
+ key: string;
993
+ /** The value, typed against the field the way an import types it: a number field takes `42` or `"42"`, a boolean `true` / `"yes"`, a date an ISO 8601 date. `null` clears the field. */
994
+ value: string | number | boolean | null;
995
+ /** Default false: overwrite every value. True: set it only where the contact has no value of its own (the key is missing or null; a contact that shows the field's default has none). Not with `value: null`. */
996
+ only_empty?: boolean;
997
+ /** Contacts of this workspace (`con_…`), up to 1,000. */
998
+ contact_ids?: Array<string>;
999
+ /** Contacts of this workspace by email address, up to 1,000. */
1000
+ emails?: Array<string>;
1001
+ /** Every member of this segment (`seg_…`), however many. Also needs `segments:read`. */
1002
+ segment_id?: string;
1003
+ };
985
1004
  type ContactsExport = {
986
1005
  /** Free text: email, first and last name, and with 3+ digits the SMS number. */
987
1006
  q?: string;
@@ -1422,7 +1441,7 @@ type FileCreate = {
1422
1441
  purpose: "sms_opt_in_evidence" | "sms_document" | "image";
1423
1442
  /** A public https address to fetch the file from (no redirects, no private addresses, 12 seconds). One of `url`, `data`, or neither (an upload session). */
1424
1443
  url?: string;
1425
- /** The bytes, base64 (no `data:` prefix), with `content_type`. A request over ~6 MB is refused before it arrives, so this fits about 4 MB; agents should prefer `url` or an upload session for anything but small files. */
1444
+ /** The bytes, base64 (no `data:` prefix), with `content_type`. Base64 grows bytes by a third, and a request body may be up to 30 MB. A `url` or an upload session carries no bytes in the request. */
1426
1445
  data?: string;
1427
1446
  /** Required with `data` and for an upload session (it is signed into the PUT); refused with `url`. */
1428
1447
  content_type?: "image/png" | "application/pdf" | "image/jpeg" | "image/gif" | "image/webp";
@@ -1434,7 +1453,7 @@ type FileCreate = {
1434
1453
  type ImageUpload = {
1435
1454
  /** A public https image to fetch (no redirects, no private addresses). PNG, JPEG, GIF or WebP, up to 5 MB and 16,384 px a side (50 megapixels at most); anything else is a 422 naming `url`. */
1436
1455
  url?: string;
1437
- /** The image bytes, base64 (no `data:` prefix). Base64 adds a third, and a request over ~6 MB is refused before it arrives, so this fits about 4 MB of image; send larger images (up to 5 MB) by `url`. At most 16,384 px a side and 50 megapixels; anything else is a 422 naming `data`. */
1456
+ /** The image bytes, base64 (no `data:` prefix), up to 5 MB of image. Base64 grows bytes by a third, and a request body may be up to 30 MB. At most 16,384 px a side and 50 megapixels; anything else is a 422 naming `data`. */
1438
1457
  data?: string;
1439
1458
  /** A file made with `POST /files` and purpose `image` (`file_…`): how an agent hands over a local image without base64 (an upload session), or an image up to 5 MB. Checked by its bytes when it was made, and again here. */
1440
1459
  file_id?: string;
@@ -1484,7 +1503,7 @@ type LibraryImage = {
1484
1503
  type LibraryImageCreate = {
1485
1504
  /** A public https image to fetch (no redirects, no private addresses). PNG, JPEG, GIF or WebP, up to 5 MB and 16,384 px a side (50 megapixels at most); anything else is a 422 naming `url`. */
1486
1505
  url?: string;
1487
- /** The image bytes, base64 (no `data:` prefix). Base64 adds a third, and a request over ~6 MB is refused before it arrives, so this fits about 4 MB of image; send larger images (up to 5 MB) by `url`. At most 16,384 px a side and 50 megapixels; anything else is a 422 naming `data`. */
1506
+ /** The image bytes, base64 (no `data:` prefix), up to 5 MB of image. Base64 grows bytes by a third, and a request body may be up to 30 MB. At most 16,384 px a side and 50 megapixels; anything else is a 422 naming `data`. */
1488
1507
  data?: string;
1489
1508
  /** A file made with `POST /files` and purpose `image` (`file_…`): how an agent hands over a local image without base64 (an upload session), or an image up to 5 MB. Checked by its bytes when it was made, and again here. */
1490
1509
  file_id?: string;
@@ -1854,10 +1873,46 @@ type SegmentMember = {
1854
1873
  subscribed: boolean;
1855
1874
  unsubscribed_at: string | null;
1856
1875
  };
1876
+ /** Add one contact. */
1857
1877
  type SegmentMemberAdd = {
1878
+ /** The contact: its id (`con_…`) or email. */
1858
1879
  contact: string;
1880
+ /** The new member's per-segment subscription (default true). A contact that is already a member keeps its own. */
1859
1881
  subscribed?: boolean;
1860
1882
  };
1883
+ /** Who to add: exactly one of `contact`, `contact_ids` or `emails`. */
1884
+ type SegmentMemberAddBody = {
1885
+ /** One contact: its id (`con_…`) or email. */
1886
+ contact?: string;
1887
+ /** Many contacts of this workspace by id (`con_…`), up to 1,000. */
1888
+ contact_ids?: Array<string>;
1889
+ /** Many contacts of this workspace by email address, up to 1,000. */
1890
+ emails?: Array<string>;
1891
+ /** A new member's per-segment subscription (default true). A contact that is already a member keeps its own. */
1892
+ subscribed?: boolean;
1893
+ };
1894
+ /** Add many contacts: exactly one of `contact_ids` or `emails`. */
1895
+ type SegmentMembersAdd = {
1896
+ /** Many contacts of this workspace by id (`con_…`), up to 1,000. */
1897
+ contact_ids?: Array<string>;
1898
+ /** Many contacts of this workspace by email address, up to 1,000. */
1899
+ emails?: Array<string>;
1900
+ /** New members' per-segment subscription (default true). A contact that is already a member keeps its own. */
1901
+ subscribed?: boolean;
1902
+ };
1903
+ type SegmentMembersAdded = {
1904
+ object: "list";
1905
+ /** Each listed contact's membership, in the order sent (a contact listed twice appears once). */
1906
+ data: Array<{
1907
+ object: "segment_member";
1908
+ contact_id: string;
1909
+ subscribed: boolean;
1910
+ unsubscribed_at: string | null;
1911
+ }>;
1912
+ has_more: false;
1913
+ /** How many of them this call added; the others were already members and kept their state. */
1914
+ added: number;
1915
+ };
1861
1916
  type SegmentMemberUpdate = {
1862
1917
  /** `false` opts the contact out of this segment's sends without removing it; `true` opts it back in. */
1863
1918
  subscribed: boolean;
@@ -3456,6 +3511,7 @@ type models_ContactFieldUpdate = ContactFieldUpdate;
3456
3511
  type models_ContactImport = ContactImport;
3457
3512
  type models_ContactImportCreate = ContactImportCreate;
3458
3513
  type models_ContactSegment = ContactSegment;
3514
+ type models_ContactSetField = ContactSetField;
3459
3515
  type models_ContactTopic = ContactTopic;
3460
3516
  type models_ContactTopicList = ContactTopicList;
3461
3517
  type models_ContactTopicSet = ContactTopicSet;
@@ -3505,7 +3561,10 @@ type models_Segment = Segment;
3505
3561
  type models_SegmentCreate = SegmentCreate;
3506
3562
  type models_SegmentMember = SegmentMember;
3507
3563
  type models_SegmentMemberAdd = SegmentMemberAdd;
3564
+ type models_SegmentMemberAddBody = SegmentMemberAddBody;
3508
3565
  type models_SegmentMemberUpdate = SegmentMemberUpdate;
3566
+ type models_SegmentMembersAdd = SegmentMembersAdd;
3567
+ type models_SegmentMembersAdded = SegmentMembersAdded;
3509
3568
  type models_SegmentPreview = SegmentPreview;
3510
3569
  type models_SegmentPreviewRequest = SegmentPreviewRequest;
3511
3570
  type models_SegmentUpdate = SegmentUpdate;
@@ -3599,7 +3658,7 @@ type models_Whoami = Whoami;
3599
3658
  type models_WorkspaceKeyMint = WorkspaceKeyMint;
3600
3659
  type models_WorkspaceUpdate = WorkspaceUpdate;
3601
3660
  declare namespace models {
3602
- export type { models_Activity as Activity, models_ApiKey as ApiKey, models_ApiKeyCreate as ApiKeyCreate, models_ApiKeyCreated as ApiKeyCreated, models_ApiKeyUsage as ApiKeyUsage, models_Batch as Batch, models_BatchSend as BatchSend, models_BatchSendResult as BatchSendResult, models_BrandImport as BrandImport, models_BrandImportAccept as BrandImportAccept, models_BrandImportAccepted as BrandImportAccepted, models_BrandImportCreate as BrandImportCreate, models_BrandKit as BrandKit, models_BrandKitCreate as BrandKitCreate, models_BrandKitGraphicAdd as BrandKitGraphicAdd, models_BrandKitGraphicAdded as BrandKitGraphicAdded, models_BrandKitList as BrandKitList, models_BrandKitUpdate as BrandKitUpdate, Branding$1 as Branding, models_BrandingUpdate as BrandingUpdate, models_Campaign as Campaign, models_CampaignAffectedRecipient as CampaignAffectedRecipient, models_CampaignCreate as CampaignCreate, models_CampaignDuplicate as CampaignDuplicate, models_CampaignQualityRemoval as CampaignQualityRemoval, models_CampaignRecipient as CampaignRecipient, models_CampaignReschedule as CampaignReschedule, models_CampaignReviewRequest as CampaignReviewRequest, models_CampaignSend as CampaignSend, models_CampaignStats as CampaignStats, models_CampaignUpdate as CampaignUpdate, models_Contact as Contact, models_ContactActivity as ContactActivity, models_ContactAddress as ContactAddress, models_ContactCreate as ContactCreate, models_ContactField as ContactField, models_ContactFieldCreate as ContactFieldCreate, models_ContactFieldRename as ContactFieldRename, models_ContactFieldUpdate as ContactFieldUpdate, models_ContactImport as ContactImport, models_ContactImportCreate as ContactImportCreate, models_ContactSegment as ContactSegment, models_ContactTopic as ContactTopic, models_ContactTopicList as ContactTopicList, models_ContactTopicSet as ContactTopicSet, models_ContactTopicsUpdate as ContactTopicsUpdate, models_ContactUpdate as ContactUpdate, models_ContactsExport as ContactsExport, models_Domain as Domain, models_DomainCreate as DomainCreate, models_DomainDiagnosis as DomainDiagnosis, models_DomainUpdate as DomainUpdate, Email$1 as Email, models_EmailEvent as EmailEvent, models_EmailPatch as EmailPatch, models_EmailStats as EmailStats, models_EmailThread as EmailThread, models_EmailThreadDeleted as EmailThreadDeleted, models_EmailThreadDetail as EmailThreadDetail, models_EmailThreadReplyRequest as EmailThreadReplyRequest, models_EmailThreadReplyResult as EmailThreadReplyResult, Error$1 as Error, models_File as File, models_FileCreate as FileCreate, models_ImageUpload as ImageUpload, models_Job as Job, models_JobDownload as JobDownload, models_LibraryImage as LibraryImage, models_LibraryImageCreate as LibraryImageCreate, models_LibraryImageUpdate as LibraryImageUpdate, models_MintedWorkspaceKey as MintedWorkspaceKey, models_OrganizationPlanQuote as OrganizationPlanQuote, models_OrganizationPlanQuoteConfirm as OrganizationPlanQuoteConfirm, models_OrganizationPlanQuoteCreate as OrganizationPlanQuoteCreate, models_OrganizationPlanStop as OrganizationPlanStop, OrganizationSharedPlan$1 as OrganizationSharedPlan, models_OrganizationSharedPlanRemoval as OrganizationSharedPlanRemoval, models_OrganizationSharedPlanWorkspace as OrganizationSharedPlanWorkspace, models_OrganizationSharedPlanWorkspaceAdd as OrganizationSharedPlanWorkspaceAdd, models_OrganizationSharedPlanWorkspaceUpdate as OrganizationSharedPlanWorkspaceUpdate, models_OrganizationWebhookDelivery as OrganizationWebhookDelivery, models_OrganizationWorkspace as OrganizationWorkspace, models_OrganizationWorkspaceCreate as OrganizationWorkspaceCreate, models_OrganizationWorkspaceUpdate as OrganizationWorkspaceUpdate, models_OrganizationWorkspaceUsage as OrganizationWorkspaceUsage, models_ReceivedAttachmentUrl as ReceivedAttachmentUrl, models_ReceivedEmail as ReceivedEmail, models_ReceivedEmailRaw as ReceivedEmailRaw, models_ReceivedEmailSummary as ReceivedEmailSummary, models_RequestLog as RequestLog, models_Segment as Segment, models_SegmentCreate as SegmentCreate, models_SegmentMember as SegmentMember, models_SegmentMemberAdd as SegmentMemberAdd, models_SegmentMemberUpdate as SegmentMemberUpdate, models_SegmentPreview as SegmentPreview, models_SegmentPreviewRequest as SegmentPreviewRequest, models_SegmentUpdate as SegmentUpdate, models_SendEmail as SendEmail, models_SendResult as SendResult, models_Sender as Sender, models_SenderCreate as SenderCreate, models_SenderUpdate as SenderUpdate, Sms$1 as Sms, models_SmsAddContact as SmsAddContact, models_SmsBillableResource as SmsBillableResource, models_SmsBrand as SmsBrand, models_SmsBrandCreate as SmsBrandCreate, models_SmsBrandDocument as SmsBrandDocument, models_SmsBrandDocumentCreate as SmsBrandDocumentCreate, models_SmsBrandDocumentDeleted as SmsBrandDocumentDeleted, models_SmsBrandDocumentUrl as SmsBrandDocumentUrl, models_SmsBrandPatch as SmsBrandPatch, models_SmsCampaign as SmsCampaign, models_SmsCampaignCreate as SmsCampaignCreate, models_SmsCampaignRecipient as SmsCampaignRecipient, models_SmsCampaignReschedule as SmsCampaignReschedule, models_SmsCampaignResubmit as SmsCampaignResubmit, models_SmsCampaignSend as SmsCampaignSend, models_SmsCampaignUpdate as SmsCampaignUpdate, models_SmsCampaignValidation as SmsCampaignValidation, models_SmsConsent as SmsConsent, models_SmsConsentRecord as SmsConsentRecord, models_SmsConsentRecorded as SmsConsentRecorded, models_SmsConsentSetup as SmsConsentSetup, models_SmsJoinKeyword as SmsJoinKeyword, models_SmsJoinKeywordCreate as SmsJoinKeywordCreate, models_SmsJoinKeywordCreated as SmsJoinKeywordCreated, models_SmsJoinKeywordList as SmsJoinKeywordList, models_SmsMessagingProgram as SmsMessagingProgram, models_SmsMessagingProgramCreate as SmsMessagingProgramCreate, models_SmsMessagingProgramUpdate as SmsMessagingProgramUpdate, models_SmsNumber as SmsNumber, models_SmsNumberRelease as SmsNumberRelease, models_SmsNumberRequest as SmsNumberRequest, models_SmsNumberResubmission as SmsNumberResubmission, models_SmsNumberRetry as SmsNumberRetry, models_SmsOptInRequest as SmsOptInRequest, models_SmsPatch as SmsPatch, models_SmsQuote as SmsQuote, models_SmsQuoteConfirm as SmsQuoteConfirm, models_SmsQuoteCreate as SmsQuoteCreate, models_SmsRegistration as SmsRegistration, models_SmsRegistrationRemove as SmsRegistrationRemove, models_SmsRegistrationReplace as SmsRegistrationReplace, models_SmsRegistrationResubmission as SmsRegistrationResubmission, models_SmsSend as SmsSend, models_SmsStats as SmsStats, models_SmsTemplate as SmsTemplate, models_SmsTemplateCreate as SmsTemplateCreate, models_SmsTemplateTestSend as SmsTemplateTestSend, models_SmsTemplateTestSendResult as SmsTemplateTestSendResult, models_SmsTemplateUpdate as SmsTemplateUpdate, models_SmsTemplateUsage as SmsTemplateUsage, models_SmsTestDestination as SmsTestDestination, models_SmsTollFreeResubmit as SmsTollFreeResubmit, SpendCaps$1 as SpendCaps, models_SpendCapsUpdate as SpendCapsUpdate, models_Suppression as Suppression, models_SuppressionBulkResult as SuppressionBulkResult, models_SuppressionCreate as SuppressionCreate, models_Template as Template, models_TemplateCreate as TemplateCreate, models_TemplateDuplicate as TemplateDuplicate, models_TemplateFromLibrary as TemplateFromLibrary, models_TemplateRender as TemplateRender, models_TemplateRenderInput as TemplateRenderInput, models_TemplateTestSend as TemplateTestSend, models_TemplateTestSendResult as TemplateTestSendResult, models_TemplateUpdate as TemplateUpdate, models_TemplateUsage as TemplateUsage, models_TemplateVersion as TemplateVersion, models_Topic as Topic, models_TopicCreate as TopicCreate, models_TopicOptOut as TopicOptOut, models_TopicUpdate as TopicUpdate, Usage$1 as Usage, models_Webhook as Webhook, models_WebhookCreate as WebhookCreate, models_WebhookCreated as WebhookCreated, models_WebhookDelivery as WebhookDelivery, models_WebhookDeliveryReplay as WebhookDeliveryReplay, models_WebhookFlush as WebhookFlush, models_WebhookFlushResult as WebhookFlushResult, models_WebhookSecretRotated as WebhookSecretRotated, models_WebhookTestResult as WebhookTestResult, models_WebhookUpdate as WebhookUpdate, models_Whoami as Whoami, Workspace$1 as Workspace, models_WorkspaceKeyMint as WorkspaceKeyMint, models_WorkspaceUpdate as WorkspaceUpdate };
3661
+ export type { models_Activity as Activity, models_ApiKey as ApiKey, models_ApiKeyCreate as ApiKeyCreate, models_ApiKeyCreated as ApiKeyCreated, models_ApiKeyUsage as ApiKeyUsage, models_Batch as Batch, models_BatchSend as BatchSend, models_BatchSendResult as BatchSendResult, models_BrandImport as BrandImport, models_BrandImportAccept as BrandImportAccept, models_BrandImportAccepted as BrandImportAccepted, models_BrandImportCreate as BrandImportCreate, models_BrandKit as BrandKit, models_BrandKitCreate as BrandKitCreate, models_BrandKitGraphicAdd as BrandKitGraphicAdd, models_BrandKitGraphicAdded as BrandKitGraphicAdded, models_BrandKitList as BrandKitList, models_BrandKitUpdate as BrandKitUpdate, Branding$1 as Branding, models_BrandingUpdate as BrandingUpdate, models_Campaign as Campaign, models_CampaignAffectedRecipient as CampaignAffectedRecipient, models_CampaignCreate as CampaignCreate, models_CampaignDuplicate as CampaignDuplicate, models_CampaignQualityRemoval as CampaignQualityRemoval, models_CampaignRecipient as CampaignRecipient, models_CampaignReschedule as CampaignReschedule, models_CampaignReviewRequest as CampaignReviewRequest, models_CampaignSend as CampaignSend, models_CampaignStats as CampaignStats, models_CampaignUpdate as CampaignUpdate, models_Contact as Contact, models_ContactActivity as ContactActivity, models_ContactAddress as ContactAddress, models_ContactCreate as ContactCreate, models_ContactField as ContactField, models_ContactFieldCreate as ContactFieldCreate, models_ContactFieldRename as ContactFieldRename, models_ContactFieldUpdate as ContactFieldUpdate, models_ContactImport as ContactImport, models_ContactImportCreate as ContactImportCreate, models_ContactSegment as ContactSegment, models_ContactSetField as ContactSetField, models_ContactTopic as ContactTopic, models_ContactTopicList as ContactTopicList, models_ContactTopicSet as ContactTopicSet, models_ContactTopicsUpdate as ContactTopicsUpdate, models_ContactUpdate as ContactUpdate, models_ContactsExport as ContactsExport, models_Domain as Domain, models_DomainCreate as DomainCreate, models_DomainDiagnosis as DomainDiagnosis, models_DomainUpdate as DomainUpdate, Email$1 as Email, models_EmailEvent as EmailEvent, models_EmailPatch as EmailPatch, models_EmailStats as EmailStats, models_EmailThread as EmailThread, models_EmailThreadDeleted as EmailThreadDeleted, models_EmailThreadDetail as EmailThreadDetail, models_EmailThreadReplyRequest as EmailThreadReplyRequest, models_EmailThreadReplyResult as EmailThreadReplyResult, Error$1 as Error, models_File as File, models_FileCreate as FileCreate, models_ImageUpload as ImageUpload, models_Job as Job, models_JobDownload as JobDownload, models_LibraryImage as LibraryImage, models_LibraryImageCreate as LibraryImageCreate, models_LibraryImageUpdate as LibraryImageUpdate, models_MintedWorkspaceKey as MintedWorkspaceKey, models_OrganizationPlanQuote as OrganizationPlanQuote, models_OrganizationPlanQuoteConfirm as OrganizationPlanQuoteConfirm, models_OrganizationPlanQuoteCreate as OrganizationPlanQuoteCreate, models_OrganizationPlanStop as OrganizationPlanStop, OrganizationSharedPlan$1 as OrganizationSharedPlan, models_OrganizationSharedPlanRemoval as OrganizationSharedPlanRemoval, models_OrganizationSharedPlanWorkspace as OrganizationSharedPlanWorkspace, models_OrganizationSharedPlanWorkspaceAdd as OrganizationSharedPlanWorkspaceAdd, models_OrganizationSharedPlanWorkspaceUpdate as OrganizationSharedPlanWorkspaceUpdate, models_OrganizationWebhookDelivery as OrganizationWebhookDelivery, models_OrganizationWorkspace as OrganizationWorkspace, models_OrganizationWorkspaceCreate as OrganizationWorkspaceCreate, models_OrganizationWorkspaceUpdate as OrganizationWorkspaceUpdate, models_OrganizationWorkspaceUsage as OrganizationWorkspaceUsage, models_ReceivedAttachmentUrl as ReceivedAttachmentUrl, models_ReceivedEmail as ReceivedEmail, models_ReceivedEmailRaw as ReceivedEmailRaw, models_ReceivedEmailSummary as ReceivedEmailSummary, models_RequestLog as RequestLog, models_Segment as Segment, models_SegmentCreate as SegmentCreate, models_SegmentMember as SegmentMember, models_SegmentMemberAdd as SegmentMemberAdd, models_SegmentMemberAddBody as SegmentMemberAddBody, models_SegmentMemberUpdate as SegmentMemberUpdate, models_SegmentMembersAdd as SegmentMembersAdd, models_SegmentMembersAdded as SegmentMembersAdded, models_SegmentPreview as SegmentPreview, models_SegmentPreviewRequest as SegmentPreviewRequest, models_SegmentUpdate as SegmentUpdate, models_SendEmail as SendEmail, models_SendResult as SendResult, models_Sender as Sender, models_SenderCreate as SenderCreate, models_SenderUpdate as SenderUpdate, Sms$1 as Sms, models_SmsAddContact as SmsAddContact, models_SmsBillableResource as SmsBillableResource, models_SmsBrand as SmsBrand, models_SmsBrandCreate as SmsBrandCreate, models_SmsBrandDocument as SmsBrandDocument, models_SmsBrandDocumentCreate as SmsBrandDocumentCreate, models_SmsBrandDocumentDeleted as SmsBrandDocumentDeleted, models_SmsBrandDocumentUrl as SmsBrandDocumentUrl, models_SmsBrandPatch as SmsBrandPatch, models_SmsCampaign as SmsCampaign, models_SmsCampaignCreate as SmsCampaignCreate, models_SmsCampaignRecipient as SmsCampaignRecipient, models_SmsCampaignReschedule as SmsCampaignReschedule, models_SmsCampaignResubmit as SmsCampaignResubmit, models_SmsCampaignSend as SmsCampaignSend, models_SmsCampaignUpdate as SmsCampaignUpdate, models_SmsCampaignValidation as SmsCampaignValidation, models_SmsConsent as SmsConsent, models_SmsConsentRecord as SmsConsentRecord, models_SmsConsentRecorded as SmsConsentRecorded, models_SmsConsentSetup as SmsConsentSetup, models_SmsJoinKeyword as SmsJoinKeyword, models_SmsJoinKeywordCreate as SmsJoinKeywordCreate, models_SmsJoinKeywordCreated as SmsJoinKeywordCreated, models_SmsJoinKeywordList as SmsJoinKeywordList, models_SmsMessagingProgram as SmsMessagingProgram, models_SmsMessagingProgramCreate as SmsMessagingProgramCreate, models_SmsMessagingProgramUpdate as SmsMessagingProgramUpdate, models_SmsNumber as SmsNumber, models_SmsNumberRelease as SmsNumberRelease, models_SmsNumberRequest as SmsNumberRequest, models_SmsNumberResubmission as SmsNumberResubmission, models_SmsNumberRetry as SmsNumberRetry, models_SmsOptInRequest as SmsOptInRequest, models_SmsPatch as SmsPatch, models_SmsQuote as SmsQuote, models_SmsQuoteConfirm as SmsQuoteConfirm, models_SmsQuoteCreate as SmsQuoteCreate, models_SmsRegistration as SmsRegistration, models_SmsRegistrationRemove as SmsRegistrationRemove, models_SmsRegistrationReplace as SmsRegistrationReplace, models_SmsRegistrationResubmission as SmsRegistrationResubmission, models_SmsSend as SmsSend, models_SmsStats as SmsStats, models_SmsTemplate as SmsTemplate, models_SmsTemplateCreate as SmsTemplateCreate, models_SmsTemplateTestSend as SmsTemplateTestSend, models_SmsTemplateTestSendResult as SmsTemplateTestSendResult, models_SmsTemplateUpdate as SmsTemplateUpdate, models_SmsTemplateUsage as SmsTemplateUsage, models_SmsTestDestination as SmsTestDestination, models_SmsTollFreeResubmit as SmsTollFreeResubmit, SpendCaps$1 as SpendCaps, models_SpendCapsUpdate as SpendCapsUpdate, models_Suppression as Suppression, models_SuppressionBulkResult as SuppressionBulkResult, models_SuppressionCreate as SuppressionCreate, models_Template as Template, models_TemplateCreate as TemplateCreate, models_TemplateDuplicate as TemplateDuplicate, models_TemplateFromLibrary as TemplateFromLibrary, models_TemplateRender as TemplateRender, models_TemplateRenderInput as TemplateRenderInput, models_TemplateTestSend as TemplateTestSend, models_TemplateTestSendResult as TemplateTestSendResult, models_TemplateUpdate as TemplateUpdate, models_TemplateUsage as TemplateUsage, models_TemplateVersion as TemplateVersion, models_Topic as Topic, models_TopicCreate as TopicCreate, models_TopicOptOut as TopicOptOut, models_TopicUpdate as TopicUpdate, Usage$1 as Usage, models_Webhook as Webhook, models_WebhookCreate as WebhookCreate, models_WebhookCreated as WebhookCreated, models_WebhookDelivery as WebhookDelivery, models_WebhookDeliveryReplay as WebhookDeliveryReplay, models_WebhookFlush as WebhookFlush, models_WebhookFlushResult as WebhookFlushResult, models_WebhookSecretRotated as WebhookSecretRotated, models_WebhookTestResult as WebhookTestResult, models_WebhookUpdate as WebhookUpdate, models_Whoami as Whoami, Workspace$1 as Workspace, models_WorkspaceKeyMint as WorkspaceKeyMint, models_WorkspaceUpdate as WorkspaceUpdate };
3603
3662
  }
3604
3663
 
3605
3664
  /**
@@ -4383,6 +4442,18 @@ declare class Contacts extends Resource {
4383
4442
  * runs is a `409` `job_in_progress`. `segment_id` also needs `segments:read`.
4384
4443
  */
4385
4444
  export(body?: ContactsExport): Result<Job>;
4445
+ /**
4446
+ * Set one custom field to the same value on many contacts, as the Contacts
4447
+ * page's Set field does, as a background job (202, the `Job`): `key`,
4448
+ * `value` (typed against the field; `null` clears it), optional
4449
+ * `only_empty`, and exactly one of `contact_ids` or `emails` (up to 1,000,
4450
+ * each a contact of this workspace) or `segment_id` (every member, however
4451
+ * many; also needs `segments:read`). Each contact whose value changes gets
4452
+ * `contact.updated`; consent is never touched. Follow it with
4453
+ * `jobs.get(id)`. Pass an `idempotencyKey` so a retry answers the same job;
4454
+ * one is generated when you don't.
4455
+ */
4456
+ setField(body: ContactSetField, opts?: SendOptions): Result<Job>;
4386
4457
  }
4387
4458
  declare class ContactFields extends Resource {
4388
4459
  list(params?: ListParams): Result<ListResponse<ContactField>>;
@@ -4446,8 +4517,20 @@ declare class Segments extends Resource {
4446
4517
  update(id: string, body: SegmentUpdate): Result<Segment>;
4447
4518
  delete(id: string): Result<null>;
4448
4519
  listMembers(id: string, params?: ListParams): Result<ListResponse<SegmentMember>>;
4449
- /** Add a contact (by id or email) to the segment. Idempotent. */
4520
+ /**
4521
+ * Add a contact (by id or email, `{ contact }`) to the segment, which
4522
+ * answers its membership; or many at once (`{ contact_ids }` or
4523
+ * `{ emails }`, up to 1,000, all checked first), which answers each listed
4524
+ * contact's membership and `added`. Idempotent: an existing member keeps
4525
+ * its state.
4526
+ */
4527
+ addMember(id: string, body: SegmentMembersAdd & ({
4528
+ contact_ids: string[];
4529
+ } | {
4530
+ emails: string[];
4531
+ })): Result<SegmentMembersAdded>;
4450
4532
  addMember(id: string, body: SegmentMemberAdd): Result<SegmentMember>;
4533
+ addMember(id: string, body: SegmentMemberAddBody): Result<SegmentMember | SegmentMembersAdded>;
4451
4534
  /** Remove a contact (by id or email) from the segment. */
4452
4535
  removeMember(id: string, contact: string): Result<null>;
4453
4536
  /**
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { createHmac, timingSafeEqual, randomUUID } from 'crypto';
4
4
  var API_VERSION = "v1";
5
5
 
6
6
  // src/http.ts
7
- var SDK_VERSION = "0.5.0";
7
+ var SDK_VERSION = "0.6.0";
8
8
  var DEFAULT_BASE_URL = "https://www.unitpost.com";
9
9
  var UnitpostError = class extends Error {
10
10
  code;
@@ -1207,6 +1207,25 @@ var Contacts = class extends Resource {
1207
1207
  export(body = {}) {
1208
1208
  return this.http.request({ method: "POST", path: "/contacts/export", body });
1209
1209
  }
1210
+ /**
1211
+ * Set one custom field to the same value on many contacts, as the Contacts
1212
+ * page's Set field does, as a background job (202, the `Job`): `key`,
1213
+ * `value` (typed against the field; `null` clears it), optional
1214
+ * `only_empty`, and exactly one of `contact_ids` or `emails` (up to 1,000,
1215
+ * each a contact of this workspace) or `segment_id` (every member, however
1216
+ * many; also needs `segments:read`). Each contact whose value changes gets
1217
+ * `contact.updated`; consent is never touched. Follow it with
1218
+ * `jobs.get(id)`. Pass an `idempotencyKey` so a retry answers the same job;
1219
+ * one is generated when you don't.
1220
+ */
1221
+ setField(body, opts = {}) {
1222
+ return this.http.request({
1223
+ method: "POST",
1224
+ path: "/contacts/set-field",
1225
+ body,
1226
+ idempotencyKey: opts.idempotencyKey ?? randomUUID()
1227
+ });
1228
+ }
1210
1229
  };
1211
1230
  var ContactFields = class extends Resource {
1212
1231
  list(params = {}) {
@@ -1305,7 +1324,6 @@ var Segments = class extends Resource {
1305
1324
  listMembers(id, params = {}) {
1306
1325
  return this.http.request({ method: "GET", path: `/segments/${enc(id)}/contacts`, query: params });
1307
1326
  }
1308
- /** Add a contact (by id or email) to the segment. Idempotent. */
1309
1327
  addMember(id, body) {
1310
1328
  return this.http.request({ method: "POST", path: `/segments/${enc(id)}/contacts`, body });
1311
1329
  }