> For the complete documentation index, see [llms.txt](https://txsentinel.gitbook.io/baibysitter/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://txsentinel.gitbook.io/baibysitter/api/api-reference.md).

# API Reference

## API Reference

### Process Transaction

Simulates and analyzes a submitted transaction, comparing the actual execution with the provided **reason (intent)** — what the transaction is expected to do.

Based on the analysis, the system determines whether the transaction should be **approved** or **rejected**, and flags any **risks or mismatches** with the original intent

**Base URL**

```
http://apib.baibysitter.xyz
```

**Endpoint**

```
POST /api/transaction
```

**Swagger**

```
http://apib.baibysitter.xyz/docs#tag/default/post/api/transaction
```

***

#### Request

**Headers**

```http
Content-Type: application/json
```

**Body Parameters**

| Field          | Type    | Required           | Description                                                         |
| -------------- | ------- | ------------------ | ------------------------------------------------------------------- |
| `chainId`      | Integer | ✅ Yes              | Blockchain network ID                                               |
| `from_address` | String  | ✅ Yes              | Sender wallet address                                               |
| `to_address`   | String  | ✅ Yes              | Recipient wallet address                                            |
| `data`         | String  | ✅ Yes              | Encoded transaction data                                            |
| `value`        | String  | No (default `"0"`) | ETH or native token value sent                                      |
| `reason`       | String  | Optional           | Declared intent for the transaction (e.g., `"swap 1 ETH for USDC"`) |

***

#### Example Request

**Shell / cURL**

```bash
curl http://apib.baibysitter.xyz/api/transaction   --request POST   --header 'Content-Type: application/json'   --data '{
    "chainId": 8453,
    "from_address": "0x2af7BA938d51353A5eE998cDB770e006C57b252B",
    "to_address": "0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b",
    "data": "0xa9059cbb0000000000000000000000007357ad9f66b6e4e056f8f4a469844f4fab00f1440000000000000000000000000000000000000000000000007ce66c50e2840000",
    "value": "0",
    "reason": "i want to transfer 9 virtuals to 0x7357ad9F66B6E4e056F8f4a469844F4faB00F145"
  }'
```

***

#### Responses

**200 OK**

```json
{
  "transaction_id": "497da974-7e74-461e-a85d-40b469ef6d1f",
  "validations": {
    "agent": {
      "risks_detected": [
        "Intent mismatch between Primary Reason and simulated behavior"
      ],
      "status": "rejected",
      "message": "The transaction is rejected due to a mismatch in recipient addresses between the Primary Reason and sentinel information. Expected recipient 0x7357ad9F66B6E4e056F8f4a469844F4faB00F145 but found 0x7357ad9f66b6e4e056f8f4a469844f4fab00f144. This could indicate a potential risk of funds being sent to an unintended recipient.",
      "warnings_considered": []
    }
  },
  "created_at": "2025-09-17T01:45:55.700394",
  "updated_at": "2025-09-17T01:46:08.676536",
  "status": "completed"
}
```

**422 Validation Error**

```json
{
  "detail": [
    {
      "loc": ["body", "chainId"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}
```

***

#### Example Use Cases

* **ERC-20 transfer**: Validate that the declared recipient matches the simulated execution.
* **Swap**: Detect mismatches between expected and actual tokens received.
* **Approval**: Detect infinite approvals or approvals to malicious addresses.
