> ## 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](https://docs.flowx.ai/6.x/docs/platform-deep-dive/integrations/consuming-flowx-from-external-apps.md).

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.

> [!NOTE]
>
> Kafka mocks are essential for testing process flows that depend on external integrations, allowing you to simulate various response scenarios and edge cases.

## Authentication

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

**Authorization** `string` *required*

Bearer token for API authentication. Format: `Bearer YOUR_API_TOKEN`

## URL Parameters

**mock-adapter-url** `string` *required*

The base URL of the mock adapter service where Kafka exchange mocks are managed.

## Request Body Parameters

**incomingTopic** `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`

**outgoingTopic** `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`

**sentMessageJson** `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.

**receivedMessageJson** `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.

## Request Example

```bash cURL theme={"dark"}
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\": [] }"
  }'
```

```javascript Node.js theme={"dark"}
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={"dark"}
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": [] }'
    }
)
```

## Response Examples

```json Success (201 Created) theme={"dark"}
{
  "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
}
```

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

```json Error (401 Unauthorized) theme={"dark"}
{
  "error": "Unauthorized",
  "message": "Invalid or missing authentication token"
}
```

## 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]
>
> **Topic Naming**: Ensure your topic names follow your organization's Kafka topic naming conventions and match exactly with your integration configurations.

> [!WARNING]
>
> Mock exchanges are intended for development and testing environments only. Do not use mocked integrations in production systems.


## Related topics

- [Mock integrations](https://docs.flowx.ai/6.x/docs/platform-deep-dive/integrations/mock-integrations.md)
- [React Native SDK](https://docs.flowx.ai/release-notes/v6.x/v6.0.0-october-2026/migrating-from-v5.9-to-v6.0/react-native.md)
- [Tutorial: Build your first workflow](https://docs.flowx.ai/6.x/docs/getting-started/building-your-first-workflow.md)
- [React SDK](https://docs.flowx.ai/release-notes/v6.x/v6.0.0-october-2026/migrating-from-v5.9-to-v6.0/react.md)
- [FlowX.AI 5.9.0 Release Notes](https://docs.flowx.ai/release-notes/v5.x/v5.9.0-june-2026/v5.9.0-june-2026.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.