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.

Note:
Detect always includes the following headers on every API request, regardless of any custom headers you configure:
  • Idempotency-Key: a randomly generated UUID
  • Accept: application/json
  • Content-Type: application/json

Procedure

  1. Create the destination JSON payload file, following the same structure used for Kafka and database destinations.

    In the connectorConfig object, add an api entry with connectorType set to API and apiConfigName set 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"
    }
    } }
    }
  2. Add custom HTTP headers your downstream system requires, if any, as key-value pairs in headers.
    Detect automatically sets Idempotency-Key, Accept, and Content-Type on 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.
  3. 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.json
    Detect validates that the referenced apiConfigName exists in Platform and validates the API config inputs before the destination is saved.
  4. 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.