# FCM Integration API

## Token Subscription API

API này cho phép client push Firebase App Token vào PangoCDP.

### Information

<table data-header-hidden><thead><tr><th width="198"></th><th></th></tr></thead><tbody><tr><td>Endpoint</td><td><a href="https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/%7BcdpAppId%7D/tokens/_subscribe">https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/{</a><a href="https://svc.mydatalakes.com/dhub-ip/api/v1.0/zmapps/%7BcdpAppId%7D/zoa/_flw_get">cdpAppId</a><a href="https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/%7BcdpAppId%7D/tokens/_subscribe">}/tokens/_subscribe</a>  </td></tr><tr><td>Method</td><td>POST</td></tr><tr><td>Header</td><td><ul><li>content-type: application/json</li><li>reqId=fcm************* (Pango provides)</li><li>cdpKey= (Pangpo provides)</li></ul></td></tr><tr><td>Path Parameter</td><td>{<a href="https://svc.mydatalakes.com/dhub-ip/api/v1.0/zmapps/%7BcdpAppId%7D/zoa/_flw_get">cdpAppId</a>}: CDP Application ID (Pango provides)</td></tr><tr><td>Payload</td><td><pre class="language-javascript"><code class="lang-javascript">[
 {
 "clientAppId": "loyalty-app-android",
"token": "firebase-app-token"
<strong> }
</strong>]
</code></pre></td></tr></tbody></table>

### Payload

<table><thead><tr><th width="163">Field</th><th width="116">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td>clientAppId</td><td>Yes</td><td>Client App Id / Name.</td><td><p>Loyalty Android</p><p>Loyalty for MS</p></td></tr><tr><td>token</td><td>Yes</td><td>Firebase App Token</td><td><br></td></tr><tr><td>loginUId</td><td>Yes</td><td>Login User ID</td><td>email@bytetech.io</td></tr><tr><td>loginUIdField</td><td>Yes</td><td><p>Field type of Login User ID. Valid values:</p><ul><li>CustomerId</li><li>Email</li><li>Phone</li><li>UserId</li><li>Cid</li></ul></td><td>Email</td></tr><tr><td>userId</td><td><br></td><td>If loginUIdField=UserId, then require userId.</td><td>dee88</td></tr><tr><td>customerId</td><td><br></td><td>If loginUIdField=CustomerId, then require customerId.</td><td>C09999991</td></tr><tr><td>phone</td><td><br></td><td>If loginUIdField=Phone, then require PHONE.</td><td>0909999999</td></tr><tr><td>email</td><td><br></td><td>If loginUIdField=Email, then require EMAIL.</td><td>email@bytetech.io</td></tr><tr><td>cid</td><td><br></td><td>If loginUIdField=UserId, then require CID.</td><td>2125546.967878</td></tr><tr><td>uniqueId</td><td><br></td><td>Related to Device. For example, In iOs: identifier for vendor</td><td><br></td></tr><tr><td>deviceInfo</td><td><br></td><td>A List of values with prefix</td><td>[ “os: iOs”, “osv: 12.0”]</td></tr><tr><td>extParams</td><td><br></td><td>A List of values with prefix if more information needs to be tracked</td><td>[ “value1”, “...”]</td></tr></tbody></table>

#### Sample Request

<table data-header-hidden><thead><tr><th width="254"></th><th></th></tr></thead><tbody><tr><td>loginUIdField=Phone</td><td><pre class="language-javascript"><code class="lang-javascript">{
  "clientAppId": "loyalty-app-android",
  "token": "firebase-app-token",
  "loginUId": "0909999999",
  "loginUIdField": "Phone",
  "userId": null,
  "customerId": null,
  "phone": "0909999999",
  "email": null,
  "cid": null,
  "uniqueId": null
  "deviceInfo": [
    "manf: VALUE",
    "brand: VALUE",
    "model: VALUE",
    "os: VALUE",
    "osv: VALUE"
  ],
  "extParams": [
    "key1: VALUE1"
  ]
}
</code></pre></td></tr><tr><td>loginUIdField=CustomerId</td><td><pre class="language-javascript"><code class="lang-javascript">{
  "clientAppId": "loyalty-app-android",
  "token": "firebase-app-token",
  "loginUId": "C09999999",
  "loginUIdField": "CustomerId",
  "userId": null,
  "customerId": "C09999999",
  "phone": null,
  "email": null,
  "cid": null,
  "uniqueId": null
  "deviceInfo": [
    "manf: VALUE",
    "brand: VALUE",
    "model: VALUE",
    "os: VALUE",
    "osv: VALUE"
  ],
  "extParams": [
    "key1: VALUE1"
  ]
}
</code></pre></td></tr></tbody></table>

### Response

<table><thead><tr><th width="196">Code</th><th>Value</th></tr></thead><tbody><tr><td><mark style="color:red;">400</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
  "success": false,
  "message": "REQ Id is incorrect.",
  "errorCode": "NOT_FOUND"
}

// Missing fields
{
"success": false,
"message": "Some required fields are missing: clientAppId",
"errorCode": "MISSING\_INFO"
} </code></pre></td></tr><tr><td><mark style="color:red;">401</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
"success": false,
"message": "Unauthorized!",
"errorCode": "REQ\_ID\_NOT\_MATCHED"
} </code></pre></td></tr><tr><td><mark style="color:green;">200</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
"success": true,
"took": 98
} </code></pre></td></tr></tbody></table>

## FCM Token Unsubscribed

API này cho phép client delete Firebase App Token trong PangoCDP

### Information

<table data-header-hidden><thead><tr><th width="217"></th><th></th></tr></thead><tbody><tr><td>Endpoint</td><td><a href="https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/%7BcdpAppId%7D/tokens/_subscribe">https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/{</a><a href="https://svc.mydatalakes.com/dhub-ip/api/v1.0/zmapps/%7BcdpAppId%7D/zoa/_flw_get">cdpAppId</a><a href="https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/%7BcdpAppId%7D/tokens/_subscribe">}/tokens/_unsubscribe</a>  </td></tr><tr><td>Method</td><td>POST</td></tr><tr><td>Header</td><td><ul><li>content-type: application/json</li><li>reqId=fcm************* (Pango provides)</li><li>cdpKey= (Pango provides)</li></ul></td></tr><tr><td>Path Parameter</td><td>{<a href="https://svc.mydatalakes.com/dhub-ip/api/v1.0/zmapps/%7BcdpAppId%7D/zoa/_flw_get">cdpAppId</a>}: CDP Application ID (Pango provides)</td></tr><tr><td>Payload</td><td><pre class="language-javascript"><code class="lang-javascript"><strong>{
</strong>  "clientAppId": "loyalty-app-android",
  "token": "firebase-app-token"
}
</code></pre></td></tr></tbody></table>

### Payload

<table><thead><tr><th>Field</th><th width="117">Required</th><th width="203">Description</th><th>Example</th></tr></thead><tbody><tr><td>clientAppId</td><td>Yes</td><td>Client App Id / Name.</td><td><p>Loyalty Android</p><p>Loyalty for MS</p></td></tr><tr><td>token</td><td>Yes</td><td>Firebase App Token</td><td><br></td></tr></tbody></table>

#### Sample Request

```javascript
{
  "clientAppId": "loyalty-app-android",
  "token": "firebase-app-token"
}
```

### Response

<table><thead><tr><th width="201">Code</th><th>Value</th></tr></thead><tbody><tr><td><mark style="color:red;">400</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
  "success": false,
  "message": "REQ Id is incorrect.",
  "errorCode": "NOT_FOUND"
}

// Missing fields
{
"success": false,
"message": "Some required fields are missing: clientAppId",
"errorCode": "MISSING\_INFO"
} </code></pre></td></tr><tr><td><mark style="color:red;">401</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
"success": false,
"message": "Unauthorized!",
"errorCode": "REQ\_ID\_NOT\_MATCHED"
} </code></pre></td></tr><tr><td><mark style="color:green;">200</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
"success": true,
"took": 98
} </code></pre></td></tr></tbody></table>

## FCM Message Structure

To push messages to Devices / Topic based on Firebase, PangoCDP provides a tool to build templates, then JSON messages to push to clients.

### Structure

```javascript
{
  "message": {
    "notification": {
      "title": "Notification MMV - Xpander 2022 - New ",
      "body": "Notification Text"
    },
    "data": {
      "cdpAck": "fcm**********",
      "title": "Notification MMV - Xpander 2022 - New",
      "body": "Notification Text",
      "imageUrl": "https://",
      "key01": "/promotion"
    },
    "android": {
      "ttl": "86400s",
      "priority": "normal",
      "notification": {
        "click_action": ""
      }
    },
    "apns": {
      "headers": {
        "ttl": 86400,
        "apns-priority": "10"
      },
      "payload": {
        "aps": {
          "category": ""
        }
      }
    }
  }
}
```

<figure><img src="https://lh7-us.googleusercontent.com/KMXYpov6a8Qio4lr3HTwERcOaXK4rxuue_eIAIVo6CDqVzG3h4qlbnBNhB1qMHnUrmWuxMT08ulvc0tzHN_PZnEoKTv02iuFEZdqN9QPT0-Ps30m0zw-tcgaW-dVpnNhNra5lyIX-v2piqXrvw3DvnE" alt="" width="563"><figcaption><p>Sample message</p></figcaption></figure>

<table><thead><tr><th width="179">Key</th><th>Description</th></tr></thead><tbody><tr><td>cdpAck</td><td><p>This value is used for acknowledgement. </p><p>Clients that received the messages will push back PangoCDP this value to notify that the messages are delivered successfully.</p></td></tr><tr><td>android</td><td><br></td></tr><tr><td>apns</td><td><br></td></tr></tbody></table>

## Acknowledge Event API

This API allows clients to push “Acknowledge Messages” back to PangoCDP. With each message delivered by Firebase, PangoCDP needs to know its status like: received, clicked.

### Information

<table data-header-hidden><thead><tr><th width="208"></th><th></th></tr></thead><tbody><tr><td>Endpoint</td><td><a href="https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/%7BcdpAppId%7D/tokens/_subscribe">https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/{</a><a href="https://svc.mydatalakes.com/dhub-ip/api/v1.0/zmapps/%7BcdpAppId%7D/zoa/_flw_get">cdpAppId</a><a href="https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/%7BcdpAppId%7D/tokens/_subscribe">}/events/_logs</a></td></tr><tr><td>Method</td><td>POST</td></tr><tr><td>Header</td><td><ul><li>content-type: application/json</li><li>reqId=fcm************* (Pango provides)</li><li>cdpKey= (Pango provides)</li></ul></td></tr><tr><td>Path Parameter</td><td>{<a href="https://svc.mydatalakes.com/dhub-ip/api/v1.0/zmapps/%7BcdpAppId%7D/zoa/_flw_get">cdpAppId</a>}: CDP Application ID (Pango provides)</td></tr><tr><td>Payload</td><td><pre class="language-javascript"><code class="lang-javascript">{
  "clientAppId": "loyalty-app-android",
  "eventName": "received",
  "cdpMsgId": "fcmxxxxxxxxxxxxxxx",
  "extParams": [
  ]
}
</code></pre></td></tr></tbody></table>

### Payload

<table><thead><tr><th width="144">Field</th><th width="119">Required</th><th width="310">Description</th><th>Example</th></tr></thead><tbody><tr><td>clientAppId</td><td>Yes</td><td>Client App Id / Name.</td><td><p>Loyalty Android</p><p>Loyalty for MS</p></td></tr><tr><td>eventName</td><td>Yes</td><td><p>Event name from Client sent back:</p><ul><li><strong>received</strong>: The message is received by a device</li><li><strong>clicked</strong>:  User clicked on the message on Phones</li></ul></td><td>received</td></tr><tr><td>cdpMsgId</td><td>Yes</td><td><p>When pangCDP pushes a message to a device, a key: “<a data-footnote-ref href="#user-content-fn-1"><strong>cdpAck</strong></a>” will be appended to the data message.</p><p><br>The client sends the value of “<a data-footnote-ref href="#user-content-fn-1"><strong>cdpAck</strong></a>” back to PangoCDP along with “eventName” to inform CDP that the message has been delivered successfully.</p></td><td>fcm...</td></tr><tr><td>extParams</td><td><br></td><td>A List of values with prefix if more information needs to be tracked</td><td>[ “value1”, “...”]</td></tr></tbody></table>

#### Sample Request

```javascript
{
  "clientAppId": "loyalty-app-android",
  "eventName": "received",
  "cdpMsgId": "fcmxxxxxxxxxxxxxxx",
  "extParams": [
     "key1: VALUE1"
  ]
}
```

### Response

<table><thead><tr><th width="150">Code</th><th>Value</th></tr></thead><tbody><tr><td><mark style="color:red;">400</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
  "success": false,
  "message": "REQ Id is incorrect.",
  "errorCode": "NOT_FOUND"
}

// Missing fields
{
"success": false,
"message": "Some required fields are missing: clientAppId",
"errorCode": "MISSING\_INFO"
} </code></pre></td></tr><tr><td><mark style="color:red;">401</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
"success": false,
"message": "Unauthorized!",
"errorCode": "REQ\_ID\_NOT\_MATCHED"
} </code></pre></td></tr><tr><td><mark style="color:green;">200</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
"success": true,
"took": 98
} </code></pre></td></tr></tbody></table>

## Push Original Message / In-house Message API

This API allows clients to push “Original Messages” or “In-house Messages” to PangoCDP.

### Information

<table data-header-hidden><thead><tr><th width="204"></th><th></th></tr></thead><tbody><tr><td>Endpoint</td><td><a href="https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/%7BcdpAppId%7D/tokens/_subscribe">https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/{</a><a href="https://svc.mydatalakes.com/dhub-ip/api/v1.0/zmapps/%7BcdpAppId%7D/zoa/_flw_get">cdpAppId</a><a href="https://svc.mydatalakes.com/dhub-i/api/v1.0/fcm/%7BcdpAppId%7D/tokens/_subscribe">}/events/_original</a></td></tr><tr><td>Method</td><td>POST</td></tr><tr><td>Header</td><td><ul><li>content-type: application/json</li><li>reqId=fcm************* (Pango provides)</li><li>cdpKey= (Pango provides)</li></ul></td></tr><tr><td>Path Parameter</td><td>{<a href="https://svc.mydatalakes.com/dhub-ip/api/v1.0/zmapps/%7BcdpAppId%7D/zoa/_flw_get">cdpAppId</a>}: CDP Application ID (Pango provides)</td></tr><tr><td>Payload</td><td><pre class="language-javascript"><code class="lang-javascript">[{
  "clientAppId": "loyalty-app-android",
  "templateId": "template id",
  "fcmToken": "firebase token",
  "msgId": "message id in your system",
  "fmsgId": "message id from firebase",
  "eventAt": 1665041443000,
  "userId": "user id",
  "customerId": "customer id",
  "phone": "phone number",
  "email": "email",
  "note": "received",
  "tags": ["TAG VALUE"],
  "deviceInfo": [
    "brand: APPLE",
    "model :iPhone",
    "os: IOS",
    "osv: 15.6.1"
  ],
  "extParams": [
  ]
}, 
{},
{}]
</code></pre></td></tr></tbody></table>

### Payload

The payload contains a **List** of Events. <mark style="color:blue;">Allowed size: \[1 - 50]</mark>

<table><thead><tr><th width="147">Field</th><th width="107">Required</th><th width="201">Description</th><th>Example</th></tr></thead><tbody><tr><td>clientAppId</td><td>Yes</td><td>Client App Id / Name.</td><td><p>Loyalty Android</p><p>Loyalty for MS</p></td></tr><tr><td>templateId</td><td>Yes</td><td>The template Id in your system</td><td><br></td></tr><tr><td>fcmToken</td><td>Yes</td><td>Firebase token</td><td><br></td></tr><tr><td>msgId</td><td>Yes</td><td>The message is created by your system</td><td>Any text</td></tr><tr><td>fmsgId</td><td><br></td><td>Firebase Message-Id. The id is returned by Firebase after the message sent</td><td><br></td></tr><tr><td>eventAt</td><td>Yes</td><td>Event Time - Timestamp with millisecond</td><td>1665041443000</td></tr><tr><td>userId</td><td><br></td><td>User Id in your system</td><td><br></td></tr><tr><td>customerId</td><td><br></td><td>Customer Id</td><td><br></td></tr><tr><td>phone</td><td><br></td><td>Phone number</td><td><br></td></tr><tr><td>email</td><td><br></td><td>Email Address</td><td><br></td></tr><tr><td>note</td><td><br></td><td>Some notes</td><td><br></td></tr><tr><td>tags</td><td><br></td><td>List of Tags</td><td><pre class="language-javascript"><code class="lang-javascript">[“Promotion”, “New Year”]
</code></pre></td></tr><tr><td>deviceInfo</td><td><br></td><td><p>Device information, following the keys:</p><ul><li>brand</li><li>model</li><li>os</li><li>osv</li></ul></td><td><pre class="language-javascript"><code class="lang-javascript">"deviceInfo": [
    "brand: APPLE",
    "model :iPhone",
    "os: IOS",
    "osv: 15.6.1"
  ]
</code></pre></td></tr><tr><td>extParams</td><td><br></td><td>More information if you want to push. </td><td><pre class="language-javascript"><code class="lang-javascript">"extParams": [
    "code: 000011",
    "campaign: ABC "
  ]
</code></pre></td></tr></tbody></table>

#### Sample Request

```javascript
[{
  "clientAppId": "loyalty-app-android",
  "templateId": "template id",
  "fcmToken": "firebase token",
  "msgId": "message id in your system",
  "fmsgId": "message id from firebase",
  "userId": "user id",
  "customerId": "customer id",
  "phone": "phone number",
  "email": "email",
  "note": "received",
  "tags": ["TAG VALUE"],
  "deviceInfo": [
    "brand: APPLE",
    "model :iPhone",
    "os: IOS",
    "osv: 15.6.1"
  ],
  "extParams": [
     
  ]
}]
```

### Response

<table><thead><tr><th width="175">Code</th><th>Value</th></tr></thead><tbody><tr><td><mark style="color:red;">400</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
  "success": false,
  "message": "REQ Id is incorrect.",
  "errorCode": "NOT_FOUND"
}

// Missing fields
{
"success": false,
"errors": \["clientAppId"],
"errorCode": "MISSING\_INFO"
} </code></pre></td></tr><tr><td><mark style="color:red;">401</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
"success": false,
"message": "Unauthorized!",
"errorCode": "REQ\_ID\_NOT\_MATCHED"
} </code></pre></td></tr><tr><td><mark style="color:green;">200</mark></td><td><pre class="language-javascript"><code class="lang-javascript">{
"success": true,
"took": 98
} </code></pre></td></tr></tbody></table>

[^1]: This value is used for acknowledgement.&#x20;

    Clients that received the messages will push back PangoCDP this value to notify that the messages are delivered successfully.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.pangocdp.com/technical-doc/vie-version/fcm-integration-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
