File size: 2,821 Bytes
9e7f815
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import axios from "axios";

// This client is used by the frontend to call the BFF (Backend-For-Frontend).
// It NEVER calls api.instantly.ai directly.

const apiClient = axios.create({
  baseURL: "/api",
  headers: {
    "Content-Type": "application/json",
  },
});

export const instantlyClient = {
  // Connection Status
  getConnectionStatus: () => apiClient.get("/org/connection-status").then((res) => res.data),

  // Campaigns
  getCampaigns: (params?: any) => apiClient.get("/campaigns", { params }).then((res) => res.data),
  createCampaign: (data: any) => apiClient.post("/campaigns", data).then((res) => res.data),
  getCampaign: (id: string) => apiClient.get(`/campaigns/${id}`).then((res) => res.data),
  updateCampaign: (id: string, data: any) => apiClient.patch(`/campaigns/${id}`, data).then((res) => res.data),
  deleteCampaign: (id: string) => apiClient.delete(`/campaigns/${id}`).then((res) => res.data),
  activateCampaign: (id: string) => apiClient.post(`/campaigns/${id}/activate`).then((res) => res.data),
  pauseCampaign: (id: string) => apiClient.post(`/campaigns/${id}/pause`).then((res) => res.data),
  getCampaignAnalytics: (id: string) => apiClient.get(`/campaigns/${id}/analytics`).then((res) => res.data),

  // Leads
  createLead: (data: any) => apiClient.post("/leads", data).then((res) => res.data),
  bulkImportLeads: (data: any[]) => apiClient.post("/leads/bulk", data).then((res) => res.data),
  searchLeads: (params?: any) => apiClient.get("/leads", { params }).then((res) => res.data),
  getLead: (id: string) => apiClient.get(`/leads/${id}`).then((res) => res.data),
  updateLead: (id: string, data: any) => apiClient.patch(`/leads/${id}`, data).then((res) => res.data),
  
  // Accounts
  getAccounts: () => apiClient.get("/accounts").then((res) => res.data),
  pauseAccount: (id: string) => apiClient.post(`/accounts/${id}/pause`).then((res) => res.data),
  resumeAccount: (id: string) => apiClient.post(`/accounts/${id}/resume`).then((res) => res.data),
  enableWarmup: () => apiClient.post("/accounts/enable-warmup").then((res) => res.data),
  disableWarmup: () => apiClient.post("/accounts/disable-warmup").then((res) => res.data),
  testVitals: (id: string) => apiClient.post(`/accounts/${id}/test-vitals`).then((res) => res.data),

  // Webhooks
  getWebhooks: () => apiClient.get("/webhooks").then((res) => res.data),
  testWebhook: (id: string) => apiClient.post(`/webhooks/${id}/test`).then((res) => res.data),
  getEvents: (params?: any) => apiClient.get("/events", { params }).then((res) => res.data),

  // Dashboard & Misc
  getDashboardSummary: () => apiClient.get("/dashboard/summary").then((res) => res.data),
  getWorkspace: () => apiClient.get("/workspace").then((res) => res.data),
  getAuditLogs: () => apiClient.get("/audit-logs").then((res) => res.data),
};