@myapihq/sdk 1.0.11 → 1.0.13
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 +18 -5
- package/dist/email.js +16 -2
- package/dist/funnel.d.ts +9 -7
- package/dist/funnel.js +14 -14
- package/package.json +1 -1
- package/src/client.d.ts +6 -0
- package/src/client.js +51 -0
- package/src/domain.d.ts +32 -0
- package/src/domain.js +36 -0
- package/src/email.d.ts +144 -0
- package/src/email.js +116 -0
- package/src/email.ts +16 -5
- package/src/funnel.d.ts +31 -0
- package/src/funnel.js +28 -0
- package/src/funnel.ts +12 -11
- package/src/hq.d.ts +84 -0
- package/src/hq.js +80 -0
- package/src/image.d.ts +21 -0
- package/src/image.js +16 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +51 -0
- package/src/pixel.d.ts +65 -0
- package/src/pixel.js +44 -0
- package/src/storage.d.ts +10 -0
- package/src/storage.js +48 -0
- package/src/types.d.ts +17 -0
- package/src/types.js +2 -0
- package/src/webhook.d.ts +20 -0
- package/src/webhook.js +20 -0
- package/src/workflow.d.ts +56 -0
- package/src/workflow.js +40 -0
package/dist/email.d.ts
CHANGED
|
@@ -13,14 +13,20 @@ export interface EmailTemplate {
|
|
|
13
13
|
created_at: string;
|
|
14
14
|
updated_at: string;
|
|
15
15
|
}
|
|
16
|
+
export interface WarmupConfig {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
start: number;
|
|
19
|
+
increment: number;
|
|
20
|
+
max: number;
|
|
21
|
+
}
|
|
16
22
|
export interface Campaign {
|
|
17
23
|
id: string;
|
|
18
24
|
name: string;
|
|
19
25
|
status: string;
|
|
20
26
|
template_id: string;
|
|
21
27
|
from_address: string;
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
per_day_limit: number;
|
|
29
|
+
warmup_config?: WarmupConfig;
|
|
24
30
|
created_at: string;
|
|
25
31
|
}
|
|
26
32
|
export interface CampaignStats {
|
|
@@ -50,7 +56,10 @@ export declare function createMailbox(apiKey: string, orgId: string, domain: str
|
|
|
50
56
|
address: string;
|
|
51
57
|
created_at: string;
|
|
52
58
|
}>;
|
|
53
|
-
export declare function listMailboxes(apiKey: string, orgId: string
|
|
59
|
+
export declare function listMailboxes(apiKey: string, orgId: string, options?: {
|
|
60
|
+
domain?: string;
|
|
61
|
+
filter?: 'unassigned';
|
|
62
|
+
}): Promise<{
|
|
54
63
|
address: string;
|
|
55
64
|
created_at: string;
|
|
56
65
|
}[]>;
|
|
@@ -63,6 +72,8 @@ export declare function sendEmail(apiKey: string, orgId: string, payload: {
|
|
|
63
72
|
subject: string;
|
|
64
73
|
html?: string;
|
|
65
74
|
text?: string;
|
|
75
|
+
template_id?: string;
|
|
76
|
+
template_vars?: Record<string, string>;
|
|
66
77
|
}): Promise<{
|
|
67
78
|
message_id: string;
|
|
68
79
|
}>;
|
|
@@ -70,7 +81,9 @@ export declare function getEmailStatus(apiKey: string, orgId: string, messageId:
|
|
|
70
81
|
status: string;
|
|
71
82
|
delivered_at?: string;
|
|
72
83
|
}>;
|
|
84
|
+
export declare function getSentEmails(apiKey: string, orgId: string, limit?: number, offset?: number): Promise<EmailMessage[]>;
|
|
73
85
|
export declare function getInbox(apiKey: string, orgId: string, address: string): Promise<EmailMessage[]>;
|
|
86
|
+
export declare function getOutbox(apiKey: string, orgId: string, address: string): Promise<EmailMessage[]>;
|
|
74
87
|
export declare function getMessage(apiKey: string, orgId: string, messageId: string, address: string): Promise<EmailMessage>;
|
|
75
88
|
export declare function startWarmup(apiKey: string, orgId: string, address: string): Promise<{
|
|
76
89
|
warmup_status: string;
|
|
@@ -115,8 +128,8 @@ export declare function createCampaign(apiKey: string, orgId: string, payload: {
|
|
|
115
128
|
name: string;
|
|
116
129
|
template_id: string;
|
|
117
130
|
from_address: string;
|
|
118
|
-
|
|
119
|
-
|
|
131
|
+
per_day_limit?: number;
|
|
132
|
+
warmup_config?: WarmupConfig | null;
|
|
120
133
|
}): Promise<Campaign>;
|
|
121
134
|
export declare function uploadContactList(apiKey: string, orgId: string, campaignId: string, emails: string[]): Promise<{
|
|
122
135
|
list_id: string;
|
package/dist/email.js
CHANGED
|
@@ -5,7 +5,9 @@ exports.listMailboxes = listMailboxes;
|
|
|
5
5
|
exports.activateSending = activateSending;
|
|
6
6
|
exports.sendEmail = sendEmail;
|
|
7
7
|
exports.getEmailStatus = getEmailStatus;
|
|
8
|
+
exports.getSentEmails = getSentEmails;
|
|
8
9
|
exports.getInbox = getInbox;
|
|
10
|
+
exports.getOutbox = getOutbox;
|
|
9
11
|
exports.getMessage = getMessage;
|
|
10
12
|
exports.startWarmup = startWarmup;
|
|
11
13
|
exports.pauseWarmup = pauseWarmup;
|
|
@@ -33,8 +35,14 @@ const BASE_URL = 'https://api.myemailapi.com';
|
|
|
33
35
|
async function createMailbox(apiKey, orgId, domain, username) {
|
|
34
36
|
return (0, client_1.request)('POST', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/mailboxes/create`, apiKey, { domain, username });
|
|
35
37
|
}
|
|
36
|
-
async function listMailboxes(apiKey, orgId) {
|
|
37
|
-
|
|
38
|
+
async function listMailboxes(apiKey, orgId, options) {
|
|
39
|
+
const query = new URLSearchParams();
|
|
40
|
+
if (options?.domain)
|
|
41
|
+
query.append('domain', options.domain);
|
|
42
|
+
if (options?.filter)
|
|
43
|
+
query.append('filter', options.filter);
|
|
44
|
+
const qStr = query.toString();
|
|
45
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/mailboxes${qStr ? '?' + qStr : ''}`, apiKey);
|
|
38
46
|
}
|
|
39
47
|
async function activateSending(apiKey, orgId, address) {
|
|
40
48
|
return (0, client_1.request)('POST', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/sending/activate`, apiKey, { address });
|
|
@@ -45,9 +53,15 @@ async function sendEmail(apiKey, orgId, payload) {
|
|
|
45
53
|
async function getEmailStatus(apiKey, orgId, messageId) {
|
|
46
54
|
return (0, client_1.request)('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/status/${encodeURIComponent(messageId)}`, apiKey);
|
|
47
55
|
}
|
|
56
|
+
async function getSentEmails(apiKey, orgId, limit = 50, offset = 0) {
|
|
57
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/sent?limit=${limit}&offset=${offset}`, apiKey);
|
|
58
|
+
}
|
|
48
59
|
async function getInbox(apiKey, orgId, address) {
|
|
49
60
|
return (0, client_1.request)('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/inbox/${encodeURIComponent(address)}`, apiKey);
|
|
50
61
|
}
|
|
62
|
+
async function getOutbox(apiKey, orgId, address) {
|
|
63
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/outbox/${encodeURIComponent(address)}`, apiKey);
|
|
64
|
+
}
|
|
51
65
|
async function getMessage(apiKey, orgId, messageId, address) {
|
|
52
66
|
return (0, client_1.request)('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/message/${encodeURIComponent(messageId)}?address=${encodeURIComponent(address)}`, apiKey);
|
|
53
67
|
}
|
package/dist/funnel.d.ts
CHANGED
|
@@ -18,14 +18,16 @@ export interface VerifyTest {
|
|
|
18
18
|
details: string;
|
|
19
19
|
}
|
|
20
20
|
export declare function createFunnel(apiKey: string, orgId: string, domain: string): Promise<Funnel>;
|
|
21
|
-
export declare function
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
export declare function getFunnel(apiKey: string, orgId: string, funnelId: string): Promise<Funnel>;
|
|
22
|
+
export declare function listFunnels(apiKey: string, orgId: string): Promise<Funnel[]>;
|
|
23
|
+
export declare function deleteFunnel(apiKey: string, orgId: string, funnelId: string): Promise<void>;
|
|
24
|
+
export declare function pushFunnelPage(apiKey: string, orgId: string, funnelId: string, payload: {
|
|
25
|
+
slug: string;
|
|
26
|
+
html: string;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
url: string;
|
|
24
29
|
}>;
|
|
25
|
-
export declare function verifyFunnel(apiKey: string, funnelId: string, opts?: {
|
|
30
|
+
export declare function verifyFunnel(apiKey: string, orgId: string, funnelId: string, opts?: {
|
|
26
31
|
html?: string;
|
|
27
32
|
slug?: string;
|
|
28
33
|
}): Promise<VerifyResult>;
|
|
29
|
-
export declare function listFunnels(apiKey: string): Promise<Funnel[]>;
|
|
30
|
-
export declare function getFunnel(apiKey: string, funnelId: string): Promise<Funnel>;
|
|
31
|
-
export declare function deleteFunnel(apiKey: string, funnelId: string): Promise<void>;
|
package/dist/funnel.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createFunnel = createFunnel;
|
|
4
|
-
exports.pushPage = pushPage;
|
|
5
|
-
exports.verifyFunnel = verifyFunnel;
|
|
6
|
-
exports.listFunnels = listFunnels;
|
|
7
4
|
exports.getFunnel = getFunnel;
|
|
5
|
+
exports.listFunnels = listFunnels;
|
|
8
6
|
exports.deleteFunnel = deleteFunnel;
|
|
7
|
+
exports.pushFunnelPage = pushFunnelPage;
|
|
8
|
+
exports.verifyFunnel = verifyFunnel;
|
|
9
9
|
const client_1 = require("./client");
|
|
10
10
|
const BASE_URL = 'https://api.myfunnelapi.com';
|
|
11
11
|
async function createFunnel(apiKey, orgId, domain) {
|
|
12
|
-
return (0, client_1.request)('POST', `${BASE_URL}/funnel/funnels/create-raw`, apiKey, {
|
|
12
|
+
return (0, client_1.request)('POST', `${BASE_URL}/funnel/orgs/${encodeURIComponent(orgId)}/funnels/create-raw`, apiKey, { domain });
|
|
13
13
|
}
|
|
14
|
-
async function
|
|
15
|
-
return (0, client_1.request)('
|
|
14
|
+
async function getFunnel(apiKey, orgId, funnelId) {
|
|
15
|
+
return (0, client_1.request)('GET', `${BASE_URL}/funnel/orgs/${encodeURIComponent(orgId)}/funnels/${encodeURIComponent(funnelId)}`, apiKey);
|
|
16
16
|
}
|
|
17
|
-
async function
|
|
18
|
-
return (0, client_1.request)('
|
|
17
|
+
async function listFunnels(apiKey, orgId) {
|
|
18
|
+
return (0, client_1.request)('GET', `${BASE_URL}/funnel/orgs/${encodeURIComponent(orgId)}/funnels`, apiKey);
|
|
19
19
|
}
|
|
20
|
-
async function
|
|
21
|
-
return (0, client_1.request)('
|
|
20
|
+
async function deleteFunnel(apiKey, orgId, funnelId) {
|
|
21
|
+
return (0, client_1.request)('DELETE', `${BASE_URL}/funnel/orgs/${encodeURIComponent(orgId)}/funnels/${encodeURIComponent(funnelId)}`, apiKey);
|
|
22
22
|
}
|
|
23
|
-
async function
|
|
24
|
-
return (0, client_1.request)('
|
|
23
|
+
async function pushFunnelPage(apiKey, orgId, funnelId, payload) {
|
|
24
|
+
return (0, client_1.request)('POST', `${BASE_URL}/funnel/orgs/${encodeURIComponent(orgId)}/funnels/${encodeURIComponent(funnelId)}/push-page`, apiKey, payload);
|
|
25
25
|
}
|
|
26
|
-
async function
|
|
27
|
-
return (0, client_1.request)('
|
|
26
|
+
async function verifyFunnel(apiKey, orgId, funnelId, opts) {
|
|
27
|
+
return (0, client_1.request)('POST', `${BASE_URL}/funnel/orgs/${encodeURIComponent(orgId)}/funnels/${encodeURIComponent(funnelId)}/verify`, apiKey, opts || {});
|
|
28
28
|
}
|
package/package.json
CHANGED
package/src/client.d.ts
ADDED
package/src/client.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MyApiError = void 0;
|
|
4
|
+
exports.request = request;
|
|
5
|
+
class MyApiError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
status;
|
|
8
|
+
constructor(code, status) {
|
|
9
|
+
super(code);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.name = 'MyApiError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.MyApiError = MyApiError;
|
|
16
|
+
async function request(method, url, apiKey, body) {
|
|
17
|
+
const headers = {};
|
|
18
|
+
if (apiKey) {
|
|
19
|
+
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
20
|
+
}
|
|
21
|
+
if (body !== undefined) {
|
|
22
|
+
headers['Content-Type'] = 'application/json';
|
|
23
|
+
}
|
|
24
|
+
const options = {
|
|
25
|
+
method,
|
|
26
|
+
headers,
|
|
27
|
+
};
|
|
28
|
+
if (body !== undefined) {
|
|
29
|
+
options.body = JSON.stringify(body);
|
|
30
|
+
}
|
|
31
|
+
const response = await fetch(url, options);
|
|
32
|
+
if (response.status === 204) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
let result;
|
|
36
|
+
try {
|
|
37
|
+
result = await response.json();
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
throw new MyApiError('invalid_json_response', response.status);
|
|
41
|
+
}
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
const code = result?.error || 'unknown_error';
|
|
44
|
+
throw new MyApiError(code, response.status);
|
|
45
|
+
}
|
|
46
|
+
const apiResponse = result;
|
|
47
|
+
if (!apiResponse.success) {
|
|
48
|
+
throw new MyApiError(apiResponse.error || 'unknown_error', response.status);
|
|
49
|
+
}
|
|
50
|
+
return apiResponse.data;
|
|
51
|
+
}
|
package/src/domain.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface DomainRecord {
|
|
2
|
+
domain: string;
|
|
3
|
+
status: string;
|
|
4
|
+
expires_at?: string;
|
|
5
|
+
created_at: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DomainSettings {
|
|
8
|
+
domain: string;
|
|
9
|
+
security_level: string;
|
|
10
|
+
browser_check: string;
|
|
11
|
+
ai_bots_protection: string;
|
|
12
|
+
is_robots_txt_managed: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function checkDomain(apiKey: string, domain: string): Promise<{
|
|
15
|
+
available: boolean;
|
|
16
|
+
price_cents: number;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function registerDomain(apiKey: string, domain: string, years?: number): Promise<DomainRecord>;
|
|
19
|
+
export declare function importDomain(apiKey: string, payload: {
|
|
20
|
+
domain: string;
|
|
21
|
+
namecheap_api_user?: string;
|
|
22
|
+
namecheap_api_key?: string;
|
|
23
|
+
}): Promise<DomainRecord>;
|
|
24
|
+
export declare function listDomains(apiKey: string): Promise<DomainRecord[]>;
|
|
25
|
+
export declare function getDomainStatus(apiKey: string, domain: string): Promise<DomainRecord>;
|
|
26
|
+
export declare function renewDomain(apiKey: string, domain: string, years?: number): Promise<DomainRecord>;
|
|
27
|
+
export declare function getDomainSettings(apiKey: string, domain: string): Promise<DomainSettings>;
|
|
28
|
+
export declare function updateDomainSettings(apiKey: string, domain: string, payload: {
|
|
29
|
+
security_level?: 'essentially_off' | 'medium' | 'high' | 'under_attack';
|
|
30
|
+
browser_check?: 'on' | 'off';
|
|
31
|
+
purge_cache?: boolean;
|
|
32
|
+
}): Promise<DomainSettings>;
|
package/src/domain.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkDomain = checkDomain;
|
|
4
|
+
exports.registerDomain = registerDomain;
|
|
5
|
+
exports.importDomain = importDomain;
|
|
6
|
+
exports.listDomains = listDomains;
|
|
7
|
+
exports.getDomainStatus = getDomainStatus;
|
|
8
|
+
exports.renewDomain = renewDomain;
|
|
9
|
+
exports.getDomainSettings = getDomainSettings;
|
|
10
|
+
exports.updateDomainSettings = updateDomainSettings;
|
|
11
|
+
const client_1 = require("./client");
|
|
12
|
+
const BASE_URL = 'https://api.mydomainapi.com';
|
|
13
|
+
async function checkDomain(apiKey, domain) {
|
|
14
|
+
return (0, client_1.request)('GET', `${BASE_URL}/domain/check/${encodeURIComponent(domain)}`, apiKey);
|
|
15
|
+
}
|
|
16
|
+
async function registerDomain(apiKey, domain, years) {
|
|
17
|
+
return (0, client_1.request)('POST', `${BASE_URL}/domain/register`, apiKey, { domain, years });
|
|
18
|
+
}
|
|
19
|
+
async function importDomain(apiKey, payload) {
|
|
20
|
+
return (0, client_1.request)('POST', `${BASE_URL}/domain/import`, apiKey, payload);
|
|
21
|
+
}
|
|
22
|
+
async function listDomains(apiKey) {
|
|
23
|
+
return (0, client_1.request)('GET', `${BASE_URL}/domain/list/me`, apiKey);
|
|
24
|
+
}
|
|
25
|
+
async function getDomainStatus(apiKey, domain) {
|
|
26
|
+
return (0, client_1.request)('GET', `${BASE_URL}/domain/status/${encodeURIComponent(domain)}`, apiKey);
|
|
27
|
+
}
|
|
28
|
+
async function renewDomain(apiKey, domain, years) {
|
|
29
|
+
return (0, client_1.request)('POST', `${BASE_URL}/domain/renew/${encodeURIComponent(domain)}`, apiKey, { years });
|
|
30
|
+
}
|
|
31
|
+
async function getDomainSettings(apiKey, domain) {
|
|
32
|
+
return (0, client_1.request)('GET', `${BASE_URL}/domain/settings/${encodeURIComponent(domain)}`, apiKey);
|
|
33
|
+
}
|
|
34
|
+
async function updateDomainSettings(apiKey, domain, payload) {
|
|
35
|
+
return (0, client_1.request)('POST', `${BASE_URL}/domain/settings/${encodeURIComponent(domain)}`, apiKey, payload);
|
|
36
|
+
}
|
package/src/email.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
export interface EmailMessage {
|
|
2
|
+
message_id: string;
|
|
3
|
+
from: string;
|
|
4
|
+
subject: string;
|
|
5
|
+
body?: string;
|
|
6
|
+
received_at: string;
|
|
7
|
+
}
|
|
8
|
+
export interface EmailTemplate {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
subject: string;
|
|
12
|
+
preview_url: string;
|
|
13
|
+
created_at: string;
|
|
14
|
+
updated_at: string;
|
|
15
|
+
}
|
|
16
|
+
export interface Campaign {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
status: string;
|
|
20
|
+
template_id: string;
|
|
21
|
+
from_address: string;
|
|
22
|
+
rate_per_minute: number;
|
|
23
|
+
per_hour_limit: number;
|
|
24
|
+
created_at: string;
|
|
25
|
+
}
|
|
26
|
+
export interface CampaignStats {
|
|
27
|
+
campaign: Campaign;
|
|
28
|
+
validation: {
|
|
29
|
+
total: number;
|
|
30
|
+
valid: number;
|
|
31
|
+
invalid: number;
|
|
32
|
+
pending: number;
|
|
33
|
+
list_status: string;
|
|
34
|
+
};
|
|
35
|
+
dispatch: {
|
|
36
|
+
sent: number;
|
|
37
|
+
remaining: number;
|
|
38
|
+
sent_this_hour: number;
|
|
39
|
+
hour_limit: number;
|
|
40
|
+
last_dispatch_at: string;
|
|
41
|
+
};
|
|
42
|
+
engagement: {
|
|
43
|
+
sent: number;
|
|
44
|
+
opens: number;
|
|
45
|
+
clicks: number;
|
|
46
|
+
page_visits: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export declare function createMailbox(apiKey: string, domain: string, username: string): Promise<{
|
|
50
|
+
address: string;
|
|
51
|
+
created_at: string;
|
|
52
|
+
}>;
|
|
53
|
+
export declare function listMailboxes(apiKey: string): Promise<{
|
|
54
|
+
address: string;
|
|
55
|
+
created_at: string;
|
|
56
|
+
}[]>;
|
|
57
|
+
export declare function activateSending(apiKey: string, address: string): Promise<{
|
|
58
|
+
status: string;
|
|
59
|
+
}>;
|
|
60
|
+
export declare function sendEmail(apiKey: string, payload: {
|
|
61
|
+
from: string;
|
|
62
|
+
to: string[];
|
|
63
|
+
subject: string;
|
|
64
|
+
html?: string;
|
|
65
|
+
text?: string;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
message_id: string;
|
|
68
|
+
}>;
|
|
69
|
+
export declare function getEmailStatus(apiKey: string, messageId: string): Promise<{
|
|
70
|
+
status: string;
|
|
71
|
+
delivered_at?: string;
|
|
72
|
+
}>;
|
|
73
|
+
export declare function getInbox(apiKey: string, address: string): Promise<EmailMessage[]>;
|
|
74
|
+
export declare function getMessage(apiKey: string, messageId: string, address: string): Promise<EmailMessage>;
|
|
75
|
+
export declare function startWarmup(apiKey: string, address: string): Promise<{
|
|
76
|
+
warmup_status: string;
|
|
77
|
+
}>;
|
|
78
|
+
export declare function pauseWarmup(apiKey: string, address: string): Promise<void>;
|
|
79
|
+
export declare function resumeWarmup(apiKey: string, address: string): Promise<void>;
|
|
80
|
+
export declare function stopWarmup(apiKey: string, address: string): Promise<void>;
|
|
81
|
+
export declare function getWarmupStats(apiKey: string, address: string): Promise<{
|
|
82
|
+
sent: number;
|
|
83
|
+
landed_inbox: number;
|
|
84
|
+
landed_spam: number;
|
|
85
|
+
health_score: number;
|
|
86
|
+
}>;
|
|
87
|
+
export declare function generateTemplate(apiKey: string, payload: {
|
|
88
|
+
org_id: string;
|
|
89
|
+
prompt: string;
|
|
90
|
+
name: string;
|
|
91
|
+
}): Promise<{
|
|
92
|
+
job_id: string;
|
|
93
|
+
template_id: string;
|
|
94
|
+
status: string;
|
|
95
|
+
preview_url: string;
|
|
96
|
+
}>;
|
|
97
|
+
export declare function getTemplateJobStatus(apiKey: string, jobId: string): Promise<{
|
|
98
|
+
status: 'processing' | 'completed' | 'failed';
|
|
99
|
+
template_id: string;
|
|
100
|
+
result?: {
|
|
101
|
+
subject: string;
|
|
102
|
+
preview_url: string;
|
|
103
|
+
};
|
|
104
|
+
}>;
|
|
105
|
+
export declare function editTemplate(apiKey: string, templateId: string, prompt: string): Promise<{
|
|
106
|
+
template_id: string;
|
|
107
|
+
preview_url: string;
|
|
108
|
+
}>;
|
|
109
|
+
export declare function sendTestEmail(apiKey: string, templateId: string, to: string): Promise<{
|
|
110
|
+
ok: boolean;
|
|
111
|
+
message_id: string;
|
|
112
|
+
}>;
|
|
113
|
+
export declare function listTemplates(apiKey: string): Promise<EmailTemplate[]>;
|
|
114
|
+
export declare function deleteTemplate(apiKey: string, templateId: string): Promise<void>;
|
|
115
|
+
export declare function createCampaign(apiKey: string, payload: {
|
|
116
|
+
name: string;
|
|
117
|
+
template_id: string;
|
|
118
|
+
from_address: string;
|
|
119
|
+
rate_per_minute?: number;
|
|
120
|
+
per_hour_limit?: number;
|
|
121
|
+
}): Promise<Campaign>;
|
|
122
|
+
export declare function uploadContactList(apiKey: string, campaignId: string, emails: string[]): Promise<{
|
|
123
|
+
list_id: string;
|
|
124
|
+
total: number;
|
|
125
|
+
status: string;
|
|
126
|
+
}>;
|
|
127
|
+
export declare function getContactUploadStatus(apiKey: string, campaignId: string): Promise<{
|
|
128
|
+
upload_status: 'ready' | 'validating' | 'failed';
|
|
129
|
+
total: number;
|
|
130
|
+
valid_count: number;
|
|
131
|
+
invalid_count: number;
|
|
132
|
+
}>;
|
|
133
|
+
export declare function startCampaign(apiKey: string, campaignId: string): Promise<{
|
|
134
|
+
status: string;
|
|
135
|
+
}>;
|
|
136
|
+
export declare function pauseCampaign(apiKey: string, campaignId: string): Promise<void>;
|
|
137
|
+
export declare function resumeCampaign(apiKey: string, campaignId: string): Promise<void>;
|
|
138
|
+
export declare function getCampaignStats(apiKey: string, campaignId: string): Promise<CampaignStats>;
|
|
139
|
+
export declare function listCampaigns(apiKey: string): Promise<Campaign[]>;
|
|
140
|
+
export declare function getCampaign(apiKey: string, campaignId: string): Promise<Campaign>;
|
|
141
|
+
export declare function updateCampaign(apiKey: string, campaignId: string, payload: {
|
|
142
|
+
name?: string;
|
|
143
|
+
per_day_limit?: number;
|
|
144
|
+
}): Promise<Campaign>;
|
package/src/email.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMailbox = createMailbox;
|
|
4
|
+
exports.listMailboxes = listMailboxes;
|
|
5
|
+
exports.activateSending = activateSending;
|
|
6
|
+
exports.sendEmail = sendEmail;
|
|
7
|
+
exports.getEmailStatus = getEmailStatus;
|
|
8
|
+
exports.getInbox = getInbox;
|
|
9
|
+
exports.getMessage = getMessage;
|
|
10
|
+
exports.startWarmup = startWarmup;
|
|
11
|
+
exports.pauseWarmup = pauseWarmup;
|
|
12
|
+
exports.resumeWarmup = resumeWarmup;
|
|
13
|
+
exports.stopWarmup = stopWarmup;
|
|
14
|
+
exports.getWarmupStats = getWarmupStats;
|
|
15
|
+
exports.generateTemplate = generateTemplate;
|
|
16
|
+
exports.getTemplateJobStatus = getTemplateJobStatus;
|
|
17
|
+
exports.editTemplate = editTemplate;
|
|
18
|
+
exports.sendTestEmail = sendTestEmail;
|
|
19
|
+
exports.listTemplates = listTemplates;
|
|
20
|
+
exports.deleteTemplate = deleteTemplate;
|
|
21
|
+
exports.createCampaign = createCampaign;
|
|
22
|
+
exports.uploadContactList = uploadContactList;
|
|
23
|
+
exports.getContactUploadStatus = getContactUploadStatus;
|
|
24
|
+
exports.startCampaign = startCampaign;
|
|
25
|
+
exports.pauseCampaign = pauseCampaign;
|
|
26
|
+
exports.resumeCampaign = resumeCampaign;
|
|
27
|
+
exports.getCampaignStats = getCampaignStats;
|
|
28
|
+
exports.listCampaigns = listCampaigns;
|
|
29
|
+
exports.getCampaign = getCampaign;
|
|
30
|
+
exports.updateCampaign = updateCampaign;
|
|
31
|
+
const client_1 = require("./client");
|
|
32
|
+
const BASE_URL = 'https://api.myemailapi.com';
|
|
33
|
+
async function createMailbox(apiKey, domain, username) {
|
|
34
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/mailbox/create`, apiKey, { domain, username });
|
|
35
|
+
}
|
|
36
|
+
async function listMailboxes(apiKey) {
|
|
37
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/mailbox/list/me`, apiKey);
|
|
38
|
+
}
|
|
39
|
+
async function activateSending(apiKey, address) {
|
|
40
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/sending/activate`, apiKey, { address });
|
|
41
|
+
}
|
|
42
|
+
async function sendEmail(apiKey, payload) {
|
|
43
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/send`, apiKey, payload);
|
|
44
|
+
}
|
|
45
|
+
async function getEmailStatus(apiKey, messageId) {
|
|
46
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/status/${encodeURIComponent(messageId)}`, apiKey);
|
|
47
|
+
}
|
|
48
|
+
async function getInbox(apiKey, address) {
|
|
49
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/inbox/${encodeURIComponent(address)}`, apiKey);
|
|
50
|
+
}
|
|
51
|
+
async function getMessage(apiKey, messageId, address) {
|
|
52
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/message/${encodeURIComponent(messageId)}?address=${encodeURIComponent(address)}`, apiKey);
|
|
53
|
+
}
|
|
54
|
+
async function startWarmup(apiKey, address) {
|
|
55
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/warmup/start`, apiKey, { address });
|
|
56
|
+
}
|
|
57
|
+
async function pauseWarmup(apiKey, address) {
|
|
58
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/warmup/pause`, apiKey, { address });
|
|
59
|
+
}
|
|
60
|
+
async function resumeWarmup(apiKey, address) {
|
|
61
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/warmup/resume`, apiKey, { address });
|
|
62
|
+
}
|
|
63
|
+
async function stopWarmup(apiKey, address) {
|
|
64
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/warmup/stop`, apiKey, { address });
|
|
65
|
+
}
|
|
66
|
+
async function getWarmupStats(apiKey, address) {
|
|
67
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/warmup/stats/${encodeURIComponent(address)}`, apiKey);
|
|
68
|
+
}
|
|
69
|
+
async function generateTemplate(apiKey, payload) {
|
|
70
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/templates/generate`, apiKey, payload);
|
|
71
|
+
}
|
|
72
|
+
async function getTemplateJobStatus(apiKey, jobId) {
|
|
73
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/template-jobs/${encodeURIComponent(jobId)}`, apiKey);
|
|
74
|
+
}
|
|
75
|
+
async function editTemplate(apiKey, templateId, prompt) {
|
|
76
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/templates/${encodeURIComponent(templateId)}/edit`, apiKey, { prompt });
|
|
77
|
+
}
|
|
78
|
+
async function sendTestEmail(apiKey, templateId, to) {
|
|
79
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/templates/${encodeURIComponent(templateId)}/send-test`, apiKey, { to });
|
|
80
|
+
}
|
|
81
|
+
async function listTemplates(apiKey) {
|
|
82
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/templates`, apiKey);
|
|
83
|
+
}
|
|
84
|
+
async function deleteTemplate(apiKey, templateId) {
|
|
85
|
+
return (0, client_1.request)('DELETE', `${BASE_URL}/email/templates/${encodeURIComponent(templateId)}`, apiKey);
|
|
86
|
+
}
|
|
87
|
+
async function createCampaign(apiKey, payload) {
|
|
88
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/campaigns`, apiKey, payload);
|
|
89
|
+
}
|
|
90
|
+
async function uploadContactList(apiKey, campaignId, emails) {
|
|
91
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/contacts/upload-list`, apiKey, { emails });
|
|
92
|
+
}
|
|
93
|
+
async function getContactUploadStatus(apiKey, campaignId) {
|
|
94
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/contacts/status`, apiKey);
|
|
95
|
+
}
|
|
96
|
+
async function startCampaign(apiKey, campaignId) {
|
|
97
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/start`, apiKey);
|
|
98
|
+
}
|
|
99
|
+
async function pauseCampaign(apiKey, campaignId) {
|
|
100
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/pause`, apiKey);
|
|
101
|
+
}
|
|
102
|
+
async function resumeCampaign(apiKey, campaignId) {
|
|
103
|
+
return (0, client_1.request)('POST', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/resume`, apiKey);
|
|
104
|
+
}
|
|
105
|
+
async function getCampaignStats(apiKey, campaignId) {
|
|
106
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/stats`, apiKey);
|
|
107
|
+
}
|
|
108
|
+
async function listCampaigns(apiKey) {
|
|
109
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/campaigns`, apiKey);
|
|
110
|
+
}
|
|
111
|
+
async function getCampaign(apiKey, campaignId) {
|
|
112
|
+
return (0, client_1.request)('GET', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}`, apiKey);
|
|
113
|
+
}
|
|
114
|
+
async function updateCampaign(apiKey, campaignId, payload) {
|
|
115
|
+
return (0, client_1.request)('PATCH', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}`, apiKey, payload);
|
|
116
|
+
}
|
package/src/email.ts
CHANGED
|
@@ -4,7 +4,8 @@ const BASE_URL = 'https://api.myemailapi.com';
|
|
|
4
4
|
|
|
5
5
|
export interface EmailMessage { message_id: string; from: string; subject: string; body?: string; received_at: string }
|
|
6
6
|
export interface EmailTemplate { id: string; name: string; subject: string; preview_url: string; created_at: string; updated_at: string }
|
|
7
|
-
export interface
|
|
7
|
+
export interface WarmupConfig { enabled: boolean; start: number; increment: number; max: number; }
|
|
8
|
+
export interface Campaign { id: string; name: string; status: string; template_id: string; from_address: string; per_day_limit: number; warmup_config?: WarmupConfig; created_at: string }
|
|
8
9
|
export interface CampaignStats {
|
|
9
10
|
campaign: Campaign;
|
|
10
11
|
validation: { total: number; valid: number; invalid: number; pending: number; list_status: string };
|
|
@@ -15,22 +16,32 @@ export interface CampaignStats {
|
|
|
15
16
|
export async function createMailbox(apiKey: string, orgId: string, domain: string, username: string): Promise<{ address: string; created_at: string }> {
|
|
16
17
|
return request('POST', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/mailboxes/create`, apiKey, { domain, username });
|
|
17
18
|
}
|
|
18
|
-
export async function listMailboxes(apiKey: string, orgId: string): Promise<{ address: string; created_at: string }[]> {
|
|
19
|
-
|
|
19
|
+
export async function listMailboxes(apiKey: string, orgId: string, options?: { domain?: string; filter?: 'unassigned' }): Promise<{ address: string; created_at: string }[]> {
|
|
20
|
+
const query = new URLSearchParams();
|
|
21
|
+
if (options?.domain) query.append('domain', options.domain);
|
|
22
|
+
if (options?.filter) query.append('filter', options.filter);
|
|
23
|
+
const qStr = query.toString();
|
|
24
|
+
return request('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/mailboxes${qStr ? '?' + qStr : ''}`, apiKey);
|
|
20
25
|
}
|
|
21
26
|
export async function activateSending(apiKey: string, orgId: string, address: string): Promise<{ status: string }> {
|
|
22
27
|
return request('POST', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/sending/activate`, apiKey, { address });
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
export async function sendEmail(apiKey: string, orgId: string, payload: { from: string; to: string[]; subject: string; html?: string; text?: string; }): Promise<{ message_id: string }> {
|
|
30
|
+
export async function sendEmail(apiKey: string, orgId: string, payload: { from: string; to: string[]; subject: string; html?: string; text?: string; template_id?: string; template_vars?: Record<string, string> }): Promise<{ message_id: string }> {
|
|
26
31
|
return request('POST', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/send`, apiKey, payload);
|
|
27
32
|
}
|
|
28
33
|
export async function getEmailStatus(apiKey: string, orgId: string, messageId: string): Promise<{ status: string; delivered_at?: string }> {
|
|
29
34
|
return request('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/status/${encodeURIComponent(messageId)}`, apiKey);
|
|
30
35
|
}
|
|
36
|
+
export async function getSentEmails(apiKey: string, orgId: string, limit: number = 50, offset: number = 0): Promise<EmailMessage[]> {
|
|
37
|
+
return request('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/sent?limit=${limit}&offset=${offset}`, apiKey);
|
|
38
|
+
}
|
|
31
39
|
export async function getInbox(apiKey: string, orgId: string, address: string): Promise<EmailMessage[]> {
|
|
32
40
|
return request('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/inbox/${encodeURIComponent(address)}`, apiKey);
|
|
33
41
|
}
|
|
42
|
+
export async function getOutbox(apiKey: string, orgId: string, address: string): Promise<EmailMessage[]> {
|
|
43
|
+
return request('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/outbox/${encodeURIComponent(address)}`, apiKey);
|
|
44
|
+
}
|
|
34
45
|
export async function getMessage(apiKey: string, orgId: string, messageId: string, address: string): Promise<EmailMessage> {
|
|
35
46
|
return request('GET', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/message/${encodeURIComponent(messageId)}?address=${encodeURIComponent(address)}`, apiKey);
|
|
36
47
|
}
|
|
@@ -70,7 +81,7 @@ export async function deleteTemplate(apiKey: string, orgId: string, templateId:
|
|
|
70
81
|
return request('DELETE', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/templates/${encodeURIComponent(templateId)}`, apiKey);
|
|
71
82
|
}
|
|
72
83
|
|
|
73
|
-
export async function createCampaign(apiKey: string, orgId: string, payload: { name: string; template_id: string; from_address: string;
|
|
84
|
+
export async function createCampaign(apiKey: string, orgId: string, payload: { name: string; template_id: string; from_address: string; per_day_limit?: number; warmup_config?: WarmupConfig | null; }): Promise<Campaign> {
|
|
74
85
|
return request('POST', `${BASE_URL}/email/orgs/${encodeURIComponent(orgId)}/campaigns`, apiKey, payload);
|
|
75
86
|
}
|
|
76
87
|
export async function uploadContactList(apiKey: string, orgId: string, campaignId: string, emails: string[]): Promise<{ list_id: string; total: number; status: string }> {
|
package/src/funnel.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface Funnel {
|
|
2
|
+
id: string;
|
|
3
|
+
org_id: string;
|
|
4
|
+
domain: string;
|
|
5
|
+
created_at: string;
|
|
6
|
+
}
|
|
7
|
+
export interface VerifyResult {
|
|
8
|
+
pages?: Array<{
|
|
9
|
+
slug: string;
|
|
10
|
+
tests: VerifyTest[];
|
|
11
|
+
}>;
|
|
12
|
+
tests?: VerifyTest[];
|
|
13
|
+
}
|
|
14
|
+
export interface VerifyTest {
|
|
15
|
+
type: 'link' | 'webhook';
|
|
16
|
+
url: string;
|
|
17
|
+
passed: boolean;
|
|
18
|
+
details: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function createFunnel(apiKey: string, orgId: string, domain: string): Promise<Funnel>;
|
|
21
|
+
export declare function pushPage(apiKey: string, funnelId: string, slug: string, html: string): Promise<{
|
|
22
|
+
status: string;
|
|
23
|
+
key: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function verifyFunnel(apiKey: string, funnelId: string, opts?: {
|
|
26
|
+
html?: string;
|
|
27
|
+
slug?: string;
|
|
28
|
+
}): Promise<VerifyResult>;
|
|
29
|
+
export declare function listFunnels(apiKey: string): Promise<Funnel[]>;
|
|
30
|
+
export declare function getFunnel(apiKey: string, funnelId: string): Promise<Funnel>;
|
|
31
|
+
export declare function deleteFunnel(apiKey: string, funnelId: string): Promise<void>;
|