@myapihq/sdk 1.3.8 → 1.3.12

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/email.d.ts CHANGED
@@ -106,6 +106,10 @@ export declare function createMailbox(apiKey: string, domain: string, username:
106
106
  address: string;
107
107
  created_at: string;
108
108
  }>;
109
+ export declare function deleteMailbox(apiKey: string, address: string): Promise<void>;
110
+ export declare function mailServerResync(apiKey: string, orgId: string, domain: string): Promise<{
111
+ ok: boolean;
112
+ } & Record<string, unknown>>;
109
113
  export declare function listMailboxes(apiKey: string, options?: {
110
114
  domain?: string;
111
115
  filter?: 'unassigned';
package/dist/email.js CHANGED
@@ -5,6 +5,8 @@ exports.verifyEmail = verifyEmail;
5
5
  exports.verifyBulk = verifyBulk;
6
6
  exports.getVerifyJob = getVerifyJob;
7
7
  exports.createMailbox = createMailbox;
8
+ exports.deleteMailbox = deleteMailbox;
9
+ exports.mailServerResync = mailServerResync;
8
10
  exports.listMailboxes = listMailboxes;
9
11
  exports.activateSending = activateSending;
10
12
  exports.setForwarding = setForwarding;
@@ -107,6 +109,20 @@ async function getVerifyJob(apiKey, orgId, jobId) {
107
109
  async function createMailbox(apiKey, domain, username, displayName) {
108
110
  return (0, client_1.request)('POST', `${config_1.EMAIL_BASE}/email/mailboxes/create`, apiKey, { domain, username, display_name: displayName });
109
111
  }
112
+ // Backend (2026-06-06): idempotent — 204 whether the mailbox existed or not.
113
+ // Returns 409 MAILBOX_IN_USE when an active/paused campaign still sends from
114
+ // this address; pause/delete the campaign first.
115
+ async function deleteMailbox(apiKey, address) {
116
+ return (0, client_1.request)('DELETE', `${config_1.EMAIL_BASE}/email/mailboxes/${encodeURIComponent(address)}`, apiKey);
117
+ }
118
+ // Backend (2026-06-06): re-run Stalwart provisioning for a domain. Use when
119
+ // mailbox-create on a domain returns DOMAIN_NOT_MAIL_READY /
120
+ // MAILBOX_PROVISION_FAILED, or when the inbox endpoint returns
121
+ // "mail server error" on a domain whose `email_infra_ready` flag is stale.
122
+ // Idempotent.
123
+ async function mailServerResync(apiKey, orgId, domain) {
124
+ return (0, client_1.request)('POST', `${config_1.EMAIL_BASE}/email/orgs/${encodeURIComponent(orgId)}/domains/${encodeURIComponent(domain)}/mail-server-resync`, apiKey);
125
+ }
110
126
  async function listMailboxes(apiKey, options) {
111
127
  const query = new URLSearchParams();
112
128
  if (options?.domain)
package/dist/funnel.d.ts CHANGED
@@ -29,6 +29,11 @@ export interface CreateFunnelResponse {
29
29
  subdomain_url?: string;
30
30
  domain_url?: string;
31
31
  }
32
+ export interface GetFunnelResponse {
33
+ funnel: Funnel;
34
+ subdomain_url?: string;
35
+ domain_url?: string;
36
+ }
32
37
  export interface VerifyResult {
33
38
  pages?: Array<{
34
39
  slug: string;
@@ -45,7 +50,7 @@ export interface VerifyTest {
45
50
  export declare function createFunnel(apiKey: string, orgId: string, opts?: {
46
51
  name?: string;
47
52
  }): Promise<CreateFunnelResponse>;
48
- export declare function getFunnel(apiKey: string, orgId: string, funnelId: string): Promise<Funnel>;
53
+ export declare function getFunnel(apiKey: string, orgId: string, funnelId: string): Promise<GetFunnelResponse>;
49
54
  export declare function listFunnels(apiKey: string, orgId: string): Promise<Funnel[]>;
50
55
  export declare function deleteFunnel(apiKey: string, orgId: string, funnelId: string): Promise<void>;
51
56
  export declare function pushFunnelPage(apiKey: string, orgId: string, funnelId: string, payload: {
package/dist/funnel.js CHANGED
@@ -36,7 +36,14 @@ async function createFunnel(apiKey, orgId, opts) {
36
36
  return (0, client_1.request)('POST', `${config_1.FUNNEL_BASE}/funnel/orgs/${encodeURIComponent(orgId)}/funnels`, apiKey, opts?.name ? { name: opts.name } : {});
37
37
  }
38
38
  async function getFunnel(apiKey, orgId, funnelId) {
39
- return (0, client_1.request)('GET', `${config_1.FUNNEL_BASE}/funnel/orgs/${encodeURIComponent(orgId)}/funnels/${encodeURIComponent(funnelId)}`, apiKey);
39
+ // Backend has wrapped GET responses since 2026-04 (`{funnel, subdomain_url, domain_url}`).
40
+ // Older builds returned a flat Funnel — normalize to the envelope so
41
+ // callers can rely on the typed shape.
42
+ const raw = await (0, client_1.request)('GET', `${config_1.FUNNEL_BASE}/funnel/orgs/${encodeURIComponent(orgId)}/funnels/${encodeURIComponent(funnelId)}`, apiKey);
43
+ if (raw && typeof raw === 'object' && 'funnel' in raw && raw.funnel) {
44
+ return raw;
45
+ }
46
+ return { funnel: raw };
40
47
  }
41
48
  async function listFunnels(apiKey, orgId) {
42
49
  return (0, client_1.request)('GET', `${config_1.FUNNEL_BASE}/funnel/orgs/${encodeURIComponent(orgId)}/funnels`, apiKey);
package/dist/hq.d.ts CHANGED
@@ -74,6 +74,12 @@ export type FreeTierEntry = {
74
74
  };
75
75
  export declare function getFreeTier(apiKey: string): Promise<FreeTierEntry[] | null>;
76
76
  export declare function getAccount(apiKey: string): Promise<AccountInfo>;
77
+ export declare function getMailingAddress(apiKey: string): Promise<{
78
+ mailing_address: string | null;
79
+ }>;
80
+ export declare function setMailingAddress(apiKey: string, mailingAddress: string): Promise<{
81
+ mailing_address: string;
82
+ }>;
77
83
  export interface CreateApiKeyOptions {
78
84
  grants?: Grants;
79
85
  orgId?: string;
package/dist/hq.js CHANGED
@@ -7,6 +7,8 @@ exports.verifyCode = verifyCode;
7
7
  exports.upgradeAccount = upgradeAccount;
8
8
  exports.getFreeTier = getFreeTier;
9
9
  exports.getAccount = getAccount;
10
+ exports.getMailingAddress = getMailingAddress;
11
+ exports.setMailingAddress = setMailingAddress;
10
12
  exports.createApiKey = createApiKey;
11
13
  exports.listApiKeys = listApiKeys;
12
14
  exports.revokeApiKey = revokeApiKey;
@@ -40,6 +42,11 @@ exports.EXPOSES = [
40
42
  'POST /hq/account/keys/revoke-all',
41
43
  'DELETE /hq/account/delete/key/{key_id}',
42
44
  'PATCH /hq/account/spend-cap',
45
+ // Backend (2026-06-06): account-scoped mailing address — required for
46
+ // transactional email per CAN-SPAM. PATCH sets, GET reads (null when
47
+ // unset). Hard-gates POST /email/send with MAILING_ADDRESS_REQUIRED.
48
+ 'PATCH /hq/account/mailing-address',
49
+ 'GET /hq/account/mailing-address',
43
50
  'POST /hq/orgs',
44
51
  'GET /hq/orgs',
45
52
  'GET /hq/orgs/{org_id}',
@@ -80,6 +87,14 @@ async function getFreeTier(apiKey) {
80
87
  async function getAccount(apiKey) {
81
88
  return (0, client_1.request)('GET', `${config_1.HQ_BASE}/hq/account/me`, apiKey);
82
89
  }
90
+ // Mailing address — required for transactional `email send` (CAN-SPAM).
91
+ // `getMailingAddress` returns `null` for `mailing_address` when unset.
92
+ async function getMailingAddress(apiKey) {
93
+ return (0, client_1.request)('GET', `${config_1.HQ_BASE}/hq/account/mailing-address`, apiKey);
94
+ }
95
+ async function setMailingAddress(apiKey, mailingAddress) {
96
+ return (0, client_1.request)('PATCH', `${config_1.HQ_BASE}/hq/account/mailing-address`, apiKey, { mailing_address: mailingAddress });
97
+ }
83
98
  // Mints a manual API key. The requested (grants, org, spend cap) must be a
84
99
  // subset of the calling key's authority — the backend rejects escalation
85
100
  // with 403 SCOPE_FORBIDDEN. The full `api_key` is in the response ONCE.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@myapihq/sdk",
3
3
  "license": "Apache-2.0",
4
- "version": "1.3.8",
4
+ "version": "1.3.12",
5
5
  "description": "TypeScript SDK for the MyAPI ecosystem",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
package/src/email.ts CHANGED
@@ -137,6 +137,22 @@ export async function createMailbox(apiKey: string, domain: string, username: st
137
137
  return request('POST', `${BASE_URL}/email/mailboxes/create`, apiKey, { domain, username, display_name: displayName });
138
138
  }
139
139
 
140
+ // Backend (2026-06-06): idempotent — 204 whether the mailbox existed or not.
141
+ // Returns 409 MAILBOX_IN_USE when an active/paused campaign still sends from
142
+ // this address; pause/delete the campaign first.
143
+ export async function deleteMailbox(apiKey: string, address: string): Promise<void> {
144
+ return request('DELETE', `${BASE_URL}/email/mailboxes/${encodeURIComponent(address)}`, apiKey);
145
+ }
146
+
147
+ // Backend (2026-06-06): re-run Stalwart provisioning for a domain. Use when
148
+ // mailbox-create on a domain returns DOMAIN_NOT_MAIL_READY /
149
+ // MAILBOX_PROVISION_FAILED, or when the inbox endpoint returns
150
+ // "mail server error" on a domain whose `email_infra_ready` flag is stale.
151
+ // Idempotent.
152
+ export async function mailServerResync(apiKey: string, orgId: string, domain: string): Promise<{ ok: boolean } & Record<string, unknown>> {
153
+ return request('POST', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/domains/${encodeURIComponent(domain)}/mail-server-resync`, apiKey);
154
+ }
155
+
140
156
  export async function listMailboxes(apiKey: string, options?: { domain?: string; filter?: 'unassigned' }): Promise<{ address: string; created_at: string }[]> {
141
157
  const query = new URLSearchParams();
142
158
  if (options?.domain) query.append('domain', options.domain);
package/src/funnel.ts CHANGED
@@ -55,6 +55,9 @@ export interface FormBinding {
55
55
  rate_limit?: { per_minute: number };
56
56
  }
57
57
  export interface CreateFunnelResponse { funnel: Funnel; subdomain_url?: string; domain_url?: string }
58
+ // Same envelope shape on read — kept as its own name so call sites read
59
+ // honestly. Wire shape is `{funnel: {...}, subdomain_url?, domain_url?}`.
60
+ export interface GetFunnelResponse { funnel: Funnel; subdomain_url?: string; domain_url?: string }
58
61
  export interface VerifyResult {
59
62
  pages?: Array<{ slug: string; tests: VerifyTest[] }>;
60
63
  tests?: VerifyTest[];
@@ -66,8 +69,19 @@ export async function createFunnel(apiKey: string, orgId: string, opts?: { name?
66
69
  // matching the reserved-suffix rules; agent should pre-validate.
67
70
  return request('POST', `${BASE_URL}/funnel/orgs/${encodeURIComponent(orgId)}/funnels`, apiKey, opts?.name ? { name: opts.name } : {});
68
71
  }
69
- export async function getFunnel(apiKey: string, orgId: string, funnelId: string): Promise<Funnel> {
70
- return request('GET', `${BASE_URL}/funnel/orgs/${encodeURIComponent(orgId)}/funnels/${encodeURIComponent(funnelId)}`, apiKey);
72
+ export async function getFunnel(apiKey: string, orgId: string, funnelId: string): Promise<GetFunnelResponse> {
73
+ // Backend has wrapped GET responses since 2026-04 (`{funnel, subdomain_url, domain_url}`).
74
+ // Older builds returned a flat Funnel — normalize to the envelope so
75
+ // callers can rely on the typed shape.
76
+ const raw = await request<GetFunnelResponse | Funnel>(
77
+ 'GET',
78
+ `${BASE_URL}/funnel/orgs/${encodeURIComponent(orgId)}/funnels/${encodeURIComponent(funnelId)}`,
79
+ apiKey,
80
+ );
81
+ if (raw && typeof raw === 'object' && 'funnel' in raw && (raw as GetFunnelResponse).funnel) {
82
+ return raw as GetFunnelResponse;
83
+ }
84
+ return { funnel: raw as Funnel };
71
85
  }
72
86
  export async function listFunnels(apiKey: string, orgId: string): Promise<Funnel[]> {
73
87
  return request('GET', `${BASE_URL}/funnel/orgs/${encodeURIComponent(orgId)}/funnels`, apiKey);
package/src/hq.ts CHANGED
@@ -14,6 +14,11 @@ export const EXPOSES: Exposes = [
14
14
  'POST /hq/account/keys/revoke-all',
15
15
  'DELETE /hq/account/delete/key/{key_id}',
16
16
  'PATCH /hq/account/spend-cap',
17
+ // Backend (2026-06-06): account-scoped mailing address — required for
18
+ // transactional email per CAN-SPAM. PATCH sets, GET reads (null when
19
+ // unset). Hard-gates POST /email/send with MAILING_ADDRESS_REQUIRED.
20
+ 'PATCH /hq/account/mailing-address',
21
+ 'GET /hq/account/mailing-address',
17
22
  'POST /hq/orgs',
18
23
  'GET /hq/orgs',
19
24
  'GET /hq/orgs/{org_id}',
@@ -148,6 +153,16 @@ export async function getAccount(apiKey: string): Promise<AccountInfo> {
148
153
  return request('GET', `${BASE_URL}/hq/account/me`, apiKey);
149
154
  }
150
155
 
156
+ // Mailing address — required for transactional `email send` (CAN-SPAM).
157
+ // `getMailingAddress` returns `null` for `mailing_address` when unset.
158
+ export async function getMailingAddress(apiKey: string): Promise<{ mailing_address: string | null }> {
159
+ return request('GET', `${BASE_URL}/hq/account/mailing-address`, apiKey);
160
+ }
161
+
162
+ export async function setMailingAddress(apiKey: string, mailingAddress: string): Promise<{ mailing_address: string }> {
163
+ return request('PATCH', `${BASE_URL}/hq/account/mailing-address`, apiKey, { mailing_address: mailingAddress });
164
+ }
165
+
151
166
  export interface CreateApiKeyOptions {
152
167
  // Slot grants. Omitted → backend defaults to unrestricted ({"*":"write"}).
153
168
  grants?: Grants;