API Reference

Pancake API documentation

Get Messages

GET https://pages.fm/api/public_api/v1/pages/[:page_id]/conversations/[:conversation_id]/messages

Message list

Query Parameters

NameTypeDescription

current_count

number

Used to index the position to get the message.

When this is missing while calling the CPI, the system will return the latest 20 messages.

If you continue to attach current_count as 25, the system will return 25 older messages from the 20th position.

page_access_token*

string

Page token (Can be generated in Setting -> Tool)

customer_id*

string

Customer's ID (From get conversation API below)

conversation_id*

string

Conversation ID to get the message(From get conversation API below)

page_id*

string

Page ID to get the data

{
  "messages": [
    {
      "attachments": [], // Message's media
      "conversation_id": "256469571178082_3100878013328342", // Conversation ID
      "from": { // customer's information
        "email": "3100878013328342@facebook.com",
        "id": "3100878013328342",
        "name": "Quyết Nguyễn"
      },
      "has_phone": false, // Contain phone number or not
      "id": "m_Ec_f7RJrKyJlRKXVdEYW5gWswhac17zNH0kIRGkMGhuBkqMkamKpUyJSpemXfRB0kULuVY8WA-ATEthHwher9g", // Message ID
      "inserted_at": "2023-12-26T08:44:29.000000", // Message creation time
      "is_hidden": false, // is hidden - only for comment
      "is_livestream_order": null, 
      "is_parent": false, // is the parent comment - only for comment
      "is_parent_hidden": false, // the parent comment has been hidden - only for comment
      "is_removed": false, // has been deleted or not
      "like_count": null, // Total like - only for comment
      "message": "asda", // Message content
      "page_id": "256469571178082", // Page ID
      "phone_info": [], // Phone number information in the message
      "type": "INBOX", // message type [INBOX, COMMEMNT, RATING]
    }
  ],
  "success": true
}

Get Conversations

GET https://pages.fm/api/v1/pages/[:page_id]/conversations?tags="ALL"&current_count=[:current_count]&access_token=[:access_token]

Query Parameters

NameTypeDescription

page_access_token*

string

Page token (can be created in Setting -> Tools)

until*

timestamp

End time (type unix in seconds).

The time should be less or equal to 1 month.

since*

timestamp

Start time (type unix in seconds).

page_id*

string

Page ID

page_number*

number

Current page (minimal 1)

order_by

String

Conversation order (default inserted_at) : inserted_at: creation time

updated_at: updated time

tags

String

Tag ID that needs to be filtered. Eg: 1,2,3,4

{
  "conversations": [{
      "page_id": "wa_c.us@84328290781",
      "customer_id": "72bea3ea-722a-4e33-b415-2b2281f44724",
      "assignee_histories": [{
          "conversation_id": "wa_84328290781@c.us_62818166016@c.us",
          "inserted_at": "2021-08-26T06:29:56",
          "payload": {
              "added_users": [{
                  "email": "phamdongtx@gmail.com",
                  "fb_id": "1831989023699268",
                  "id": "82be33ea-729a-4e83-be15-2b7c83f34724",
                  "name": "Pham Dong"
              }],
              "deleted_users": []
          }
      }],
      "type": "INBOX",
      "inserted_at": "2021-08-26T06:29:56",
      "tags": [],
      "recent_phone_numbers": [],
      "customers": [{
          "avatar_url": "84328290781@c.us_1621224114",
          "fb_id": "wa_c.us@62818166016",
          "id": "d8526c77-832a-425c-8aee-e5d7dfcd7cd0",
          "name": "Babywearit (+62 81 816 6016)"
      }],
      "has_phone": false,
      "tag_histories": [],
      "post_id": null,
      "id": "wa_84328290781@c.us_62818166016@c.us",
      "last_sent_by": {
          "avatar_url": "84328290781@c.us_1621224114",
          "id": "wa_c.us@62818166016",
          "name": "Babywearit (+62 81 816 6016)",
          "phone_number": "62818166016"
      },
  }],
  "success": true,
  "total": 1
}

Chú thích
    "conversations": Conversation list
        Chi tiết hội thoại:
            "page_id": page id
            "customer_id": customer id 
            "assignee_histories": conversation assignment history
            "type": message type (INBOX, COMMENT, RATING)
            "inserted_at": Creation time
            "tags": Current attached tag
            "recent_phone_numbers": conversation's phone number
            "customers": Customer's information
            "has_phone": has phone or not
            "tag_histories": tag history
            "post_id": post ID (if comment)
            "last_sent_by": Sender
            "current_assign_users": current assigned user
            "ad_ids": ad_id list
    "total": Total conversation

Send comment

POST https://pages.fm/api/v1/pages/[:page_id]/conversations/[:coversation_id]/messages?access_token=[:access_token]

In order to send responses of comments

Query Parameters

NameTypeDescription

access_token

string

The customer's token chain is provided from Pancake

Headers

NameTypeDescription

coversation_id

string

ID conversation you want to answer

page_id

string

ID your page

Request Body

NameTypeDescription

message

string

Comment content

parent_id

string

ID comment want to reply

action

string

To post comments need to set a value reply_comment

{
    "id": "1599241350234224_1599318880226471",
    "success": true
}

Send private reply

POST https://pages.fm/api/v1pages/[:page_id]/conversations/[:conversation_id]/messages?access_token=[:access_token]

In order to send inbox message from comments You can send only one (1) inbox message for one (1) comment. Following Facebook Policy, inbox message from comment is limited inside 7 days window

Query Parameters

NameTypeDescription

access_token

string

The customer's token chain is provided from Pancake

Headers

NameTypeDescription

page_id

string

ID your page

conversation_id

string

ID Conversation contains comments

Request Body

NameTypeDescription

post_id

string

ID the post contains that comment

message_id

string

ID comment you want to message from that comment

action

string

To send messages from comments need to set a value private_replies

message

string

Reply content

{
    "id": "m_5js02va40Z7Z5wUp2aPdbdmaxJ0QidmArUGPAjhej4U3LfA7WGMI62EL5qtJE_1FRXMtVlbDLd9dmmaIR5-ZAw",
    "success": true
}

Send inbox

POST https://pages.fm/api/v1/pages/[:page_id]/conversations/[:conversation_id]/messages?access_token=[:access_token]

Send message to customers

Query Parameters

NameTypeDescription

access_token

string

The customer's token chain is provided from Pancake

Headers

NameTypeDescription

page_id

string

ID your fanpage

conversation_id

string

ID conversation

Request Body

NameTypeDescription

name

string

attachment name

mime_type

string

attachment mime type(image,...)

content_url

string

attachment url (https://i.ibb.co/mzh7ck8/alaska-beo-acef3fcb1cc541a79048f4bbafed71c8-grande.png)

attachmentType

string

attachment type (PHOTO)

action

string

To send messages, a value needs to be set reply_inbox

message

string

Message content

thread_key

string

key of conversation want to send message

{
    "id":"m_kigIWuq85mIn7ijgUznKbdmaxJ0QidmArUGPAjhej4VUI3t48g39Ixhgpz3QTulmD42DFW386WgoS6DJ3EnbNw",
    "success":true
}

New customer statistics

GET https://pages.fm/api/v1/statistics/partner/customers?page_ids=[:page_ids]&date_range=[:date_range]&group_by=[:group_by]&access_token=[:access_token]

Statistics of new customers over time

Path Parameters

NameTypeDescription

group_by

string

Optional data grouping method. Pass one of the following strings: - Day(default): Returns data by date - hour: returns data in an hour - Page_if: Returns data by pages

access_token

string

The customer's token chain is provided from Pancake

date_range

string

The time period needs statistics For example: July 20, 2020 - August 20, 2020

page_ids

string

ID of one or more pages eg page_id1, page_d2, .. (page_id1, page_id2 is your page ID)

no group_by
{
    "data":[
        {"date":"2020-08-27","new_customer_count":0,"new_page_inbox_count":1,"new_phone_number_count":0,"phone_number_count":0},
        {"date":"2020-08-24","new_customer_count":0,"new_page_inbox_count":2,"new_phone_number_count":0,"phone_number_count":0},
        {"date":"2020-08-12","new_customer_count":4,"new_page_inbox_count":3,"new_phone_number_count":0,"phone_number_count":0}
    ],
    "success":true
}

group_by: page_id
{
    "data": {
        "103205717747769": [
            {"date":"2020-08-12","new_customer_count":0,"new_page_inbox_count":1,"new_phone_number_count":0,"phone_number_count":0}
        ],
        "110699180573884":[
            {"date":"2020-08-27","new_customer_count":0,"new_page_inbox_count":2,"new_phone_number_count":0,"phone_number_count":0}
        ]
    },
    "success":true
}

group_by: hour
{
    "data":[
        {"date":"2020-08-12T16:00:00","new_customer_count":0,"new_page_inbox_count":1,"new_phone_number_count":0,"phone_number_count":0},
        {"date":"2020-08-12T17:00:00","new_customer_count":0,"new_page_inbox_count":2,"new_phone_number_count":0,"phone_number_count":0},
        {"date":"2020-08-12T18:00:00","new_customer_count":4,"new_page_inbox_count":3,"new_phone_number_count":0,"phone_number_count":0}
    ],
    "success":true
}

Customer phone number statistics

GET https://pages.fm/api/v1/statistics/partner/customers?page_ids=[:page_ids]&date_range=[:date_range]&access_token=[:access_token]

Path Parameters

NameTypeDescription

page_number

string

Data retrieval page

access_token

string

Customer's token chain provided from Pancake

page_ids

string

ID of 1 or more pages for example: page_id1, page_id2, ... (page_ids1, page_id2 is your page ID)

date_range

string

Time interval to be statistic For example: July 20, 2019 - August 20, 2019

Last updated