> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tradara.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Replace account

> POST /v1/firm-control/accounts/{account_id}/replace — close one account and mint a replacement from the same plan.

Use this when a trader needs a **fresh** account on the same evaluation template: after a fail, a reset, or an administrative replacement. Tradara flattens the original account, closes it, then generates a new account for the same trader.

```http theme={null}
POST /v1/firm-control/accounts/{account_id}/replace
```

`operationId: replaceFirmAccount`

Requires `accounts:write`. A firm API key is automatically scoped to its firm.

## What it does

1. Cancels working orders and flattens open positions on the original account.
2. Sets the original account to `closed` and emits `account.closed`.
3. Generates a replacement from the same evaluation template and trading user.
4. Emits `account.created` for the new account.

If the original account is already closed (for example a retry after generation failed), flatten/close are skipped and only the replacement is created.

The replacement is a **new** `account_id`. Store it before sending new orders.

## Body

The request body is required. Send `{}` when you do not need a custom status.

| Field    | Required | Notes                                             |
| -------- | -------- | ------------------------------------------------- |
| `status` | no       | Status for the replacement. Defaults to `active`. |

```bash theme={null}
curl -X POST "$TRADARA_BASE_URL/v1/firm-control/accounts/$ACCOUNT_ID/replace" \
  -H "X-Tradara-Api-Key: $TRADARA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Response — `200 OK`

```json theme={null}
{
  "item": {
    "id": "7c2a9d11-4b8e-4f01-9a33-0c1d2e3f4a5b",
    "account_name": "ONYXEV1234",
    "status": "active"
  },
  "closed_account": {
    "id": "5b1c8a2e-9f2d-4d3c-b6f0-2b6c5b6e1f9a",
    "status": "closed"
  },
  "flatten": {
    "cancelled_count": 2,
    "closed_count": 1
  }
}
```

`item` is the new account. Use `item.id` on the [Trading API](/trading/overview).

<Warning>
  This does not copy cash, session anchors, or live risk state from the closed account. The replacement starts from the evaluation template, the same way [Generate account](/prop-firm/provisioning/generate-account) does.
</Warning>

## Errors

| HTTP          | Meaning                                                                              |
| ------------- | ------------------------------------------------------------------------------------ |
| `400`         | Missing firm scope or invalid account id.                                            |
| `403`         | Caller lacks `accounts:write`.                                                       |
| `404`         | Account is unknown or not in your firm.                                              |
| `409`         | Account has no evaluation template, or no trading user to attach the replacement to. |
| `502` / `503` | Flatten or accounts service unavailable.                                             |
