Configure Destination with API Connector
Before you begin
- You have created an API configuration in Platform; see Create API Configuration in Platform.
- You know the message template and feed attribute mappings required for the destination, as described in the destination creation commands.
About this task
Destinations in Detect are created and updated through the Detect CLI by submitting a
JSON payload. To publish events to a REST endpoint, add an api entry
under connectorConfig that points to the API configuration you created
in Platform. You can combine the api connector with
kafka or db connectors on the same destination to
publish the same event to multiple places.
Idempotency-Key: a randomly generated UUIDAccept:application/jsonContent-Type:application/json
Procedure
-
Create the destination JSON payload file, following the same structure used for
Kafka and database destinations.
In the
connectorConfigobject, add anapientry withconnectorTypeset toAPIandapiConfigNameset to the name of the API configuration you created in Platform. Provided below a sample JSON payload file, you can configure it as per your Feed and profile attributes configurations.{ "name": "API", "description": "Generic destination with API and DB connector only", "templateId": 4, "messageConfig": { "producerServiceName": "hcl-unica-detect-event" }, "feedAttributeMapping": [ { "feedId": 1, "attributes": { "profile": { "AUDIENCE_KEY": "AUDIENCE_KEY", "firstName": "firstName" }, "tuple": { "transactionStatus": "transactionStatus", "AUDIENCE_KEY": "AUDIENCE_KEY" } } } ], "connectorConfig": { "api": { "connectorType": "API", "properties": null, "apiConfigSourceName": "VM242_API_Connector", "headers": { "Content-Type": "application/json" } } } } -
Add custom HTTP headers your downstream system requires, if any, as key-value pairs
in
headers.Detect automatically setsIdempotency-Key,Accept, andContent-Typeon every request, so you do not need to include them here. Only JSON payloads are supported. The custom headers you enter are used in addition to the default headers set by Detect. -
Create the destination.
Windows:
CliTool.bat create-destination -f "C:\destinations\create-webhook-destination.json"Linux:
./CliTool.sh create-destination -f /home/user/destinations/create-webhook-destination.jsonDetect validates that the referencedapiConfigNameexists in Platform and validates the API config inputs before the destination is saved. - Trigger a test event for the destination and confirm the target endpoint returns HTTP 200.
Results
The destination publishes matching events to the configured REST endpoint. See API Connector Delivery, Retry, and Failure Handling for how delivery, retries, and failures are handled after the destination is saved.