DEV Community

Cover image for Cách Sử Dụng API Make (Integromat)
Sebastian Petrus
Sebastian Petrus

Posted on • Originally published at apidog.com

Cách Sử Dụng API Make (Integromat)

TÓM TẮT

API của Make (trước đây là Integromat) cho phép các nhà phát triển tự động hóa quy trình làm việc, quản lý các kịch bản (scenarios) và thực hiện các tích hợp theo chương trình. Nó sử dụng xác thực OAuth 2.0 và khóa API, các điểm cuối RESTful cho kịch bản, thực thi, webhook và nhóm, với giới hạn tốc độ từ 60-600 yêu cầu mỗi phút tùy theo gói dịch vụ. Bài viết này hướng dẫn thiết lập xác thực, quản lý kịch bản, kích hoạt webhook, giám sát thực thi và triển khai tự động hóa ở môi trường production.

Dùng thử Apidog ngay hôm nay

Giới thiệu

Make (Integromat) xử lý hơn 2 tỷ hoạt động mỗi tháng cho hơn 1 triệu người dùng tại 100+ quốc gia. Nếu bạn là developer cần xây dựng công cụ tự động hóa, quản lý workflow khách hàng hoặc tích hợp với trên 1000 ứng dụng, API Make là thành phần bắt buộc để tự động hóa có khả năng mở rộng.

Hiện trạng phổ biến: Agency quản lý >50 automation khách hàng mất 15-25 giờ/tuần cho việc cập nhật kịch bản, giám sát thực thi, báo cáo thủ công. Một tích hợp API Make tốt sẽ tự động hóa triển khai kịch bản, theo dõi thực thi, xử lý lỗi, xuất báo cáo white-label.

Hướng dẫn này sẽ giúp bạn từng bước tích hợp API Make: xác thực OAuth 2.0 và API key, quản lý kịch bản, webhook, thực thi, nhóm, chiến lược triển khai production. Kết thúc bài, bạn sẽ sở hữu một tích hợp Make sẵn sàng chạy thực tế.

💡 Apidog giúp kiểm thử tích hợp API nhanh chóng: kiểm thử endpoint Make, xác thực luồng OAuth, test response thực thi, debug automation trên một workspace. Import API spec, mô phỏng response, chia sẻ test scenario cho team dễ dàng.

Make API là gì?

Make cung cấp một API RESTful để quản lý workflow automation qua mã. API hỗ trợ:

  • CRUD kịch bản
  • Thực thi kịch bản (kích hoạt thủ công)
  • Lịch sử và giám sát thực thi
  • Quản lý Webhook
  • Quản lý nhóm/người dùng
  • Quản lý kết nối/ứng dụng
  • Cài đặt tổ chức/workspace

Các tính năng chính

Tính năng Mô tả
API RESTful Các endpoint dựa trên JSON
OAuth 2.0 + API key Xác thực linh hoạt
Webhooks Real-time execution notification
Rate limit 60-600 yêu cầu/phút tùy gói
Quản lý kịch bản Đầy đủ thao tác CRUD
Kiểm soát thực thi Start/dừng/giám sát thực thi
API nhóm Quản lý user/quyền

Các gói dịch vụ Make và quyền API

Gói Quyền API Giới hạn tốc độ Phù hợp cho
Miễn phí Giới hạn 60/phút Kiểm thử, học hỏi
Core API đầy đủ 120/phút Doanh nghiệp nhỏ
Pro API đầy đủ + ưu tiên 300/phút Nhóm phát triển
Teams API đầy đủ + quản trị 600/phút Agency, doanh nghiệp
Enterprise Giới hạn tùy chỉnh Tùy chỉnh Tổ chức lớn

Tổng quan kiến trúc API

API endpoint chính:

https://api.make.com/api/v2/
Enter fullscreen mode Exit fullscreen mode

Các phiên bản API

Phiên bản Trạng thái Trường hợp sử dụng
v2 Hiện tại Tích hợp mới
v1 Ngừng hỗ trợ Legacy, cần migrate

Bắt đầu: Thiết lập xác thực

Bước 1: Tạo tài khoản Make

  1. Truy cập Make.com
  2. Đăng ký tài khoản
  3. Vào Settings > Developer settings
  4. Tạo thông tin xác thực API

Bước 2: Chọn phương thức xác thực

Phương thức Phù hợp cho Bảo mật
API Key Tích hợp nội bộ, script Cao (lưu an toàn)
OAuth 2.0 Ứng dụng multi-tenant Cao hơn

Bước 3: Lấy API Key (nhanh nhất)

  1. Vào Settings > Developer settings
  2. Nhấn Create API key
  3. Sao chép và lưu trữ an toàn
# .env
MAKE_API_KEY="your_api_key_here"
MAKE_ORGANIZATION_ID="your_org_id"
Enter fullscreen mode Exit fullscreen mode

Bước 4: Thiết lập OAuth 2.0 (ứng dụng đa người thuê)

  1. Vào Settings > Developer settings > OAuth apps
  2. Chọn Create OAuth app
  3. Cấu hình redirect URI
  4. Lấy client credentials
const MAKE_CLIENT_ID = process.env.MAKE_CLIENT_ID;
const MAKE_CLIENT_SECRET = process.env.MAKE_CLIENT_SECRET;
const MAKE_REDIRECT_URI = process.env.MAKE_REDIRECT_URI;

const getAuthUrl = (state) => {
  const params = new URLSearchParams({
    client_id: MAKE_CLIENT_ID,
    redirect_uri: MAKE_REDIRECT_URI,
    scope: 'read write execute',
    state: state,
    response_type: 'code'
  });
  return `https://www.make.com/oauth/authorize?${params.toString()}`;
};
Enter fullscreen mode Exit fullscreen mode

Bước 5: Trao đổi mã lấy access token

const exchangeCodeForToken = async (code) => {
  const response = await fetch('https://www.make.com/oauth/token', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: new URLSearchParams({
      grant_type: 'authorization_code',
      client_id: MAKE_CLIENT_ID,
      client_secret: MAKE_CLIENT_SECRET,
      redirect_uri: MAKE_REDIRECT_URI,
      code: code
    })
  });
  const data = await response.json();
  return {
    accessToken: data.access_token,
    refreshToken: data.refresh_token,
    expiresIn: data.expires_in
  };
};

// Xử lý callback:
app.get('/oauth/callback', async (req, res) => {
  const { code, state } = req.query;
  try {
    const tokens = await exchangeCodeForToken(code);
    // Lưu tokens an toàn
    await db.integrations.create({
      userId: req.session.userId,
      accessToken: tokens.accessToken,
      refreshToken: tokens.refreshToken,
      tokenExpiry: Date.now() + (tokens.expiresIn * 1000)
    });
    res.redirect('/success');
  } catch (error) {
    console.error('OAuth error:', error);
    res.status(500).send('Authentication failed');
  }
});
Enter fullscreen mode Exit fullscreen mode

Bước 6: Thực hiện các call API đã xác thực

const MAKE_BASE_URL = 'https://api.make.com/api/v2';

const makeRequest = async (endpoint, options = {}) => {
  const apiKey = options.useOAuth ? await getOAuthToken() : process.env.MAKE_API_KEY;
  const response = await fetch(`${MAKE_BASE_URL}${endpoint}`, {
    ...options,
    headers: {
      'Authorization': `Token ${apiKey}`,
      'Content-Type': 'application/json',
      ...options.headers
    }
  });
  if (!response.ok) {
    const error = await response.json();
    throw new Error(`Make API Error: ${error.message}`);
  }
  return response.json();
};

// Ví dụ lấy danh sách kịch bản
const scenarios = await makeRequest('/scenarios');
console.log(`Found ${scenarios.data.length} scenarios`);
Enter fullscreen mode Exit fullscreen mode

Quản lý kịch bản

Liệt kê kịch bản

const listScenarios = async (filters = {}) => {
  const params = new URLSearchParams({
    limit: filters.limit || 50,
    offset: filters.offset || 0
  });
  if (filters.folder) params.append('folder', filters.folder);
  const response = await makeRequest(`/scenarios?${params.toString()}`);
  return response;
};

// Usage
const scenarios = await listScenarios({ limit: 100 });
scenarios.data.forEach(scenario => {
  console.log(`${scenario.name} - ${scenario.active ? 'Active' : 'Paused'}`);
  console.log(`  Last run: ${scenario.lastRunDate || 'Never'}`);
});
Enter fullscreen mode Exit fullscreen mode

Lấy chi tiết kịch bản

const getScenario = async (scenarioId) => {
  const response = await makeRequest(`/scenarios/${scenarioId}`);
  return response;
};

// Usage
const scenario = await getScenario('12345');
console.log(`Name: ${scenario.name}`);
console.log(`Modules: ${scenario.modules.length}`);
console.log(`Schedule: ${scenario.schedule?.cronExpression || 'Manual'}`);
Enter fullscreen mode Exit fullscreen mode

Tạo kịch bản mới

const createScenario = async (scenarioData) => {
  const scenario = {
    name: scenarioData.name,
    blueprint: scenarioData.blueprint,
    active: scenarioData.active || false,
    priority: scenarioData.priority || 1,
    maxErrors: scenarioData.maxErrors || 3,
    autoCommit: scenarioData.autoCommit || true,
    description: scenarioData.description || ''
  };
  const response = await makeRequest('/scenarios', {
    method: 'POST',
    body: JSON.stringify(scenario)
  });
  return response;
};

// Usage
const newScenario = await createScenario({
  name: 'Lead Sync to CRM',
  blueprint: {
    modules: [
      { id: 1, app: 'webhooks', action: 'customWebhook', parameters: {} },
      { id: 2, app: 'salesforce', action: 'createRecord', parameters: {} }
    ],
    connections: [{ from: 1, to: 2 }]
  },
  active: true,
  description: 'Sync webhook leads to Salesforce'
});
console.log(`Scenario created: ${newScenario.id}`);
Enter fullscreen mode Exit fullscreen mode

Cập nhật kịch bản

const updateScenario = async (scenarioId, updates) => {
  const response = await makeRequest(`/scenarios/${scenarioId}`, {
    method: 'PATCH',
    body: JSON.stringify(updates)
  });
  return response;
};

// Pause scenario
await updateScenario('12345', { active: false });

// Update schedule
await updateScenario('12345', {
  schedule: {
    cronExpression: '0 */6 * * *',
    timezone: 'America/New_York'
  }
});
Enter fullscreen mode Exit fullscreen mode

Xóa kịch bản

const deleteScenario = async (scenarioId) => {
  await makeRequest(`/scenarios/${scenarioId}`, {
    method: 'DELETE'
  });
  console.log(`Scenario ${scenarioId} deleted`);
};
Enter fullscreen mode Exit fullscreen mode

Quản lý thực thi

Kích hoạt thực thi kịch bản

const executeScenario = async (scenarioId, inputData = null) => {
  const response = await makeRequest(`/scenarios/${scenarioId}/execute`, {
    method: 'POST',
    body: inputData ? JSON.stringify(inputData) : undefined
  });
  return response;
};

// Run không có input
const execution = await executeScenario('12345');
console.log(`Execution started: ${execution.id}`);

// Run có input
const executionWithData = await executeScenario('12345', {
  lead: {
    email: 'prospect@example.com',
    name: 'John Doe',
    company: 'Acme Corp'
  }
});
Enter fullscreen mode Exit fullscreen mode

Lấy lịch sử thực thi

const getExecutionHistory = async (scenarioId, filters = {}) => {
  const params = new URLSearchParams({
    limit: filters.limit || 50,
    from: filters.from,
    to: filters.to,
    status: filters.status // 'success', 'error', 'running'
  });
  const response = await makeRequest(`/scenarios/${scenarioId}/executions?${params.toString()}`);
  return response;
};

// Lấy execution thất bại 24h gần nhất
const failedExecutions = await getExecutionHistory('12345', {
  from: new Date(Date.now() - 86400000).toISOString(),
  status: 'error',
  limit: 100
});
failedExecutions.data.forEach(exec => {
  console.log(`Execution ${exec.id}: ${exec.error?.message}`);
});
Enter fullscreen mode Exit fullscreen mode

Lấy chi tiết thực thi

const getExecution = async (executionId) => {
  const response = await makeRequest(`/executions/${executionId}`);
  return response;
};

// Usage
const execution = await getExecution('98765');
console.log(`Status: ${execution.status}`);
console.log(`Duration: ${execution.duration}ms`);
console.log(`Modules executed: ${execution.modulesExecuted}`);
Enter fullscreen mode Exit fullscreen mode

Dừng thực thi đang chạy

const stopExecution = async (executionId) => {
  await makeRequest(`/executions/${executionId}`, {
    method: 'DELETE'
  });
  console.log(`Execution ${executionId} stopped`);
};
Enter fullscreen mode Exit fullscreen mode

Quản lý Webhook

Tạo Webhook

const createWebhook = async (webhookData) => {
  const webhook = {
    name: webhookData.name,
    scenarioId: webhookData.scenarioId,
    type: 'custom',
    hookType: 'HEAD',
    security: { type: 'none' }
  };
  const response = await makeRequest('/webhooks', {
    method: 'POST',
    body: JSON.stringify(webhook)
  });
  return response;
};

// Usage
const webhook = await createWebhook({
  name: 'Lead Capture Webhook',
  scenarioId: '12345',
  type: 'custom',
  hookType: 'HEAD',
  security: { type: 'none' }
});
console.log(`Webhook URL: ${webhook.url}`);
Enter fullscreen mode Exit fullscreen mode

Liệt kê Webhook

const listWebhooks = async () => {
  const response = await makeRequest('/webhooks');
  return response;
};

// Usage
const webhooks = await listWebhooks();
webhooks.data.forEach(webhook => {
  console.log(`${webhook.name}: ${webhook.url}`);
});
Enter fullscreen mode Exit fullscreen mode

Xóa Webhook

const deleteWebhook = async (webhookId) => {
  await makeRequest(`/webhooks/${webhookId}`, {
    method: 'DELETE'
  });
  console.log(`Webhook ${webhookId} deleted`);
};
Enter fullscreen mode Exit fullscreen mode

Quản lý nhóm và người dùng

Liệt kê thành viên nhóm

const listTeamMembers = async (organizationId) => {
  const response = await makeRequest(`/organizations/${organizationId}/users`);
  return response;
};

// Usage
const members = await listTeamMembers('org-123');
members.data.forEach(member => {
  console.log(`${member.email} - ${member.role}`);
});
Enter fullscreen mode Exit fullscreen mode

Thêm thành viên nhóm

const addTeamMember = async (organizationId, email, role) => {
  const response = await makeRequest(`/organizations/${organizationId}/users`, {
    method: 'POST',
    body: JSON.stringify({
      email: email,
      role: role // 'viewer', 'builder', 'manager', 'admin'
    })
  });
  return response;
};

// Usage
await addTeamMember('org-123', 'newuser@example.com', 'builder');
Enter fullscreen mode Exit fullscreen mode

Cập nhật vai trò người dùng

const updateUserRole = async (organizationId, userId, newRole) => {
  await makeRequest(`/organizations/${organizationId}/users/${userId}`, {
    method: 'PATCH',
    body: JSON.stringify({ role: newRole })
  });
  console.log(`User ${userId} role updated to ${newRole}`);
};
Enter fullscreen mode Exit fullscreen mode

Các vai trò người dùng

Vai trò (Role) Quyền
Viewer Xem kịch bản, không chỉnh sửa
Builder Tạo/chỉnh sửa kịch bản
Manager Quản lý nhóm, thanh toán
Admin Toàn quyền truy cập tổ chức

Giới hạn tốc độ

Tìm hiểu giới hạn tốc độ

Gói Yêu cầu/phút Burst Limit
Miễn phí 60 100
Core 120 200
Pro 300 500
Teams 600 1000
Enterprise Tùy chỉnh Tùy chỉnh

Tiêu đề giới hạn tốc độ

Header Mô tả
X-RateLimit-Limit Số yêu cầu tối đa mỗi phút
X-RateLimit-Remaining Số yêu cầu còn lại
X-RateLimit-Reset Số giây cho đến khi đặt lại

Triển khai xử lý giới hạn tốc độ

const makeRateLimitedRequest = async (endpoint, options = {}, maxRetries = 3) => {
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
    try {
      const response = await makeRequest(endpoint, options);
      const remaining = response.headers.get('X-RateLimit-Remaining');
      if (remaining < 10) {
        console.warn(`Low rate limit: ${remaining} remaining`);
      }
      return response;
    } catch (error) {
      if (error.message.includes('429') && attempt < maxRetries) {
        const delay = Math.pow(2, attempt) * 1000;
        console.log(`Rate limited. Retrying in ${delay}ms...`);
        await new Promise(resolve => setTimeout(resolve, delay));
      } else {
        throw error;
      }
    }
  }
};
Enter fullscreen mode Exit fullscreen mode

Danh sách kiểm tra triển khai production

Trước khi go-live, hãy đảm bảo:

  • [ ] Dùng API key cho nội bộ, OAuth cho tích hợp khách hàng
  • [ ] Lưu thông tin xác thực an toàn (DB mã hóa)
  • [ ] Xử lý rate limit & queue request
  • [ ] Thiết lập giám sát và cảnh báo thực thi
  • [ ] Cấu hình thông báo lỗi (email, Slack)
  • [ ] Retry logic cho thực thi thất bại
  • [ ] Ghi log toàn diện
  • [ ] Backup/xuất các kịch bản quan trọng

Các trường hợp sử dụng thực tế

Quản lý khách hàng của Agency

Bài toán: Agency marketing quản lý 100+ automation khách hàng.

  • Khó khăn: Update kịch bản thủ công trên nhiều tài khoản.
  • Giải pháp: Dashboard trung tâm dùng Make API.
  • Kết quả: Tiết kiệm 70% thời gian, triển khai đồng nhất.

Triển khai chính:

  • OAuth multi-account
  • Triển khai kịch bản hàng loạt
  • Báo cáo usage khách hàng

Xử lý đơn hàng Thương mại điện tử

Bài toán: Cửa hàng online tự động fulfillment.

  • Khó khăn: Nhập đơn vào kho thủ công, dễ sai sót.
  • Giải pháp: Kịch bản Make kích hoạt bằng Webhook.
  • Kết quả: Không còn nhập liệu thủ công, độ chính xác 99.9%.

Triển khai chính:

  • Webhook từ Shopify tới Make
  • Kịch bản xử lý đơn, cập nhật kho
  • Retry logic khi lỗi

Kết luận

Make API cung cấp khả năng tự động hóa workflow toàn diện. Ghi nhớ:

  • API key cho nội bộ, OAuth 2.0 cho ứng dụng đa người thuê
  • Đầy đủ CRUD cho kịch bản, thực thi, webhook
  • Quản lý nhóm mạnh mẽ
  • Rate limit thay đổi theo gói (60-600 req/phút)
  • Giám sát thực thi là bắt buộc ở production
  • Apidog giúp kiểm thử API, cộng tác nhóm thuận tiện

Làm cách nào để xác thực với Make API?

Sử dụng API key từ Developer settings cho tích hợp nội bộ, hoặc OAuth 2.0 cho ứng dụng đa người thuê.

Tôi có thể kích hoạt kịch bản theo chương trình không?

Có, dùng endpoint /scenarios/{id}/execute để start kịch bản manual, truyền data tùy chọn.

Giới hạn tốc độ của Make là gì?

Tùy gói: 60 req/phút (miễn phí) đến 600 req/phút (Teams/Enterprise).

Làm cách nào để lấy nhật ký thực thi?

Gọi /scenarios/{id}/executions để truy vấn lịch sử thực thi, có filter ngày/trạng thái.

Tôi có thể tạo webhook thông qua API không?

Có, endpoint /webhooks cho phép tạo, liệt kê, xóa webhook cho kịch bản.

Top comments (0)