---
title: "Fix Bank Connections"
method: POST
path: "/api/admin/fix-bank-connections"
tags: ["Admin"]
---

# Fix Bank Connections

`POST /api/admin/fix-bank-connections`

## Request

- Base URL: `https://api.earmarkiq.app` (the document declares no server; this is the origin it was published from)
- URL: `https://api.earmarkiq.app/api/admin/fix-bank-connections`
- Auth: HTTP bearer

Clean up ghost bank connections and reactivate incorrectly expired ones.

Safe to run — only deactivates duplicates and resets connections that were
incorrectly marked expired. Does NOT delete any data.

Steps:
1. Reactivate connections marked consent_expired=True whose consent_expires
   is still in the future.
2. For each user, deduplicate accounts by (sort_code, account_number).
   Keep the account whose parent connection has the most recent
   last_synced_at; deactivate the parent connections of the rest.
3. For connections sharing the same finexer_consent_id within a user,
   keep the most recently synced one and deactivate the rest.

## Response `200`

Successful Response

- unknown

---

[API](https://skmtc.dev/earmarkiq/apis/earmark-api.md) · [All operations](https://skmtc.dev/earmarkiq/apis/earmark-api/llms.txt) · [OpenAPI document](https://skmtc.dev/earmarkiq/apis/earmark-api/revisions/4a2c41907105?raw)
