# MongoServerError: Transaction API version error: expected API version '1' but received '2'

- **ID:** `mongodb/transaction-api-version-error`
- **Domain:** mongodb
- **Category:** protocol_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

A driver or application attempted to use an unsupported transaction API version, typically due to driver/library version mismatch with the MongoDB server.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| MongoDB 5.0 | active | — | — |
| MongoDB 6.0 | active | — | — |
| MongoDB 7.0 | active | — | — |

## Workarounds

1. **Upgrade the MongoDB driver to a version compatible with the server API version. For Node.js: npm install mongodb@6.3.0. For Python: pip install pymongo==4.6.0.** (95% success)
   ```
   Upgrade the MongoDB driver to a version compatible with the server API version. For Node.js: npm install mongodb@6.3.0. For Python: pip install pymongo==4.6.0.
   ```
2. **Set the API version explicitly in the connection string: mongodb://localhost:27017/?apiVersion=1 to force compatibility.** (85% success)
   ```
   Set the API version explicitly in the connection string: mongodb://localhost:27017/?apiVersion=1 to force compatibility.
   ```

## Dead Ends

- **** — Upgrading the MongoDB server to the latest version doesn't fix the mismatch if the driver is outdated. (80% fail)
- **** — Setting transaction options to empty object in the driver is ignored because the API version is negotiated at connection time. (90% fail)
