Giới thiệu

Đây là tài liệu dành cho lập trình viên các đơn vị khác kết nối đến Getfly CRM. Getfly API được xây dựng dựa trên RESTFull standards cho phép truy xuất truy xuất URLs từ trình duyệt.

Base URL

Mọi truy xuất đến Getfly API đều phải thông qua Base URL, Getfly cung cấp các phương thức submit qua http bao gồm POST, GET, PUT, DELETE

Base URL có dạng sau: https://tencongty.getflycrm.com

Hiện tại bạn có thể truy xuất API thông qua http hoặc https, nhưng chúng tôi khuyến nghị bạn nên sử dụng https để đảm bảo an toan về mặt dữ liệu

Content-Type & Accept header

Mặc định chúng tôi chỉ hỗ trợ JSON

Xác thực

Getfly cung cấp phương pháp xác thực qua API Key. Mỗi khách hàng sẽ được cấp 1 key gồm 30 chữ số có dạng 9HzV4BkrWu26Qj6YPIbRPLvvp2kkbQ, mỗi request đến Getfly đều phải kèm theo tham số này trong header. Để lấy được key này bạn phải đăng nhập vào tài khoản quản trị > Getfly CRM > Tích hợp > Getfly API Key

Ví dụ: X-API-KEY: 9HzV4BkrWu26Qj6YPIbRPLvvp2kkbQ

# Phương pháp xác thực
# API KEY sẽ được truyền trong header theo mỗi request
$ curl https://sandbox.getflycrm.com/api/v3/accounts \
    - H 'X-API-KEY: 9HzV4BkrWu26Qj6YPIbRPLvvp2kkbQ'

Khách hàng

Hiện tại Getfly lưu thông tin khách hàng thành 2 phần riêng biệt

Danh sách

// Dữ liệu trả về có dạng
{
"records": [
  {
    "account_id": "13989",
    "account_code": "KH13989",
    "account_name": "Cty ĐT và PT Nam Trường Giang",
    "address": "",
    "phone": "0436554788",
    "email": "",
    "website": "",
    "logo": "https://sample.getflycrm.com/assets/images/noavatar.png",
    "birthday": "0000-00-00",
    "description": "",
    "created_at": "2016-12-14 08:20:00",
    "account_type": "",
    "ngay_ky_hd": null,
    "truong_": null,
    "lop": null,
    "chang_bay_du_kien": null,
    "ngay_xuat_ve": null,
    "nhom_hang": null,
    "contacts": [
        {
            "contact_id": "14007",
            "first_name": "Nguyễn Văn Nam",
            "last_name": null,
            "phone_mobile": "0906221583",
            "email": "namtg@yahoo.com",
            "description": null,
            "title": null
        },
        {
            "contact_id": "14069",
            "first_name": "Trần Hoài Thu",
            "last_name": null,
            "phone_mobile": "",
            "email": null,
            "description": null,
            "title": null
        }
    ]
  },
  {}
],
"pagination": {
    "page": 2,
    "total_record": 629,
    "total_page": 13
}
}

Lấy thông tin các khách hàng có trong hệ thống

HTTP Request

GET /api/v3/accounts/

Query Parameters

Parameter Default Description
q blank Điều kiện tìm kiếm, có thể là tên khách hàng, địa chỉ, email, số điện thoại
limit 50 Giới hạn số bản ghi trả về
page 1 Trang hiện tại
custom_fields null Các điều kiện tìm kiếm theo các trường định nghĩa dữ liệu

Riêng điều kiện tìm kiếm theo custom field có đôi chút đặt biệt

Ví dụ: custom_fields[chang_bay_du_kien] = "like|hanoi"

Trong đó

Thêm mới

Dạng dữ liệu truyền sang

{
  "account": {
    "account_name": "GetFly CRM",
    "phone_office": "0944344333",
    "email": "contact@getfly.vn",
    "gender": 1,
    "billing_address_street": "107 Vĩnh Hưng, Hoàng Mai, Hà Nội",
    "birthday": "14/12/1984",
    "account_type": 1,
    "industry": "2,3",
    "country_id": 1,
    "province_id": 1,
    "district_id": 1
  },
  "contacts": [
    {
      "first_name": "Vũ Hoàng Duy",
      "email": "vuhoangduy@getflycrm.com",
      "phone_home": "0944344333",
      "title": "Giám đốc"
    },
    {
      "first_name": "Nguyễn Đình Đạt",
      "email": "nguyendinhdat@getflycrm.com",
      "phone_home": "",
      "title": "Nhân viên"
    }
  ],
  "referrer": {
    "utm_source": "https://getfly.vn",
    "utm_campaign": "GetflyWebsite"
  },
  "custom_fields": {
    "ngay_ky_hd": "14/12/1984",
    "so_thich": 41
  }
}

Thêm mới 1 khách hàng

HTTP Request

POST /api/v3/account/

Dữ liệu truyền sang gồm 3 phần

Mô tả thông tin khách hàng (account)

Parameter Type Default Require Description
account_name string yes Tên khách hàng
phone_office string Số điện thoại
email string Email
gender int Giới tính (1: Nữ, 2: Nam)
billing_address_street string Địa chỉ
birthday string Ngày sinh (d/m/Y)
account_type string Nhóm khách hàng (Nếu nhiều nhóm cách nhau bằng dấu ’,’)
industry int Ngành kinh doanh
country_id int Mã quốc gia
province_id int Mã tỉnh/ TP
district_id int Mã quận/ huyện

Mô tả người liên hệ (contacts)

Parameter Type Default Require Description
first_name string yes Tên người liên hệ
email string Email
phone_home string Số điện thoại liên hệ,
title string Chức vụ người liên hệ

Mô tả người định nghĩa dự liệu truyền sang (custom_fields)

Dữ liệu được truyền sang là một mảng dữ liệu bao gồm {key: value} Trong đó

Chi tiết 1 khách hàng

Phiên bản hỗ trợ: 4.0

HTTP Request

GET /api/v3/account/ID

Trong đó ID là ID của khách hàng trên hệ thống Getfly (account_id)

Mẫu dữ liệu trả về

{
    "info": {
        "account_id": "1",
        "account_code": "KH00001",
        "account_name": "Getfly CRM",
        "address": "11 Thái Hà",
        "phone": "0912345678",
        "email": "demo@getflycrm.com",
        "website": "getfly.vn",
        "birthday": "2012-12-22",
        "description": "Getfly CRM",
        "relation_id": "1",
        "revenue": "0",
        "account_type": "0",
        "created_at": "2021-07-14 14:05:23",
        "account_source": "0",
        "creator_name": "Getfly",
        "country_id": "1",
        "province_name": "Hà Nội",
        "district_name": "Đống Đa",
        "country_name": "Việt Nam",
        "industry_name": "Software",
        "account_source": "FB,Google"
    },
    "contacts": [
        {
            "contact_id": "1",
            "first_name": "Nguyen",
            "last_name": "Van A",
            "phone_mobile": "0912345678",
            "email": "demo@getflycrm.com",
            "description": "",
            "title": ""
        }
    ]
}

Dữ liệu truyền sang bao gồm:

Sửa khách hàng

Mẫu dữ liệu truyền sang

{
  "account": {
      "account_name": "Công ty TNHH Bình An",
      "phone_office": "0944344111",
      "email": "info@binhan.com",
      "billing_address_street": "15 Trần Bình Trọng",
      "account_type": 29,
      "industry_id": 2,
      "country_id": 1,
      "province_id": 1,
      "district_id": 1
  },
  "contacts": [
      {
          "contact_id": "156",
          "first_name": "Nguyễn Văn A",
          "phone_home": "0896411111",
          "email": "hihhi@gmail.com",
          "title": "Tổng giám đốc"
      },
      {
          "first_name": "Nguyễn Văn A",
          "phone_home": "089643333",
          "email": "haa@gmail.com",
          "title": "Sales manager"
      }
  ]
}

Mô tả

Sửa thông tin khách hàng đã tồn tại trên hệ thống

HTTP Request

PUT /api/v3/account/ID Trong đó ID là Mã khách hàng (account_id)

Query Parameters

Xóa khách hàng

Mô tả

Cho phép xóa một khách hàng khỏi hệ thống

HTTP Request

DELETE /api/v3/account/ID Trong đó ID là Mã khách hàng (account_id)

Phục hồi

Mô tả

Phục hồi một khách hàng đã bị xóa

HTTP Request

POST /api/v3/account/ID/restore/

Đổi người phụ trách

Mô tả

Đổi người phụ trách khách hàng

HTTP Request

POST /api/v3/account/ID/manager

Query Parameters

Parameter Default Description
account_manager 0 ID của người phụ trách mới

Nhóm khách hàng

[
    {
        "account_type_id": "1",
        "account_type_name": "KH đã ký hợp đồng",
        "description": "",
        "invalid": "0",
        "created_at": "2015-09-11 15:34:18",
        "updated_at": "2016-01-08 12:13:02",
        "parent_id": "125",
        "level": "2",
        "title": "|-- KH đã ký hợp đồng"
    },
    {
        "account_type_id": "2",
        "account_type_name": "500sme",
        "description": "",
        "invalid": "0",
        "created_at": "2015-10-29 10:05:36",
        "updated_at": "2015-10-29 10:05:36",
        "parent_id": "0",
        "level": "1",
        "title": "500sme"
    },
]

Mô tả

Lấy danh sách các nhóm khách hàng có trên hệ thống

HTTP Request

GET /api/v3/account/types

Query Parameters

Không có

Ngành kinh doanh

[
    {
        "industry_id": "1",
        "industry_name": "Công nghệ thông tin",
        "description": null,
        "invalid": "0",
        "created_at": "2016-01-14 19:55:16",
        "updated_at": "2016-01-14 19:55:16"
    },
    {
        "industry_id": "2",
        "industry_name": "Máy xây dựng",
        "description": null,
        "invalid": "0",
        "created_at": "2016-01-25 18:43:08",
        "updated_at": "2016-01-25 18:43:08"
    },
]

Ngành kinh doanh

Lấy toàn bộ ngành kinh doanh (không phân trang)

HTTP Request

GET /api/v3/account/industries

Query Parameters

Không có

Trạng thái đơn hàng

{
    "waiting": "0",
    "approval": "0",
    "cancel": "0"
}

Mô tả

Đếm số đơn hàng của 1 khách hàng theo các trạng thái

HTTP Request

GET /api/v3/account/ID/count_orders_status/

Định nghĩa dữ liệu

Mô tả

Các trường dữ liệu thêm dành cho module khách hàng

HTTP Request

GET /api/v3/account/custom_fields

Query Parameters

Không có

Mô tả dữ liệu trả về

Field Type Description
field_id int Id của trường dữ liệu được định nghĩa
field_htmltype tring Loại dữ liệu (input, textarea, select, checkbox, href)
field_name string Mã của trường định nghĩa, mã này là duy nhất
field_description tring Mô tả
options array Các options trả về trong trường hợp dạng dữ liệu là select

Đồng bộ khách hàng

{
    "data": [
        {
            "account_id": "1",
            "account_code": "BID00001",
            "account_name": "Công ty A",
            "description": "Công ty A",
            "email": "",
            "billing_address_street": "2132 Vân Cơ-Thành Phố Việt Trì",
            "phone_office": "09443443337",
            "logo": "https://xxxx.getflycrm.com/assets/images/noavatar.png",
            "website": null,
            "relation_id": "23",
            "birthday": null,
            "account_type": "1,2,3,4",
            "account_source": null,
            "sic_code": null,
            "country_id": "0",
            "province_id": "0",
            "district_id": "0",
            "contacts": [
                {
                    "contact_id": "1",
                    "first_name": "Tạ Quang Chung",
                    "last_name": null,
                    "phone_mobile": null,
                    "email": "taquangchung041@gmail.com",
                    "description": "",
                    "title": "Trưởng Phòng"
                }
            ],
            "custom_fields": {
                "thuong_hieu": "Biosky",
                "truong_dh": "",
                "ten_cong_ty": "",
                "email_khach_hang": "",
                "ngay_dat_hang": "",
            }
        },
        {
            "account_id": "1",
            "account_code": "KH0001",
            "account_name": "Công Ty Công Nghệ GetFly Việt Nam A",
            "description": "ss",
            "email": "tranquyet@live.com",
            "billing_address_street": "Linh Đàm - Hoàng Mai - Hà Nội",
            "phone_office": "09443443344",
            "logo": "https://xxxx.getflycrm.com/uploads/crm/account/logo/1/",
            "website": null,
            "relation_id": "8",
            "birthday": "2017-11-23",
            "account_type": "10",
            "account_source": "4",
            "sic_code": "111222333",
            "country_id": "1",
            "province_id": "0",
            "district_id": "0",
            "contacts": [
                {
                    "contact_id": "2",
                    "first_name": "Nguyễn Đình Đạt",
                    "last_name": null,
                    "phone_mobile": "0462627662",
                    "email": "nguyendinhdat@gmail.com",
                    "description": "",
                    "title": "Bang Chủ"
                },
                {
                    "contact_id": "3",
                    "first_name": "Tạ Quang Chung",
                    "last_name": null,
                    "phone_mobile": null,
                    "email": "taquangchung041@gmail.com",
                    "description": "",
                    "title": "Top"
                }
            ],
            "custom_fields": {
                "thuong_hieu": "",
                "truong_dh": "",
                "ten_cong_ty": "",
                "email_khach_hang": "",
                "ngay_dat_hang": "",
            }
        }
    ],
    "meta": {
        "limit": 20,
        "offset": 0,
        "total_record": "2"
    }
}

Mô tả

Lấy ra danh sách khách hàng thêm mới hoặc cập nhật từ thời gian chỉ định đến hiện tại

HTTP Request

GET api/v3/accounts/sync

Query Parameters

last_sync Thời gian đồng bộ cuối cùng tính theo unix time

Đồng bộ khách hàng đã xóa

[
    {
        "account_id": "1",
        "account_code": "KH166511"
    },
    {
        "account_id": "2",
        "account_code": "KH166502"
    }
]

Đồng bộ khách hàng đã xóa trong khoảng thời gian xác định đến hiện tại

HTTP Request

GET api/v3/accounts/deleted_ids

Query Parameters

last_sync Thời gian đồng bộ cuối cùng tính theo unix time, nếu không truyền vào sẽ lấy toàn bộ các khách hàng đã xóa

Mối quan hệ

[
    {
        "relation_id": "1",
        "relation_name": "Mới",
        "relation_code": "moi",
        "deleted_by": null,
        "created_at": "2019-07-30 14:04:35",
        "created_by": "0",
        "updated_by": "1",
        "updated_at": "2021-01-20 16:59:36",
        "deleted_at": null,
        "description": "NVIDIA nói rằng họ mua lại ARM là để phục vụ cho những sáng kiến mới, những dự án điện toán trong kỉ nguyên của AI"
    },
    {
        "relation_id": "40",
        "relation_name": "Mới b",
        "relation_code": "moi_b",
        "deleted_by": null,
        "created_at": "2020-06-24 13:34:24",
        "created_by": "4",
        "updated_by": "4",
        "updated_at": "2020-06-24 13:34:24",
        "deleted_at": null,
        "description": ""
    },
]

Mô tả

Lấy danh sách mối quan hệ khách hàng

HTTP Request

GET /api/v3/account/relations

Query Parameters

Không có

Chiến dịch - Cơ hội

Danh sách chiến dịch

[
    {
        "campaign_id": "1",
        "campaign_name": "Khách hàng mới",
        "token_api": "TwBIzvwSIg",
        "description": "",
        "start_date": "2016-01-18 12:04:27",
        "end_date": "2016-01-18 00:00:00"
    },
    {
        "campaign_id": "2",
        "campaign_name": "Khách hàng tiêm năng",
        "token_api": "AEtRpzFLdN",
        "description": "",
        "start_date": "2016-02-02 14:42:48",
        "end_date": "2016-02-02 00:00:00"
    }
]

Mô tả

Lấy ra danh sách các chiến dịch

HTTP Request

POST /api/v3/campaigns/

Query Parameters

Không có

Thêm mới cơ hội

{
    "account": {
        "account_name": "GetFly CRM",
        "phone_office": "0944344333",
        "email": "contact@getfly.vn11111111",
        "gender": 0,
        "billing_address_street": "107 Vĩnh Hưng, Hoàng Mai, Hà Nội",
        "birthday": "14/12/1984",
        "account_type": 1,
        "industry": "2,3"
    },
    "contacts": [
        {
            "first_name": "Vũ Hoàng Duy",
            "email": "vuhoangduy@getflycrm.com",
            "phone_mobile": "0944344333"
        },
        {
            "first_name": "Nguyễn Đình Đạt",
            "email": "nguyendinhdat@getflycrm.com",
            "phone_mobile": ""
        }
    ],

    "custom_fields": {
        "to_hop_mon_xet_tuyen": "To hop mon xet tuyen"
    },

    "opportunity": {
        "token_api": "TwBIzvwSIg",
        "user_id": "",
        "recipient": 1,
        "opportunity_status": 1
    },

    "referer": {
        "utm_source": "https://getfly.vn",
        "utm_campaign": "GetflyWebsite"
    }
}

Mô tả

Thêm mới một cơ hội vào chiến dịch

HTTP Request

POST /api/v3/opportunity/

Trạng thái cơ hội

[
    {
        "opportunity_status_id": "1",
        "opportunity_status_name": "Thông tin khách hàng"
    },
    {
        "opportunity_status_id": "2",
        "opportunity_status_name": "Tiếp cận khách hàng"
    },
    {
        "opportunity_status_id": "3",
        "opportunity_status_name": "Gặp mặt và chăm sóc"
    },
    {
        "opportunity_status_id": "4",
        "opportunity_status_name": "Chốt sales - Bán hàng"
    }
]

Mô tả

Lấy thông tin các bước trong một chiến dịch. Trong đó ID là Id của chiến dịch cần lấy thông tin

HTTP Request

GET api/v3/campaigns/ID/status

Danh sách cơ hội

{
    "data": [
        {
            "opportunity_id": "78",
            "opportunity_name": "Tuấn LinhTuấn Linh",
            "probability": "14",
            "opportunity_status": "5",
            "opportunity_status_name": "Thông tin khách hàng",
            "recipient": "37",
            "recipient_avatar": "db9e3fd3a1cfe81a1abe3e605e64f099.png",
            "recipient_contact_name": "Le Duy123",
            "recipient_role_name": "Trưởng phòng",
            "recipient_dept_name": "test 123",
            "time_created": "2019-08-09 18:09:55",
            "time_registed": "0",
            "responsible": "2",
            "creator_contact_name": "Tạ Quang Chung",
            "create_user_id": "2",
            "account_id": "102",
            "account_name": "Anh Tu 6",
            "phone_office": null,
            "account_email": null,
            "campaign_id": "2",
            "campaign_name": "Chiến dịch bán hàng ngày 05/08/2019"
        },
    ],
    "pagination": {
        "total_page": 1,
        "total_record": "1",
        "current_page": "1",
        "limit": "10"
    }
}

Mô tả

Lây danh sách cơ hội

HTTP Request

GET /api/v3/opportunity/list

Query Parameters

Parameter Default Description
campaign_id Id chiến dịch
opportunity_status Id trạng thái cơ hội trong chiến dịch
opportunity_status_name Tên trạng thái cơ hội trong chiến dịch (Điều kiện "like")
created_from Thời gian tạo cơ hội từ (d/m/Y)
created_to Thời gian tạo cơ hội đến (d/m/Y)
created_to Thời gian tạo cơ hội đến (d/m/Y)
p Trang
limit Số bản ghi trên trang

Đơn hàng

Danh sách

{
  "records": [
    {
        "order_id": "14219",
        "order_code": "DH14219",
        "order_type": "2",
        "amount": "1,000,000.0",
        "f_amount": "0.0",
        "discount": "0.0",
        "discount_amount": "0.0",
        "vat_amount": "0.0",
        "account_info": {
            "account_id": "22",
            "account_code": "KH4989988",
            "email": null,
            "phone": "09370399001",
            "address": "11 Thái Hà Đống Đa Hà Nội"
        },
        "order_date": "2022-02-22",
        "created_at": "2022-02-22 11:39:03",
        "updated_at": "2022-02-22 11:43:41",
        "status": "1",
        "assigned_user": "3",
        "assigned_name": "Nguyễn Trung Hiếu"
    }
  ],
  "pagination": {
      "limit": "10",
      "offset": "0",
      "total_record": "1"
  }
}

Mô tả

Lấy danh sách đơn hàng

HTTP Request

GET /api/v3/orders

Query Parameters

Parameter Default Description
order_type Loại đơn hàng (1 - Đơn hàng mua, 2 - Đơn hàng bán)
order_date_from Ngày đặt hàng từ (Y-m-d)
order_date_to Ngày đặt hàng đến (Y-m-d)
created_at_from Ngày tạo đơn hàng từ (Y-m-d)
created_at_to Ngày tạo đơn hàng đến (Y-m-d)
offset Vị trí bắt đầu lấy dữ liệu
limit Số bản ghi trên trang

Thêm mới

{
    "order_info": {
        "account_code": "KH0001",
        "account_name": "Anh Quyet",
        "account_address": "Linh Đàm - Hoàng Mai - Hà Nội",
        "account_email": "tranquyet@live.com",
        "account_phone": "0988686868",
        "order_date": "12/12/2016",
        "discount": 5,
        "discount_amount": 3200,
        "vat": 10,
        "vat_amount": 6080,
        "transport": 0,
        "transport_amount": 0,
        "installation": 0,
        "installation_amount": 0,
        "amount": 66880,
        "source_name": "Nguồn FB"
    },
    "products": [
        { "product_code": "ABCXYZ123", "product_name": "iPhone 7 Plus", "quantity": 1, "price": 10000, "product_sale_off": 10, "cash_discount": "1000" },
        { "product_code": "ABCXYZ456", "product_name": "iMac X20", "quantity": 2, "price": 30000, "product_sale_off": 0, "cash_discount": "5000" }
    ],
    "terms": [ "Thời gian giao hàng: ", "Địa điểm giao hàng: ", "Điều khoản khác"
    ]
}

Mô tả

Thêm mới đơn hàng bán

HTTP Request

POST /api/v3/orders/

Query Parameters

Parameter Default Description
order_info object Thông tin đơn hàng, được mô tả chi tiết phía dưới
products array Mảng chứa thông tin sản phẩm
terms array Điều kiện đơn hàng

Thông tin đơn hàng (order_info). Một đơn hàng có thể có nhiều sản phẩm thông tin mỗi sản phẩm bao gồm

Parameter Default Description
account_code Mã khác hàng, nếu không truyền sang là thêm mới
account_name Tên khách hàng
account_address Địa chỉ
account_email Email khách hàng
account_phone Số điện thoại
order_date Ngày đặt hàng (Định dạng d/m/Y)
discount Phần trăm chiết khấu trên đơn hàng
discount_amount Số tiền chiết khấu trên đơn hàng
vat VAT
vat_amount Số tiền VAT quy ra tiền
transport Phần trăm Phí vận chuyển
transport_amount Phí vận chuyển quy ra tiền
installation Phần trăm phí cài đặt
installation_amount Phí cài đặt quy ra tiền
amount Giá trị đơn hàng
source_name Nguồn đơn hàng (nhập text)

Thông tin sản phẩm (products)

Parameter Default Description
product_code Mã sản phẩm
product_name Tên sản phẩm
quantity Số lượng
price Giá tiền
product_sale_off Phần trăm chiết khấu sản phẩm, nếu không có để 0
cash_discount Số tiền chiết khấu (được tính từ % chiết khấu hoặc tự nhập)

Sửa đơn hàng

{
    "order_code": "ORDER001",
    "order_info": {
        "account_code": "KH0001",
        "account_name": "Anh Quyet",
        "account_address": "Linh Đàm - Hoàng Mai - Hà Nội",
        "account_email": "tranquyet@live.com",
        "account_phone": "0988686868",
        "order_date": "12/12/2016",
        "discount": 5,
        "discount_amount": 3200,
        "vat": 10,
        "vat_amount": 6080,
        "transport": 0,
        "transport_amount": 0,
        "installation": 0,
        "installation_amount": 0,
        "amount": 66880
    },
    "products": [
        { "product_id": 2179, "product_code": "ABCXYZ123", "product_name": "iPhone 7 Plus", "quantity": 1, "price": 10000, "product_sale_off": 10, "cash_discount": "1000" },
        { "product_id": 2180, "product_code": "ABCXYZ456", "product_name": "iMac X20", "quantity": 2, "price": 30000, "product_sale_off": 0, "cash_discount": "5000" }
    ],
    "terms": [ "Thời gian giao hàng: ", "Địa điểm giao hàng: ", "Điều khoản khác"
    ]
}

Mô tả

Sửa một đơn hàng đã tồn tại trên hệ thống

HTTP Request

PUT /api/v3/orders/

Duyệt đơn hàng

Mô tả

Cho phép duyệt đơn hàng dựa theo mã đơn hàng

HTTP Request

POST /api/v3/orders/approve

Query Parameters

Parameter Default Description
order_code Mã đơn hàng, bắt buộc

Thanh toán

Mẫu dữ liệu truyền sang

{
 "order_code": "DH0972",
 "payment_info": {
  "amount": 1000000000,
  "pay_date": "02/05/2016",
  "description": "Thanh toan lan 1"
 }
}

Mô tả

Thanh toán trực tiếp trên đơn hàng, đối với trường hợp không dùng chức năng Quỹ

HTTP Requests

POST /api/v3/orders/paid

Query Parameters

Parameter Default Description
order_code Mã đơn hàng, bắt buộc
payment_info Thông tin thanh toán, bao gồm - amount: Số tiền phải thanh toán - pay_date: Ngày thanh toán - description: Nội dung mô tả

Thanh toán đơn hàng theo phiếu thu - chi

{
    "user_id": 3, //Người tạo phiếu
    "order_code": "DH14398", //Mã đơn hàng
    "payment_info": {
        "amount": 100000, //Số tiền thanh toán
        "pay_date": "20/12/2022", //Ngày yêu cầu
        "fund_id": 3, //Id phiếu
        "sheet_description": "Mô tả", //Mô tả
        "method_id": 1, //Hình thức thanh toán
        "payment_slip_receiver": "Nguyễn Trung Hiếu" //Người nộp tiền / người tiếp nhập
    }
}

Mô tả

Thanh toán đơn hàng theo phiếu thu - chi

HTTP Request

POST /api/v3/orders/paid_via_fund

Query Parameters

Parameter Default Description
user_id Người tạo phiếu
order_code Mã đơn hàng, bắt buộc
payment_info Thông tin thanh toán, bao gồm - amount: Số tiền phải thanh toán - pay_date: Ngày thanh toán - description: Nội dung mô tả

Sản phẩm

Danh mục

[
    {
        "category_id": "1",
        "category_code": "IPhone",
        "category_name": "Apple IPhone",
        "description": null,
        "is_default": "0",
        "parent_id": "0",
        "level": "1",
        "lft": "2",
        "rgt": "5"
    },
    {
        "category_id": "2",
        "category_code": "IPhoneX",
        "category_name": "Apple Iphone X",
        "description": "Điện thoại apple",
        "is_default": "0",
        "parent_id": "2",
        "level": "2",
        "lft": "3",
        "rgt": "4"
    }
]

Mô tả

Lấy ra tất cả danh mục sản phẩm không phân trang

HTTP Request

GET /api/v3/products/categories/

Query Parameters

Parameter Default Description
parent_id 0 Lọc theo danh mục cha
level Lọc các danh mục cùng cấp

Danh sách sản phẩm

{
    "records": [
        {
            "product_id": "4371",
            "category_id": null,
            "origin_id": null,
            "unit_id": "0",
            "manufacturer_id": null,
            "services": "0",
            "saleoff_price": "0",
            "created_at": "11-11-2017",
            "technique": "",
            "updated_at": "11-11-2017",
            "featured_image": null,
            "product_code": "NAM004",
            "product_name": "Áo vest nam màu xanh trắng",
            "last_active": "0000-00-00 00:00:00",
            "description": null,
            "cover_price": "1299000",
            "discount": "0",
            "price_wholesale": null,
            "discount_wholesale": null,
            "price_online": null,
            "discount_online": null,
            "price_average_in": "0",
            "discount_in": null,
            "short_description": null,
            "product_vat": "0",
            "images": [],
            "thumbnail_file": "https://sample.getflycrm.com/assets/images/no-product.jpg"
        },
        {
            "product_id": "4366",
            "category_id": null,
            "origin_id": null,
            "unit_id": null,
            "manufacturer_id": null,
            "services": null,
            "saleoff_price": "0",
            "created_at": "03-11-2017",
            "technique": "",
            "updated_at": "03-11-2017",
            "featured_image": null,
            "product_code": "1",
            "product_name": "Tượng Quan Công",
            "last_active": "0000-00-00 00:00:00",
            "description": "",
            "cover_price": "52000000",
            "discount": null,
            "price_wholesale": null,
            "discount_wholesale": null,
            "price_online": "51000000",
            "discount_online": null,
            "price_average_in": null,
            "discount_in": null,
            "short_description": null,
            "product_vat": null,
            "images": [
                {
                    "file_id": "68",
                    "file_name": "13315413_504567209748552_8962201007053306221_n.jpg",
                    "thumbnail_file": "13315413_504567209748552_8962201007053306221_n.jpg",
                    "file_type": "1",
                    "product_id": "4366",
                    "thumb_src": "https://sample.getflycrm.com/uploads/crm/product/4366/thumbs/13315413_504567209748552_8962201007053306221_n.jpg",
                    "origin_src": "https://sample.getflycrm.com/uploads/crm/product/4366/13315413_504567209748552_8962201007053306221_n.jpg"
                }
            ],
            "thumbnail_file": "https://sample.getflycrm.com/uploads/crm/product/4366/thumbs/13315413_504567209748552_8962201007053306221_n.jpg"
        },
        {
            "product_id": "4352",
            "category_id": null,
            "origin_id": null,
            "unit_id": "0",
            "manufacturer_id": null,
            "services": "0",
            "saleoff_price": "0",
            "created_at": "18-10-2017",
            "technique": "",
            "updated_at": "18-10-2017",
            "featured_image": null,
            "product_code": "SPA012",
            "product_name": "Sản phẩm SPA0012",
            "last_active": "0000-00-00 00:00:00",
            "description": null,
            "cover_price": null,
            "discount": "0",
            "price_wholesale": null,
            "discount_wholesale": null,
            "price_online": null,
            "discount_online": null,
            "price_average_in": "0",
            "discount_in": null,
            "short_description": null,
            "product_vat": "0",
            "images": [],
            "thumbnail_file": "https://sample.getflycrm.com/assets/images/no-product.jpg"
        }
    ],
    "pagination": {
        "page": 1,
        "limit": 20,
        "total_page": 219,
        "total_records": 4369
    }
}

Mô tả

Trả về danh sách sản phẩm có phân trang theo các điều kiện lọc

HTTP Request

GET /api/v3/products/

Query Parameters

Parameter Default Description
category_id 0 Lọc theo danh mục sản phẩm
grap false Nếu lọc theo danh mục sản phẩm thì tham số này cho phép lấy cả sản phẩm thuộc danh mục con của danh mục cần tìm kiếm
saleoff false Lọc theo các sản phẩm có khuyến mại (có giá khuyến mại)
product_name Tìm kiếm theo tên sản phẩm
product_code Tìm theo mã sản phẩm

Thêm mới sản phẩm

Cấu trúc dữ liệu truyền sang

{
  "product_code": "SP00001",
  "product_name": "Sản phẩm thêm mới từ API",
  "description": "Đây là mô tả dài",
  "short_description": "Đây là mô tả ngắn",
  "cover_price": "200000",
  "discount": 5,
  "price_wholesale": 160000,
  "discount_wholesale": 10,
  "price_online": 185000,
  "discount_online": 0,
  "saleoff_price": 180000,
  "unit_id": 2,
  "category_id": 4,
  "origin_id": 5,
  "manufacturer_id": 5,
  "custom_fields": {
    "thuong_hieu": "Den tu nhat ban",
    "bao_hanh": "10 nam",
    "cong_xuat": "200"
  }
}

Mô tả

Thêm mới 1 sản phẩm

HTTP Request

POST /api/v3/products

Query Parameters

Parameter Type Default Require Description
product_code string Mã sản phẩm, nếu không truyền sang sẽ tự động thêm mới, không tự động check trùng
product_name string yes Tên sản phẩm
description string Mô tả sản phẩm
short_description string Mô tả ngắn về sản phẩm
cover_price float Giá bán, đây là giá mặc định của sản phẩm
discount int Chiết khấu sản phẩm. Ví dụ 5%, 10%
price_wholesale float Giá bán buôn, nếu không có không cần truyền sang
discount_wholesale int Chiết khấu bán buôn
price_online float Giá bán online
discount_online int Chiết khấu online
saleoff_price float Giá bán khi sale off
unit_id int Đơn vị tính, vui lòng tham khảo tại API về đơn vị tính
category_id int Danh mục sản phẩm, vui lòng tham khảo API về danh mục sản phẩm
origin_id int Nguồn gốc xuất xứ của sản phẩm
manufacturer_id int Hãng sản xuất
custom_fields array Các thông tin định nghĩa thêm về sản phẩm, cấu trúc dữ liệu truyền sang vui lòng tham khảo ở ví dụ

Chi tiết sản phẩm

Ví dụ dữ liệu trả về

{
    "data": {
        "product_id": 4414,
        "product_name": "TFX150",
        "product_code": "TFX150",
        "description": "Xe Máy TFX150",
        "short_description": "Xe máy Yamaha TFX150",
        "cover_price": 2500000,
        "discount": 5,
        "price_wholesale": 0,
        "discount_wholesale": 0,
        "price_average_in": 0,
        "discount_in": 0,
        "price_online": 0,
        "discount_online": 0,
        "saleoff_price": 0,
        "category_id": 1,
        "category_name": "Xe gắn máy",
        "origin_id": 1,
        "origin_name": "Nhật bản",
        "unit_id": "12",
        "unit_name": "Chiếc"
    },
    "images": [
        "https://xxx.getflycrm.com/uploads/crm/product/image_1.jpg",
        "https://xxx.getflycrm.com/uploads/crm/product/image_2.jpg",
        "https://xxx.getflycrm.com/uploads/crm/product/image_3.jpg"
    ],
    "attributes": [
        {
            "Dung tích động cơ": "150 cm2"
        },
        {
            "Màu sắc": "Xanh, Xám, Đỏ"
        },
        {
            "Kiểu xe": "Nam"
        }
    ],
    "attachments": [
        "https://xxx.getflycrm.com/uploads/crm/product/tl1.pdf"
    ]
}

HTTP Request

GET /api/v3/products/ID

Trong đó ID là id của sản phẩm

Đơn vị tính

[
    {
        "unit_id": 1,
        "unit_name": "Chiếc"
    },
    {
        "unit_id": 2,
        "unit_name": "Cái"
    },
    {
        "unit_id": 3,
        "unit_name": "Kg"
    },
    {
        "unit_id": 4,
        "unit_name": "Lọ"
    },
]

Mô tả

Lấy danh sách các đơn vị tính liên quan đến sản phẩm

HTTP Request

GET /api/v3/products/units

Nguồn gốc xuất xứ

[
    {
        "origin_id": 1,
        "origin_name": "Việt Nam"
    },
    {
        "origin_id": 2,
        "origin_name": "Nhật bản"
    },
    {
        "origin_id": 3,
        "origin_name": "Hàn Quốc"
    }
]

Mô tả

Lấy ra nguồn gốc xuất xứ của sản phẩm

HTTP Request

GET api/v3/products/origins

Định nghĩa dữ liệu

[
    {
        "field_id": "1",
        "field_htmltype": "select",
        "field_name": "tinh_trang",
        "field_description": "Tình trạng",
        "options": [
            {
                "field_id": "1",
                "list_option_id": "1",
                "list_value": "Đã cho thuê"
            },
            {
                "field_id": "1",
                "list_option_id": "2",
                "list_value": "Trống"
            }
        ]
    },
    {
        "field_id": "2",
        "field_htmltype": "textinput",
        "field_name": "dien_tich",
        "field_description": "Diện tích",
        "options": []
    }
]

Mô tả

Lấy ra tất cả các trường dữ liệu định nghĩa thêm liên quan đến sản phẩm

HTTP Request

GET /api/v3/products/custom_fields

Hãng sản xuất

[
    {
        "manufacturer_id": "1",
        "manufacturer_name": "Yamaha",
        "description": "Yamaha"
    },
    {
        "manufacturer_id": "2",
        "manufacturer_name": "Honda",
        "description": "Honda"
    }
]

Mô tả

Danh sách các hãng sản phẩm

HTTP Request

GET /api/v3/products/manufacturers

Kiểm tra Tồn kho

Lấy ra số lượng tồn kho theo mã sản sản phẩm hoặc theo id sản phẩm Tham số tìm kiếm

Parameter Default Description
product_id 0 Lọc theo ID sản phẩm
product_code Lọc theo mã sản phẩm

Tổng sản phẩm tồn

GET /api/v3/products/quantity

Tổng sản phẩm tồn theo kho

GET /api/v3/products/store_quantity

Tồn kho theo sản phẩm

{
    "data": [
        {
            "product_id": 21,
            "product_code": "SP0021",
            "product_name": "sữa rửa mặt",
            "cover_price": 800,
            "quantity": 1,
            "cover_image": "https://xxx.getflycrm.com/assets/images/no-product.jpg"
        },
        {
            "product_id": 40,
            "product_code": "SP0040",
            "product_name": "Mặt nạ nóng",
            "cover_price": 1,
            "quantity": 998,
            "cover_image": "https://xxx.getflycrm.com/assets/images/no-product.jpg"
        }
    ],
    "meta": {
        "offset": 0,
        "limit": 20,
        "total_record": 210
    }
}

Mô tả

Trả về danh sách các sản phẩm tồn tại tất cả các kho

HTTP Request

GET /api/v3/products/inventory

Query Parameters

Parameter Type Default Require Description
limit int 20 Số bản ghi trả về trên mỗi lần request
offset int 0 Vị trí bắt đầu của bản ghi cần lấy

Quỹ

Danh sách quỹ

[
    {
        "fund_id": "1",
        "fund_parent_id": "0",
        "fund_title": "Quỹ mẫu Công ty Getfly CRM",
        "lvl": "1",
        "financial_account": null
    }
]

Mô tả

Lấy danh sách quỹ

HTTP Request

GET /api/v3/fund

Chi tiết phiếu thu - phiếu chi theo mã phiếu

{
    "sheet_info": {
        "sheet_id": "963",
        "sheet_code": "PT/2023-04/0615",
        "sheet_date": "03/04/2023",
        "pay_date": "01/01/1970 08:00:00",
        "create_user": "3",
        "approval_user": "0",
        "request_id": "0",
        "sheet_source": "1",
        "sheet_payment": "1",
        "sheet_amount": "450000",
        "fund_id": "2",
        "fund_receive_id": null,
        "sheet_type": "1",
        "sheet_status": "0",
        "sheet_title": "Nhập đơn hàng DH17960",
        "sheet_description": "",
        "employee_get_money": "3",
        "payment_slip_receiver": "",
        "customer_get_money": "0",
        "account": "",
        "reciaccount": "",
        "budget_id": "0",
        "budget_detail_id": "0"
    },
    "sheet_orders": [
        {
            "order_id": "17960",
            "amount": "450000",
            "sheet_amount": "450000",
            "account_id": "0",
            "order_code": "DH17960",
            "real_amount": "450000.000000",
            "f_amount": "0.000000",
            "order_date": "03/04/2023"
        }
    ]
}

Mô tả

Lấy chi tiết phiếu thu - phiếu chi theo mã

HTTP Request

GET /api/v3/fund/sheet

Query Parameters

Parameter Default Description
sheet_code Mã phiếu

Chi tiết phiếu theo id phiếu

{
    "sheet_info": {
        "sheet_id": "963",
        "sheet_code": "PT/2023-04/0615",
        "sheet_date": "03/04/2023",
        "pay_date": "01/01/1970 08:00:00",
        "create_user": "3",
        "approval_user": "0",
        "request_id": "0",
        "sheet_source": "1",
        "sheet_payment": "1",
        "sheet_amount": "450000",
        "fund_id": "2",
        "fund_receive_id": null,
        "sheet_type": "1",
        "sheet_status": "0",
        "sheet_title": "Nhập đơn hàng DH17960",
        "sheet_description": "",
        "employee_get_money": "3",
        "payment_slip_receiver": "",
        "customer_get_money": "0",
        "account": "",
        "reciaccount": "",
        "budget_id": "0",
        "budget_detail_id": "0"
    },
    "sheet_orders": [
        {
            "order_id": "17960",
            "amount": "450000",
            "sheet_amount": "450000",
            "account_id": "0",
            "order_code": "DH17960",
            "real_amount": "450000.000000",
            "f_amount": "0.000000",
            "order_date": "03/04/2023"
        }
    ]
}

Mô tả

Lấy chi tiết phiếu thu - phiếu chi id

HTTP Request

GET /api/v3/fund/sheet/{{sheet_id}}

Tổng đài điện thoại

Lấy số máy nhánh của người phụ trách khách hàng

{
    "extension": "1010"
}

Mô tả

Trả về số máy nhánh của người phụ trách khách hàng từ số điện thoại gọi tới, nếu không có ai phụ trách khách hàng hoặc chưa tồn tại khách hàng này thì số máy nhánh sẽ trả về null

HTTP Request

GET /api/v3/callcenter/extension?caller_number=0944xxxxx

Query Parameters

Parameter Type Default Description
caller_number string Số điện thoại gọi tới

Ticket

Danh mục hỗ trợ

[
  {
    "cate_id": "1",
    "cate_name": "Hỗ trợ về sản phẩm",
    "description": "Hỗ trợ về sản phẩm",
    "created_at": "2020-01-21 10:26:38"
  },
  {
    "cate_id": "2",
    "cate_name": "Hỗ trợ về API",
    "description": "",
    "created_at": "2020-05-15 11:04:47"
  },
  {
    "cate_id": "3",
    "cate_name": "Hỗ trợ Automation",
    "description": "Hỗ trợ Automation",
    "created_at": "2020-06-18 14:35:07"
  }
]

Mô tả

Lấy ra danh sách các chủ đề cần hỗ trợ, sử dụng trong việc tạo ticket

HTTP Request

GET /api/v3/tickets/categories

Query Parameters

Không có

Tạo mới 1 ticket

{
  "title": "Tao moi khachhang",
  "content": "Vui long ho tro",
  "cate_id": "2",
  "phone": "0948384583",
  "name": "Duy VH"
}

Mô tả

HTTP Request

POST /api/v3/tickets

Query Parameters

Parameter Type Default Require Description
title string Tiêu đề cần hỗ trợ
content string Nội dung cần hỗ trợ (html support)
cate_id int yes Danh mục hỗ trợ (tham khảo api danh mục hỗ trợ)
phone string yes Số điện thoại khách hàng cần hỗ trợ, nếu số điện thoại trong hệ thống chưa tồn tại thì tạo thành khách hàng mới
name string Tên khách hàng, trong trường hợp khách hàng chưa tồn tại sẽ lấy thông tin này để tạo mới

Người dùng

Danh sách người dùng

[
    {
        "id": "1",
        "name": "Nguyễn Đình Đạt",
        "dept_id": "2",
        "dept_name": "Ban giám đốc 总部",
        "email": "testmail1@gmail.com",
        "mobile": ""
    }
]

Mô tả

Lấy danh sách người dùng trên hệ thống

HTTP Request

GET /api/v3/users

Webhook

Phiên bản hỗ trợ: 4.0

Hiện tại hệ thống chỉ hỗ trợ các sự kiện sau:

Dữ liệu trả về có dạng sau

{
  "uid":"f3f95949-0de2-480a-98af-2fafd0f493f6",
  "event":"customer.created",
  "data":{
    "account_id":10462
  },
  "domain":"demo.getflycrm.com"
}

Cấu hình

Danh sách quốc gia

[
  {
      "country_id": "1",
      "country_code": "84",
      "country_name": "Việt Nam",
      "order": "0",
      "international_name": "VN"
  },
  {
      "country_id": "2",
      "country_code": null,
      "country_name": "Yemen",
      "order": "0",
      "international_name": null
  },
  {
      "country_id": "3",
      "country_code": null,
      "country_name": "India",
      "order": "0",
      "international_name": null
  }
]

Mô tả

Lấy ra danh sách các quốc gia

HTTP Request

GET /api/v3/configs/countries

Query Parameters

Không có

Danh sách tỉnh/TP

[
  {
      "province_id": "1",
      "province_name": "HÀ NỘI"
  },
  {
      "province_id": "2",
      "province_name": "HỒ CHÍ MINH"
  },
  {
      "province_id": "3",
      "province_name": "HẢI PHÒNG"
  },
  {
      "province_id": "4",
      "province_name": "ĐÀ NẴNG"
  }
]

Mô tả

HTTP Request

GET /api/v3/configs/provinces

Query Parameters

Parameter Type Default Require Description
country_id int yes Mã quốc gia

Danh sách quận/ huyện

[
  {
      "district_id": "1",
      "district_name": "Quận Ba Đình"
  },
  {
      "district_id": "17",
      "district_name": "Huyện Ba Vì"
  },
  {
      "district_id": "18",
      "district_name": "Huyện Phúc Thọ"
  },
  {
      "district_id": "19",
      "district_name": "Huyện Thạch Thất"
  },
  {
      "district_id": "20",
      "district_name": "Huyện Quốc Oai"
  },
  {
      "district_id": "21",
      "district_name": "Huyện Chương Mỹ"
  }
]

Mô tả

HTTP Request

GET /api/v3/configs/districts

Query Parameters

Parameter Type Default Require Description
province_id int yes Mã tỉnh/ thành phố

Errors

GetFly API sử dụng error codes đi kèm dưới đây:

Error Code Ý nghĩa
200 Thành công
201 Thêm mới thành công
400 Bad request
401 Không xác thực yêu cầu, có thể do cung cấp API Key không hợp lệ
403 Forbidden - Request Method not accepted
404 Not found - Không tìm thấy tài nguyên yêu cầu
500 Internal Server Error