# Positions

> Split collateral into a complete binary pair and merge a held pair back into collateral.

Outcome tokens enter or leave your account through trading or two explicit
position operations:

* **Split** locks collateral and mints one unit of each binary outcome per
  collateral unit.
* **Merge** burns equal quantities of both outcomes and returns collateral.

Every AGARA market is binary. Neg-risk events group binary member markets; a
member uses the same split and merge paths as a standalone market.

| Endpoint                                   | Authentication             |
| ------------------------------------------ | -------------------------- |
| `POST /trade/v1/portfolio/positions/split` | PAT with `positions:split` |
| `POST /trade/v1/portfolio/positions/merge` | PAT with `positions:merge` |

Split and merge are refused after a market is resolved. Supported standalone
markets use [automatic redemption](/docs/automatic-redemption) after resolution.

## Asynchronous lifecycle [#asynchronous-lifecycle]

For an AGARA market, both endpoints return `201` with an account-batch hash:

```json
{
  "batch_hash": "0x2174…",
  "status": "PENDING",
  "as_of": "2026-07-20T11:00:00.000Z"
}
```

Poll `GET /trade/v1/batches/{batch_hash}`. `PENDING` means only that the
request was accepted. `SETTLED` means the operation succeeded. For an isolated
`FAILED` batch, do not reuse provisional inventory until `unwound_at` is set.
`FAILED_DIVERGENT` requires review: keep mutations paused. A higher batch
closed after a lower `FAILED_DIVERGENT` batch is a further exception: its
`unwound_at` alone does not prove inventory was restored. Follow the
[stranded-sequence recovery
rule](/docs/api-traders/account-batches#what-you-observe-on-failure).

Operations queue per account and run in the order you started them, so a
second split, merge, or withdrawal is accepted while the first is still
settling. The queue has a limit; past it you get a `409` until one finishes.

Neither request has a client idempotency key. If a response is lost, the batch
may exist but you also lose its server-generated `batch_hash`. Treat the outcome
as unknown and do not resubmit automatically. Pause position mutations for
that market and reconcile the account stream, positions, and portfolio summary.
Do not trust a positions response while `unavailable_exchanges` includes
`AGARA`; retry that read before using it as evidence. If the outcome remains
uncertain, retain the request time and any `request_id` for investigation.

## Split [#split]

`POST /trade/v1/portfolio/positions/split`

```json
{
  "condition_id": "0x2174…",
  "collateral_amount_micro": "10000000"
}
```

`collateral_amount_micro` must be positive. `10000000` locks ten collateral
units and mints ten units of each outcome.

## Merge [#merge]

`POST /trade/v1/portfolio/positions/merge`

```json
{
  "condition_id": "0x2174…",
  "shares_micro": "5000000"
}
```

`shares_micro` is burned from **each** outcome. `5000000` burns five units of
both legs and returns five collateral units. Merge converts a complete pair at
one collateral unit per pair; it does not use the orderbook midpoint.

If you split 100 units and later sell 50 units of each outcome, the remaining
50-unit complete pair can be merged. A single unmatched outcome cannot be
merged alone.

## Errors [#errors]

This table is the AGARA request contract. Do not apply its retry guidance to a
condition served by another exchange.

| Status                                | Action                                                                                                                                           |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `400 malformed_json`                  | Correct the JSON body                                                                                                                            |
| `401` authentication code             | Replace or refresh the credential as instructed                                                                                                  |
| `403 forbidden_scope`                 | Add the required split or merge scope                                                                                                            |
| `403 account_quarantined`             | Stop account mutations; retain `request_id` and resolve the account review before continuing                                                     |
| `404 wallet_not_registered`           | Complete AGARA wallet registration for this account                                                                                              |
| `409` conflict code                   | Wait for an operation in your queue to finish                                                                                                    |
| `422 validation_failed`               | Correct a non-positive amount or unknown condition ID                                                                                            |
| `422 invalid_batch`                   | Correct an unsupported market route, operation, or batch composition                                                                             |
| `422 insufficient_balance`            | For split, reduce the amount or restore collateral; for merge, reduce the amount or restore both outcome balances needed for a complete pair     |
| `422 market_closed`                   | Stop position operations for that market                                                                                                         |
| `422 value_cap_exceeded`              | Reduce the requested value below the configured cap                                                                                              |
| `424` setup code                      | Finish wallet setup and signer authorization                                                                                                     |
| `500 internal_error`                  | Do not retry automatically; retain `request_id` for investigation                                                                                |
| `502 dependency_credentials_rejected` | Stop retrying, retain `request_id`, and contact support                                                                                          |
| `502 dependency_invalid_response`     | Do not retry automatically; retain `request_id` for investigation                                                                                |
| `502 dependency_outcome_unknown`      | The batch may already exist. Follow `recovery.resource.batch_hash` and poll that batch; do not submit another mutation first                     |
| `503 dependency_unavailable`          | For an AGARA request, back off with jitter and retry after a received typed response; a lost response is the separate outcome-unknown case above |

This table covers the immediate HTTP response. After a `201`, poll the batch:
a later terminal `failure` can report `insufficient_shares` or another
[account-batch failure](/docs/api-traders/account-batches#tracking-a-batch).

## Cross-match settlement [#cross-match-settlement]

Position tokens can also be created or burned when orders match:

| Match                     | Settlement                                        |
| ------------------------- | ------------------------------------------------- |
| Same-outcome SELL and BUY | Normal token transfer                             |
| Complementary BUY orders  | Mint a complete pair from both buyers' collateral |
| Complementary SELL orders | Merge the complete pair and return collateral     |

The fill's `settlement_mode` reports the path. SELL orders always require and
reserve actual outcome shares; complementary BUY orders can create inventory
from collateral during a match.
