使用 API

完成入门指南页面中的先决条件后,请通过此页面学习如何发送事件及使用测试事件工具。发送事件后,请验证您的设置

转化 API 以 Facebook 的市场营销 API 为基础,而市场营销 API 则建立在图谱 API 之上。市场营销 API 和图谱 API 版本的停用时间表各不相同。我们的发布周期与图谱 API 保持一致,因此每个版本至少可获得两年的支持。此例外情况仅适用于转化 API。

转化 API:概览参数

使用转化 API 分享的网络、应用和实体店铺事件需要特定参数。使用转化 API,即表示您同意:据您所知,action_source 参数准确无误。如需获取必要参数的列表,请参见此处

发送请求

要发送新事件,请通过以下路径向此 API 的 /events 连线发出 POST 请求:https://graph.facebook.com/{API_VERSION}/{PIXEL_ID}/events?access_token={TOKEN}。当您发布至此连线时,Facebook 即会创建新服务器事件。

curl -X POST \ -F 'data=[ { "event_name": "Purchase", "event_time": 1734848426, "user_data": { "em": [ "309a0a5c3e211326ae75ca18196d301a9bdbd1a882a4d2569511033da23f0abd" ], "ph": [ "254aa248acb47dd654ca3ea53f48c2c26d641d23d7e2e93a1ec56258df7674c4", "6f4fcb9deaeadc8f9746ae76d97ce1239e98b404efe5da3ee0b7149740f89ad6" ], "client_ip_address": "123.123.123.123", "client_user_agent": "$CLIENT_USER_AGENT", "fbc": "fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890", "fbp": "fb.1.1558571054389.1098115397" }, "custom_data": { "currency": "usd", "value": 123.45, "contents": [ { "id": "product123", "quantity": 1, "delivery_category": "home_delivery" } ] }, "event_source_url": "http://jaspers-market.com/product/123", "action_source": "website" } ]' \ -F 'access_token=<ACCESS_TOKEN>' \ https://graph.facebook.com/v21.0/<PIXEL_ID>/events
'use strict'; const bizSdk = require('facebook-nodejs-business-sdk'); const Content = bizSdk.Content; const CustomData = bizSdk.CustomData; const DeliveryCategory = bizSdk.DeliveryCategory; const EventRequest = bizSdk.EventRequest; const UserData = bizSdk.UserData; const ServerEvent = bizSdk.ServerEvent; const access_token = '<ACCESS_TOKEN>'; const pixel_id = '<ADS_PIXEL_ID>'; const api = bizSdk.FacebookAdsApi.init(access_token); let current_timestamp = Math.floor(new Date() / 1000); const userData = (new UserData()) .setEmails(['joe@eg.com']) .setPhones(['12345678901', '14251234567']) // It is recommended to send Client IP and User Agent for Conversions API Events. .setClientIpAddress(request.connection.remoteAddress) .setClientUserAgent(request.headers['user-agent']) .setFbp('fb.1.1558571054389.1098115397') .setFbc('fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890'); const content = (new Content()) .setId('product123') .setQuantity(1) .setDeliveryCategory(DeliveryCategory.HOME_DELIVERY); const customData = (new CustomData()) .setContents([content]) .setCurrency('usd') .setValue(123.45); const serverEvent = (new ServerEvent()) .setEventName('Purchase') .setEventTime(current_timestamp) .setUserData(userData) .setCustomData(customData) .setEventSourceUrl('http://jaspers-market.com/product/123') .setActionSource('website'); const eventsData = [serverEvent]; const eventRequest = (new EventRequest(access_token, pixel_id)) .setEvents(eventsData); eventRequest.execute().then( response => { console.log('Response: ', response); }, err => { console.error('Error: ', err); } );
require __DIR__ . '/vendor/autoload.php'; use FacebookAds\Api; use FacebookAds\Logger\CurlLogger; use FacebookAds\Object\ServerSide\ActionSource; use FacebookAds\Object\ServerSide\Content; use FacebookAds\Object\ServerSide\CustomData; use FacebookAds\Object\ServerSide\DeliveryCategory; use FacebookAds\Object\ServerSide\Event; use FacebookAds\Object\ServerSide\EventRequest; use FacebookAds\Object\ServerSide\UserData; $access_token = '<ACCESS_TOKEN>'; $pixel_id = '<ADS_PIXEL_ID>'; $api = Api::init(null, null, $access_token); $api->setLogger(new CurlLogger()); $user_data = (new UserData()) ->setEmails(array('joe@eg.com')) ->setPhones(array('12345678901', '14251234567')) // It is recommended to send Client IP and User Agent for Conversions API Events. ->setClientIpAddress($_SERVER['REMOTE_ADDR']) ->setClientUserAgent($_SERVER['HTTP_USER_AGENT']) ->setFbc('fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890') ->setFbp('fb.1.1558571054389.1098115397'); $content = (new Content()) ->setProductId('product123') ->setQuantity(1) ->setDeliveryCategory(DeliveryCategory::HOME_DELIVERY); $custom_data = (new CustomData()) ->setContents(array($content)) ->setCurrency('usd') ->setValue(123.45); $event = (new Event()) ->setEventName('Purchase') ->setEventTime(time()) ->setEventSourceUrl('http://jaspers-market.com/product/123') ->setUserData($user_data) ->setCustomData($custom_data) ->setActionSource(ActionSource::WEBSITE); $events = array(); array_push($events, $event); $request = (new EventRequest($pixel_id)) ->setEvents($events); $response = $request->execute(); print_r($response);
import time from facebook_business.adobjects.serverside.action_source import ActionSource from facebook_business.adobjects.serverside.content import Content from facebook_business.adobjects.serverside.custom_data import CustomData from facebook_business.adobjects.serverside.delivery_category import DeliveryCategory from facebook_business.adobjects.serverside.event import Event from facebook_business.adobjects.serverside.event_request import EventRequest from facebook_business.adobjects.serverside.user_data import UserData from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' pixel_id = 'ADS_PIXEL_ID>' FacebookAdsApi.init(access_token=access_token) user_data = UserData( emails=['joe@eg.com'], phones=['12345678901', '14251234567'], # It is recommended to send Client IP and User Agent for Conversions API Events. client_ip_address=request.META.get('REMOTE_ADDR'), client_user_agent=request.headers['User-Agent'], fbc='fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890', fbp='fb.1.1558571054389.1098115397', ) content = Content( product_id='product123', quantity=1, delivery_category=DeliveryCategory.HOME_DELIVERY, ) custom_data = CustomData( contents=[content], currency='usd', value=123.45, ) event = Event( event_name='Purchase', event_time=int(time.time()), user_data=user_data, custom_data=custom_data, event_source_url='http://jaspers-market.com/product/123', action_source=ActionSource.WEBSITE, ) events = [event] event_request = EventRequest( events=events, pixel_id=pixel_id, ) event_response = event_request.execute() print(event_response)
import com.facebook.ads.sdk.APIContext; import com.facebook.ads.sdk.APIException; import com.facebook.ads.sdk.serverside.ActionSource; import com.facebook.ads.sdk.serverside.Content; import com.facebook.ads.sdk.serverside.CustomData; import com.facebook.ads.sdk.serverside.DeliveryCategory; import com.facebook.ads.sdk.serverside.Event; import com.facebook.ads.sdk.serverside.EventRequest; import com.facebook.ads.sdk.serverside.EventResponse; import com.facebook.ads.sdk.serverside.UserData; import java.util.Arrays; public class ServerSideApiExample { public static final String ACCESS_TOKEN = "<ACCESS_TOKEN>"; public static final String PIXEL_ID = "<ADS_PIXEL_ID>"; public static void main(String[] args) { APIContext context = new APIContext(ACCESS_TOKEN).enableDebug(true); context.setLogger(System.out); UserData userData = new UserData() .emails(Arrays.asList("joe@eg.com")) .phones(Arrays.asList("12345678901", "14251234567")) // It is recommended to send Client IP and User Agent for Conversions API Events. .clientIpAddress(clientIpAddress) .clientUserAgent(clientUserAgent) .fbc("fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890") .fbp("fb.1.1558571054389.1098115397"); Content content = new Content() .productId("product123") .quantity(1L) .deliveryCategory(DeliveryCategory.home_delivery); CustomData customData = new CustomData() .addContent(content) .currency("usd") .value(123.45F); Event purchaseEvent = new Event(); purchaseEvent.eventName("Purchase") .eventTime(System.currentTimeMillis() / 1000L) .userData(userData) .customData(customData) .eventSourceUrl("http://jaspers-market.com/product/123") .actionSource(ActionSource.website); EventRequest eventRequest = new EventRequest(PIXEL_ID, context); eventRequest.addDataItem(purchaseEvent); try { EventResponse response = eventRequest.execute(); System.out.println(String.format("Standard API response : %s ", response)); } catch (APIException e) { e.printStackTrace(); } } }
require 'facebook_ads' access_token = '<ACCESS_TOKEN>' pixel_id = '<ADS_PIXEL_ID>' FacebookAds.configure do |config| config.access_token = access_token end user_data = FacebookAds::ServerSide::UserData.new( emails: ['joe@eg.com'], phones: ['12345678901', '14251234567'], # It is recommended to send Client IP and User Agent for Conversions API Events. client_ip_address: request.remote_ip, client_user_agent: request.user_agent, fbc: 'fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890', fbp: 'fb.1.1558571054389.1098115397' ) content = FacebookAds::ServerSide::Content.new( product_id: 'product123', quantity: 1, delivery_category: 'home_delivery' ) custom_data = FacebookAds::ServerSide::CustomData.new( contents: [content], currency: 'usd', value: 123.45 ) event = FacebookAds::ServerSide::Event.new( event_name: 'Purchase', event_time: Time.now.to_i, user_data: user_data, custom_data: custom_data, event_source_url: 'http://jaspers-market.com/product/123', action_source: 'website' ) request = FacebookAds::ServerSide::EventRequest.new( pixel_id: pixel_id, events: [event] ) print request.execute

将您使用 access_token 查询参数生成的安全访问口令附加至此请求。您还可以使用图谱 API 探索工具POST 请求发送至 /<pixel_id>/events 端点。

请求正文示例如下:

{
   "data": [
      {
         "event_name": "Purchase",
         "event_time": 1633552688,
         "event_id": "event.id.123",
         "event_source_url": "http:\/\/jaspers-market.com\/product\/123",         
         "action_source": "website",
         "user_data": {
            "client_ip_address": "192.19.9.9",
            "client_user_agent": "test ua",
            "em": [
               "309a0a5c3e211326ae75ca18196d301a9bdbd1a882a4d2569511033da23f0abd"
            ],
            "ph": [
               "254aa248acb47dd654ca3ea53f48c2c26d641d23d7e2e93a1ec56258df7674c4",
               "6f4fcb9deaeadc8f9746ae76d97ce1239e98b404efe5da3ee0b7149740f89ad6"
            ],
            "fbc": "fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890",
            "fbp": "fb.1.1558571054389.1098115397"
         },
         "custom_data": {
            "value": 100.2,
            "currency": "USD",
            "content_ids": [
               "product.id.123"
            ],
            "content_type": "product"
         },
         "opt_out": false
      },
      {
         "event_name": "Purchase",
         "event_time": 1633552688,
         "user_data": {
            "client_ip_address": "192.88.9.9",
            "client_user_agent": "test ua2"
         },
         "custom_data": {
            "value": 50.5,
            "currency": "USD"
         },
         "opt_out": false
      }
   ]
}

上传时间与事件发生时间的对比情况

event_time 是事件发生时间。您应以 Unix 时间戳(以秒为单位)的形式发送该时间,以指示实际事件的发生时间。指定的时间可能早于您向 Facebook 发送事件的时间。这是为了实现批处理和服务器性能优化。

event_time 最长可比您向 Meta 发送事件的时间早 7 天。如果 data 中的任何 event_time 早于 7 天前,我们会为整个请求返回错误消息,而且不会处理任何事件。对于线下事件和实体店事件(action_sourcephysical_store),您应该在转化后的 62 天内上传发生的事件。

使用转化 API,即表示您同意:据您所知,action_source 参数准确无误。

批量请求

您最多可在 data 中发送 1,000 个事件。不过,为实现最优性能,我们建议您尽可能在事件发生后立即发送事件;以在事件发生一小时内发送为宜。如果批量发送的事件中存在任何无效事件,我们将拒绝整个批次。

哈希

请参阅我们的客户信息参数页面,了解应先对哪些参数执行哈希处理,然后再将之发送至 Facebook。如果您正在使用我们的其中一个 Business SDK,此 SDK 会为您完成哈希处理。

转化 API 专用的 Business SDK 功能

详细了解专为转化 API 用户设计的三项特定 Business SDK 功能:异步请求并发批处理以及 HTTP 服务接口。使用这些功能所需的最低语言版本:

  • PHP >= 7.2
  • Node.js >= 7.6.0
  • Java >= 8
  • Python >= 2.7
  • Ruby >= 2

自 2019 年 1 月起,Business SDK 已不再支持 PHP 5。如要使用 Business SDK,请升级至 PHP 7。

如果必须使用 PHP 5,可考虑使用我们的 Swagger 实现

转化 API 参数

验证事件

发送事件后,您需在事件管理工具中确认我们已收到这些事件:

  • 数据源页面上,点击与您 POST 请求中的 PIXEL_ID 对应的 Pixel 像素代码。详情请参阅 Business 帮助中心:使用 Meta 事件管理工具管理网站事件
  • 然后,点击概览。页面随即会显示我们收到的原始事件、匹配事件和归因事件的数量。在连接方法下,您可以查看发送该事件的渠道。
  • 您可以点击每个事件以获取更具体的信息。
  • 开始发送事件后,请在 20 分钟内完成事件验证。此时,您可开始从服务器发送事件。

测试事件工具

您可以使用事件管理工具中的“测试事件”功能来验证 Facebook 是否已正确接收服务器事件。如要找到此工具,请前往 Events Manager > Data Sources > Your Pixel > Test Events

测试事件工具可生成测试编号。将测试编号作为 test_event_code 参数发送,即可开始查看“测试事件”窗口中显示的事件活动。

请注意:应只将 test_event_code 字段用于测试。在发送生产负载时,您必须将该字段移除。

使用 test_event_code 发送的事件不会遭到丢弃,而是会流入事件管理工具,以用于设置目标受众和衡量广告表现。

以下是请求的正确组织结构示例:

{ "data": [ { "event_name": "ViewContent", "event_time": 1734847826, "event_id": "event.id.123", "event_source_url": "http:\/\/jaspers-market.com", "user_data": { "client_ip_address": "1.2.3.4", "client_user_agent": "test user agent" } } ], "test_event_code": "TEST123" }

以下是请求在图谱 API 探索工具中的显示示例:

您可以使用负载帮手工具来生成此测试负载。请注意,测试事件代码仅用于测试负载。

在您发送请求后,您的服务器事件随即会在“测试事件”窗口中显示。

适用于美国用户的数据处理选项

对于应用事件 API 和线下转化 API,可在事件数据参数的每个事件内添加 data_processing_optionsdata_processing_options_countrydata_processing_options_state,借此实现数据处理选项。

注意:对于新的集成,我们不再推荐使用应用事件 API 和线下转化 API。我们推荐您改为使用转化 API,因为转化 API 现在支持网页事件、应用事件和线下事件。详情请参阅使用转化 API 传递应用事件使用转化 API 传递线下事件

如要明确不启用“限制数据使用”(LDU),请为每个事件指定空数组,或直接移除负载中的字段:

{
    "data": [
        {
            "event_name": "Purchase",
            "event_time": <EVENT_TIME>,
            "user_data": {
                "em": "<EMAIL>"
            },
            "custom_data": {
                "currency": "<CURRENCY>",
                "value": "<VALUE>"
            },
            "data_processing_options": []
        }
    ]
}

如要启用 LDU 并让 Meta 执行地理定位,请使用以下代码:

{
    "data": [
        {
            "event_name": "Purchase",
            "event_time": <EVENT_TIME>,
            "user_data": {
                "em": "<EMAIL>",
                "client_ip_address": "256.256.256.256"
            },
            "custom_data": {
                "currency": "<CURRENCY>",
                "value": "<VALUE>"
            },
            "data_processing_options": ["LDU"],
            "data_processing_options_country": 0,
            "data_processing_options_state": 0
        }
    ]
}

如要启用 LDU 并手动指定位置(例如加利福尼亚州),请使用以下代码:

{
    "data": [
        {
            "event_name": "Purchase",
            "event_time": <EVENT_TIME>,
            "user_data": {
                "em": "<EMAIL>"
            },
            "custom_data": {
                "currency": "<CURRENCY>",
                "value": "<VALUE>"
            },
            "data_processing_options": ["LDU"],
            "data_processing_options_country": 1,
            "data_processing_options_state": 1000
        }
    ]
}

手动上传用户界面

线下转化 API 提供手动上传选项,支持通过 .csv 文件上传事件。在这种情况下,请将“数据处理选项”、“数据处理国家/地区”和“数据处理州/省/自治区/直辖市”添加为文件中的列。如需有关该内容的更多信息,请前往上传用户界面。


详细了解数据处理选项

API 限制

市场营销 API 有专门的流量限制逻辑,并独立于所有图谱 API 流量限制之外。因此,如果您调用市场营销 API,该调用并不会影响图谱 API 节流。

转化 API 没有特定的流量限制。转化 API 调用计作市场营销 API 调用。唯一的限制是您一次最多只能向我们发送 1,000 个事件。详情请参阅发送请求

市场营销 API 流量限制

Business SDK API 在转化 API 网关中的使用方法

通过此指南,您可以浏览专为转化 API 网关用户设计的 Meta Business SDK 高级功能。如需了解转化 API 网关的基本使用方法,请参阅转化 API 网关文档。

将事件发送到您的转化 API 网关实例

要求

您需要先安装 Meta Business SDK,才能使用以下任何一项功能。请参阅 Meta Business SDK 入门指南,或遵循下列 README 说明:

目前,上述功能仅适用于 PHP 和 Java 版 Business SDK。到 2023 年底,适用范围将扩大到其他语言。

以下是使用这些功能时所需的最低语言版本:

PHP >= 7.2

Java >= 8

注意:如要对发送至转化 API 端点的事件进行去重,请在请求中传递 eventId。如此一来,在启用转化 API 发布功能时,便可以避免出现重复事件。

设置 CAPIGatewayIngressRequest 参数的格式

参数描述
endpointUrl
字符串

系统会将事件发送至该转化 API 网关端点。除检查该参数是否为有效网址之外,系统不会对其进行任何预验证。


示例:https://test.example.com


accessKey
字符串

将事件发送至转化 API 网关事件端点时,需要使用此转化 API 网关访问密钥。请参阅这些说明,了解如何生成该密钥。

CAPIGatewayIngressRequest Setter

参数描述
setSendToDestinationOnly
布尔值

此布尔值标记用于表明事件是否仅发送到选定的端点。


默认值:False


setFilter
CustomEndpointRequest.Filter() 函数

此筛选函数用于处理每个事件。如果筛选逻辑返回 true,表示该事件已传递成功;否则,表示事件被丢弃。您必须在具有 Event 参数的接口中执行 shouldSendEvent 函数。


默认值:Null



迁移示例:PHP

对于已使用 Business SDK 的系统,您只需引用新的 CAPIGatewayIngressRequest,并将其附加到 eventRequest 的 customEndpoint 对象之后。

// this is the standard event request that we attach events to
$event_request = new EventRequest($this->pixel_id);
$capiIngressRequest = new CAPIGatewayIngressRequest($this->cb_url, $this->access_key);
$event_request->setCustomEndpoint($capiIngressRequest);
// pass the events to this event Request object
$event_request->setEvents($events);
$event_request->execute()

迁移示例:Java

对于已使用 Business SDK 的系统,您只需引用新的 CAPIGatewayIngressRequest,并将其附加到 eventRequest 的 customEndpoint 对象之后。

// this is the standard event request that we attach events to


EventRequest eventRequest = new EventRequest(PIXEL_ID, context);


CAPIGatewayIngressRequest capiSyncRequest = new CAPIGatewayIngressRequest(CB_URL, CAPIG_ACCESS_KEY);
eventRequest.setCustomEndpoint(capiSyncRequest);
eventRequest.addDataItem(testEvent);
eventRequest.execute();

同步选项

PHP 代码示例

$api = Api::init(null, null, $this->access_token);
$api->setLogger(new CurlLogger());
$event_request = new EventRequest($this->pixel_id);
$capiIngressRequest = new CAPIGatewayIngressRequest($this->cb_url, $this->access_key);
$event_request->setCustomEndpoint($capiIngressRequest);
$user_data = (new UserData())
   ->setEmails(array('joe@eg.com'))
   ->setPhones(array('12345678901', '14251234567'))
   ->setFbc('fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890')
   ->setFbp('fb.1.1558571054389.1098115397');
$event1 = (new Event())
   ->setEventName('Purchase')
   ->setEventId('125')
   ->setEventTime(time())
   ->setEventSourceUrl('http://jaspers-market.com/product/123')
   ->setUserData($user_data);
$events = array($event1, $event2);
$event_request->setEvents($events);
$response = $event_request->execute();
print($response->__toString());

Java 代码示例

EventRequest eventRequest = new EventRequest(PIXEL_ID, context);
UserData userData = new UserData()
       .email("abc@eg.com");
CAPIGatewayIngressRequest capiSyncRequest = new CAPIGatewayIngressRequest(CB_URL, CAPIG_ACCESS_KEY);
eventRequest.setCustomEndpoint(capiSyncRequest);
Event testEvent = new Event();
testEvent.eventId("125").eventName("Purchase")
       .eventTime(System.currentTimeMillis() / 1000L)
       .userData(userData)
       .dataProcessingOptions(new String[]{}).setEventId("134423232");
eventRequest.namespaceId("11")
       .uploadId("22222")
       .uploadTag("upload-tag-4")
       .uploadSource("upload-source-4")
       .testEventCode("test-event-code-5")
       .partnerAgent("partner-agent-6");
eventRequest.addDataItem(testEvent);
eventRequest.execute();

异步选项

PHP 代码示例

$api = Api::init(null, null, $this->access_token);
$api->setLogger(new CurlLogger());
$event_request = new EventRequestAsync($this->pixel_id);
$capiIngressRequest = new CAPIGatewayIngressRequest($this->cb_url, $this->access_key);
$capiIngressRequest->setSendToDestinationOnly(true);
$event_request->setCustomEndpoint($capiIngressRequest);
$event1 = (new Event())
   ->setEventName('test Async Event')
   ->setEventId('134423232')
   ->setEventTime(time())
   ->setEventSourceUrl('http://jaspers-market.com/product/123');
$events = array($event1, $event2);
$event_request->setEvents($events);
$response = $event_request->execute()->wait();

Java 代码示例

EventRequest eventRequest = new EventRequest(PIXEL_ID, context);
UserData userData = new UserData()
       .email("abc@eg.com");
CAPIGatewayIngressRequest capiSyncRequest = new CAPIGatewayIngressRequest(CB_URL, CAPIG_ACCESS_KEY);
capiSyncRequest.setSendToDestinationOnly(true);
eventRequest.setCustomEndpoint(capiSyncRequest);
Event testEvent = new Event();
testEvent.eventName("test Async Event")
       .eventTime(System.currentTimeMillis() / 1000L)
       .userData(userData)
       .dataProcessingOptions(new String[]{}).setEventId("134423232");
eventRequest.namespaceId("11222")
       .uploadId("22222")
       .uploadTag("upload-tag-4")
       .uploadSource("upload-source-4")
       .testEventCode("test-event-code-5")
       .partnerAgent("partner-agent-6");
eventRequest.addDataItem(testEvent);
eventRequest.executeAsync();

筛选功能

PHP 代码示例

lass APIFilter implements Filter {
   public function shouldSendEvent(Event $event): bool
   {
       if ($event->getEventId() === '125') {
           return false;
       }
       return true;
   }
}
$capiIngressRequest = new CAPIGatewayIngressRequest($this->cb_url, $this->access_key);
$event_request->setCustomEndpoint($capiIngressRequest);
$capiIngressRequest->setFilter(new APIFilter());

Java 代码示例

CAPIGatewayIngressRequest capiSyncRequest = new CAPIGatewayIngressRequest(CB_URL, CAPIG_ACCESS_KEY);
eventRequest.setCustomEndpoint(capiSyncRequest);


capiSyncRequest.setFilter(new CustomEndpointRequest.Filter() {
   @Override
   public boolean shouldSendEvent(Event event) {
   if (event.getEventId().equals("125")) {
       return true;
   }
   return false;
}
});