> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Add new Kafka exchange mock

> Create a new Kafka exchange mock to simulate message flows between FlowX Engine and external integrations during development and testing

<Warning>
  **Reference under review.** This endpoint is exposed by the mock-server, a development and testing component — not a production-facing API. For supported integration patterns, see [Consuming FlowX from external apps](/5.9/docs/platform-deep-dive/integrations/consuming-flowx-from-external-apps).
</Warning>

This endpoint allows you to create a new Kafka exchange mock that simulates the message flow between FlowX Engine and external integrations. Use this during development and testing to mock third-party system responses without requiring actual external services.

<Info>
  Kafka mocks are essential for testing process flows that depend on external integrations, allowing you to simulate various response scenarios and edge cases.
</Info>

## Authentication

This endpoint requires Bearer Token authentication. Include your API token in the Authorization header.

<ParamField header="Authorization" type="string" required>
  Bearer token for API authentication. Format: `Bearer YOUR_API_TOKEN`
</ParamField>

## URL Parameters

<ParamField path="mock-adapter-url" type="string" required>
  The base URL of the mock adapter service where Kafka exchange mocks are managed.
</ParamField>

## Request Body Parameters

<ParamField body="incomingTopic" type="string" required>
  The Kafka topic name that the external integration listens on for incoming messages from FlowX Engine. This should match exactly with your integration's configuration.

  **Example:** `ai.flowx.in.adapter.kyc.clientCheckPf.v1`
</ParamField>

<ParamField body="outgoingTopic" type="string" required>
  The Kafka topic name that FlowX Engine listens on for replies from the external integration. This should match the topic configured in your process definition.

  **Example:** `to.flowx.updates.qa.adapter.kyc.clientcheck.v1`
</ParamField>

<ParamField body="sentMessageJson" type="string" required>
  The JSON message that will be sent to the external integration. Use `null` if you want to test scenarios where no specific message content is required, or provide a JSON string for specific message simulation.
</ParamField>

<ParamField body="receivedMessageJson" type="string" required>
  The JSON response message that the mock will return to FlowX Engine, simulating the external integration's response. This allows you to test different response scenarios.
</ParamField>

## Request Example

<RequestExample>
  ```bash cURL theme={"system"}
  curl -X POST '{MOCK_ADAPTER_URL}/api/kafka-exchanges/' \
    -H 'Authorization: Bearer YOUR_API_TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
      "incomingTopic": "ai.flowx.in.adapter.kyc.clientCheckPf.v1",
      "outgoingTopic": "to.flowx.updates.qa.adapter.kyc.clientcheck.v1",
      "receivedMessageJson": null,
      "sentMessageJson": "{ \"status\": \"success\", \"response\": [] }"
    }'
  ```
</RequestExample>

<CodeGroup>
  ```javascript Node.js theme={"system"}
  const response = await fetch('{MOCK_ADAPTER_URL}/api/kafka-exchanges/', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      incomingTopic: 'ai.flowx.in.adapter.kyc.clientCheckPf.v1',
      outgoingTopic: 'to.flowx.updates.qa.adapter.kyc.clientcheck.v1',
      receivedMessageJson: null,
      sentMessageJson: '{ "status": "success", "response": [] }'
    })
  });
  ```

  ```python Python theme={"system"}
  import requests

  response = requests.post(
      '{MOCK_ADAPTER_URL}/api/kafka-exchanges/',
      headers={
          'Authorization': 'Bearer YOUR_API_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'incomingTopic': 'ai.flowx.in.adapter.kyc.clientCheckPf.v1',
          'outgoingTopic': 'to.flowx.updates.qa.adapter.kyc.clientcheck.v1',
          'receivedMessageJson': None,
          'sentMessageJson': '{ "status": "success", "response": [] }'
      }
  )
  ```
</CodeGroup>

## Response Examples

<ResponseExample>
  ```json Success (201 Created) theme={"system"}
  {
    "id": "mock_exchange_123",
    "incomingTopic": "ai.flowx.in.adapter.kyc.clientCheckPf.v1",
    "outgoingTopic": "to.flowx.updates.qa.adapter.kyc.clientcheck.v1",
    "receivedMessageJson": null,
    "sentMessageJson": "{ \"status\": \"success\", \"response\": [] }",
    "createdAt": "2024-01-15T10:30:00Z",
    "isActive": true
  }
  ```
</ResponseExample>

<ResponseExample>
  ```json Error (400 Bad Request) theme={"system"}
  {
    "error": "Invalid request",
    "message": "incomingTopic is required and must be a valid topic name",
    "code": "INVALID_TOPIC_NAME"
  }
  ```
</ResponseExample>

<ResponseExample>
  ```json Error (401 Unauthorized) theme={"system"}
  {
    "error": "Unauthorized",
    "message": "Invalid or missing authentication token"
  }
  ```
</ResponseExample>

## Usage Tips

<Tip>
  **Testing Different Scenarios**: Create multiple mocks with different `sentMessageJson` values to test various response scenarios like success, failure, and edge cases in your process flows.
</Tip>

<Tip>
  **Topic Naming**: Ensure your topic names follow your organization's Kafka topic naming conventions and match exactly with your integration configurations.
</Tip>

<Warning>
  Mock exchanges are intended for development and testing environments only. Do not use mocked integrations in production systems.
</Warning>


## Related topics

- [Mock integrations](/5.9/docs/platform-deep-dive/integrations/mock-integrations.md)
- [FlowX.AI 5.9.0 Release Notes](/release-notes/v5.x/v5.9.0-june-2026/v5.9.0-june-2026.md)
- [Email Trigger](/5.9/docs/platform-deep-dive/integrations/email-trigger.md)
- [FlowX.AI 5.6.0 Release Notes](/release-notes/v5.x/v5.6.0-march-2026/v5.6.0-march-2026.md)
- [Kafka send action](/5.9/docs/building-blocks/actions/kafka-send-action.md)
