---
title: Transaction Monitoring : API
slug: grc-suite/transaction-monitoring-api
createdAt: 2024-10-16T11:31:05.176Z
---

This describes the request body and the various responses from the transaction monitoring system after processing a transaction. The responses detail the rule evaluation, any detected violations, and errors encountered during the rule evaluation or transaction processing.

### Endpoint: `/stream/v1`

### Method: `POST`

### Headers:

- `x-api-key` (Required): A valid API key associated with the team. (Present in the API Key Curl Command)

### Request Body:

The request body must be a JSON object that includes the following fields:

```json
{
    "data": { ... }            // Required, dynamic payload
}
```

### Responses:

### 200 OK (Success)

The response includes the following details for each rule :

1. **status**: The status for each rule, which can be:
   - **RULE\_COMPILED**: The rule was successfully checked with the payload, and no violations were found.
   - **RULE\_VIOLATED**: The transaction violated the rule.
   - **RULE\_EVALUATION\_FAILED**: An error occurred while evaluating the rule, likely due to misconfiguration or invalid logic in the rule.
2. **timetaken**: The time taken to evaluate each rule against the transaction payload.

```json
{
    "txnId": "txn-987654",
    "teamId": "679ddc46-34ce-4b7a-8da8-4b8ba4848ae8",
    "acknowledgementId": "670f9e9d4028b83f2543fdb1",
    "flagged": true,
    "receivedAt": 1729076893328,
    "ruleEvaluationMetrics": {
         "3116db5a-36bb-4a70-8853-6a71cf6b91a9": {
            "status": "RULE_VIOLATED",
            "timetaken": 0.159074992
        },
        "13f913d5-8dcc-4867-b6d7-5d372956ce04": {
            "status": "RULE_EVALUATION_FAILED",
            "timetaken": 0.003980621
        },
        "1484dd77-985d-4854-af45-86934f50cdd5": {
            "status": "RULE_COMPLIED",
            "timetaken": 0.121830409
        }
}
```

### 400 Bad Request

- **INVALID\_JSON**
  - **Description**: The request body contains invalid JSON, making it impossible to process the transaction.
  - **Response&#x20;**: &#x20;

```json
    {
        "error": "INVALID_JSON"
    }
```

- **Missing Required Fields**
  - **Description**: One or more required fields are missing from the transaction payload.
  - **Response**:&#x20;

```json
    {
        "error": "Missing required fields: [list of fields]"
    }
```

- **Failed to Parse Transaction Payload**
  - **Description**: The system encountered an error while parsing the transaction payload, possibly due to improper data formatting or structure.
  - **Response**:&#x20;

```json
{
  "error": "FAILED_TO_PARSE_TRANSACTION_PAYLOAD" 
}
```

- **Empty Database Schema**
  - **Description**: The database schema is not set or configured for the team, preventing the transaction from being processed.
  - **Response:&#x20;**

```json
    {
        "error": "dbSchema is empty"
    }
```

### 401 Unauthorized

- **Missing API Key**
  - **Description**: The x-api-key header is not present in the request, and the server cannot authenticate the request.
  - **Response**:&#x20;

```json
    {
        "error": "Missing x-api-key"
    }
```

- **Invalid API Key**
  - **Description**: The provided API key in the x-api-key header is invalid or incorrect.
  - **Response**:&#x20;

```json
    {
        "error": "Invalid x-api-key"
    }
```

### 403 Forbidden

- **Unauthorized Team**
  - **Description**: The team ID provided in the request is not authorized to access the requested resources.
  - **Response**:&#x20;

```json
    {
        "error": "UNKNOWN_TEAM"
    }
```

### 422 Unprocessable Entity

- **Failed to Register Transaction :**
  - This indicates that there was an error in the transaction payload. The potential reasons for this could include:
    - **Datatype mismatch**: A field’s value does not match its expected datatype.
    - **Missing keys**: Certain required keys are missing from the transaction payload, preventing proper rule evaluation.
  - **Response**:&#x20;

```json
    {
        "error": "FAILED_TO_REGISTER_TRANSACTION"
    }
```

These response categories provide detailed feedback about whether the transaction was processed successfully, the status of each rule evaluated, and if any errors occurred during the evaluation.
