mailtea-sdk 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,7 +47,10 @@ const mailtea = new Mailtea(apiKey, { baseUrl: "http://localhost:8787" });
47
47
  | `emails.update(id, { scheduled_at })` | Reschedule a scheduled email |
48
48
  | `emails.reschedule(id, scheduledAt)` | Convenience wrapper over `update` |
49
49
  | `emails.cancel(id)` | Cancel a scheduled email |
50
- | `contacts.create / list / get / update / delete` | Manage audience contacts |
50
+ | `contacts.create / upsert / list / get / update / delete` | Manage audience contacts (`upsert` = `create`; the endpoint upserts) |
51
+ | `posts.create(input)` | Create a newsletter post (draft, or `send: true`) → `{ id }` |
52
+ | `posts.send(id, { scheduled_at? })` | Send a draft post to the audience, now or scheduled |
53
+ | `posts.sendTest(id, input)` | Send a `[TEST]` copy of a post → `{ sent_to, failed_to }` |
51
54
  | `segments.create / list / get / update / delete` | Manage segments |
52
55
  | `tags.create / list / get / update / delete` | Manage tags |
53
56
  | `domains.create / list / get / verify / update / delete` | Manage sending domains (add, read DNS records, verify) |
package/dist/index.d.ts CHANGED
@@ -410,6 +410,11 @@ declare class Contacts {
410
410
  constructor(request: RequestFn);
411
411
  /** Create (or upsert) a contact in a publication. */
412
412
  create(input: CreateContactInput): Promise<Contact>;
413
+ /**
414
+ * Create the contact or update it in place — alias of `create`, named for
415
+ * what `POST /v1/contacts` actually does.
416
+ */
417
+ upsert(input: CreateContactInput): Promise<Contact>;
413
418
  /** List contacts in a publication. Supports cursor pagination via `after`. */
414
419
  list(params: ListContactsParams): Promise<ListResponse<Contact>>;
415
420
  /** Retrieve a single contact by id or email. */
@@ -573,6 +578,16 @@ interface CreatePostResult {
573
578
  /** The new post's id. */
574
579
  id: string;
575
580
  }
581
+ /** Input for `posts.send`. */
582
+ interface SendPostInput {
583
+ /** ISO-8601; schedules the send instead of sending now. */
584
+ scheduled_at?: string;
585
+ }
586
+ /** Result of `posts.send`. */
587
+ interface SendPostResult {
588
+ object: "post";
589
+ id: string;
590
+ }
576
591
  /**
577
592
  * The `posts` resource (newsletter posts/issues). Access via `mailtea.posts`.
578
593
  */
@@ -586,6 +601,12 @@ declare class Posts {
586
601
  * schedule) — that requires the `issues:send` scope. Returns `{ id }`.
587
602
  */
588
603
  create(input: CreatePostInput): Promise<CreatePostResult>;
604
+ /**
605
+ * Send a draft post to the publication's audience — immediately, or at
606
+ * `scheduled_at` (ISO-8601) if given. Requires the `issues:send` scope.
607
+ * Returns `{ id }`.
608
+ */
609
+ send(id: string, input?: SendPostInput): Promise<SendPostResult>;
589
610
  /**
590
611
  * Send a TEST copy of a post to specific recipients to check it before
591
612
  * subscribers see it. Renders the post exactly as a subscriber would receive
@@ -957,4 +978,4 @@ interface VerifyWebhookSignatureInput {
957
978
  */
958
979
  declare function verifyWebhookSignature(input: VerifyWebhookSignatureInput): boolean;
959
980
 
960
- export { type ApiKeyListItem, type ApiKeyPermission, ApiKeys, type BatchEmailInput, type BatchEmailItemInput, type BatchEmailResponse, type CancelEmailResponse, type Contact, ContactProperties, type ContactProperty, type ContactPropertyType, type ContactStatus, Contacts, type CreateApiKeyInput, type CreateContactInput, type CreateContactPropertyInput, type CreateDomainInput, type CreatePostInput, type CreatePostResult, type CreateSegmentInput, type CreateTagInput, type CreateTrackingDomainInput, type CreateWebhookInput, type CreatedApiKey, type DeletedResponse, type Domain, type DomainPurpose, type DomainRecord, type DomainStatus, Domains, type EmailAnalytics, type EmailAnalyticsParams, type EmailAttachmentMeta, type EmailListItem, type EmailListResponse, type EmailStatus, type EmailTag, Emails, type InboundAttachment, type InboundAttachmentMeta, InboundAttachments, type InboundEmailListItem, InboundEmails, type InboundReplyInput, type InboundReplyResponse, type ListContactPropertiesParams, type ListContactsParams, type ListDomainsParams, type ListEmailsParams, type ListInboundEmailsParams, type ListResponse, type ListSegmentsParams, type ListTagsParams, type ListWebhooksParams, Mailtea, MailteaError, type MailteaErrorInit, type MailteaOptions, type PostTestSendResult, Posts, type RequestFn, type RetrievedEmail, type RetrievedInboundEmail, type Segment, Segments, type SendEmailInput, type SendEmailResponse, type SendPostTestInput, type SignWebhookInput, type Tag, type TagSubscription, type TagVisibility, Tags, type TemplateRef, type TrackingDomain, TrackingDomains, type UpdateContactInput, type UpdateContactPropertyInput, type UpdateDomainInput, type UpdateEmailInput, type UpdateEmailResponse, type UpdateSegmentInput, type UpdateTagInput, type UpdateWebhookInput, type VerifyWebhookSignatureInput, type Webhook, type WebhookEvent, type WebhookStatus, Webhooks, signWebhook, verifyWebhookSignature };
981
+ export { type ApiKeyListItem, type ApiKeyPermission, ApiKeys, type BatchEmailInput, type BatchEmailItemInput, type BatchEmailResponse, type CancelEmailResponse, type Contact, ContactProperties, type ContactProperty, type ContactPropertyType, type ContactStatus, Contacts, type CreateApiKeyInput, type CreateContactInput, type CreateContactPropertyInput, type CreateDomainInput, type CreatePostInput, type CreatePostResult, type CreateSegmentInput, type CreateTagInput, type CreateTrackingDomainInput, type CreateWebhookInput, type CreatedApiKey, type DeletedResponse, type Domain, type DomainPurpose, type DomainRecord, type DomainStatus, Domains, type EmailAnalytics, type EmailAnalyticsParams, type EmailAttachmentMeta, type EmailListItem, type EmailListResponse, type EmailStatus, type EmailTag, Emails, type InboundAttachment, type InboundAttachmentMeta, InboundAttachments, type InboundEmailListItem, InboundEmails, type InboundReplyInput, type InboundReplyResponse, type ListContactPropertiesParams, type ListContactsParams, type ListDomainsParams, type ListEmailsParams, type ListInboundEmailsParams, type ListResponse, type ListSegmentsParams, type ListTagsParams, type ListWebhooksParams, Mailtea, MailteaError, type MailteaErrorInit, type MailteaOptions, type PostTestSendResult, Posts, type RequestFn, type RetrievedEmail, type RetrievedInboundEmail, type Segment, Segments, type SendEmailInput, type SendEmailResponse, type SendPostInput, type SendPostResult, type SendPostTestInput, type SignWebhookInput, type Tag, type TagSubscription, type TagVisibility, Tags, type TemplateRef, type TrackingDomain, TrackingDomains, type UpdateContactInput, type UpdateContactPropertyInput, type UpdateDomainInput, type UpdateEmailInput, type UpdateEmailResponse, type UpdateSegmentInput, type UpdateTagInput, type UpdateWebhookInput, type VerifyWebhookSignatureInput, type Webhook, type WebhookEvent, type WebhookStatus, Webhooks, signWebhook, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -162,6 +162,13 @@ var Contacts = class {
162
162
  create(input) {
163
163
  return this.request("POST", "/v1/contacts", input);
164
164
  }
165
+ /**
166
+ * Create the contact or update it in place — alias of `create`, named for
167
+ * what `POST /v1/contacts` actually does.
168
+ */
169
+ upsert(input) {
170
+ return this.create(input);
171
+ }
165
172
  /** List contacts in a publication. Supports cursor pagination via `after`. */
166
173
  list(params) {
167
174
  return this.request(
@@ -287,6 +294,18 @@ var Posts = class {
287
294
  create(input) {
288
295
  return this.request("POST", "/v1/posts", input);
289
296
  }
297
+ /**
298
+ * Send a draft post to the publication's audience — immediately, or at
299
+ * `scheduled_at` (ISO-8601) if given. Requires the `issues:send` scope.
300
+ * Returns `{ id }`.
301
+ */
302
+ send(id, input) {
303
+ return this.request(
304
+ "POST",
305
+ `/v1/posts/${encodeURIComponent(id)}/send`,
306
+ input
307
+ );
308
+ }
290
309
  /**
291
310
  * Send a TEST copy of a post to specific recipients to check it before
292
311
  * subscribers see it. Renders the post exactly as a subscriber would receive
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailtea-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Mailtea Node.js SDK — send, schedule, and manage email, contacts, and segments from your app or AI agent.",
5
5
  "license": "MIT",
6
6
  "type": "module",