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

# Edit Order Strategy

> This endpoint allows users to replace the definition of an open order strategy.

```http theme={null}
POST /api/v1/order_strategies/edit
```

Replaces a strategy's `params` and schedule. Send the full definition, not only the fields that change.

#### Operation Type (for Signing)

| Header Field | Type | Content |
| - | - | - |
| `"type"` | string | `"edit_order_strategy"` |

#### Request Body

<table><thead><tr><th width="200">Field</th><th width="98">Type</th><th width="95">Need</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td>`"account"`</td><td>string</td><td>required</td><td>User's wallet address</td><td>`42trU9A5...`</td></tr><tr><td>`"signature"`</td><td>string</td><td>required</td><td>Cryptographic signature</td><td>`5j1Vy9Uq...`</td></tr><tr><td>`"timestamp"`</td><td>integer</td><td>required</td><td>Current timestamp in milliseconds</td><td>`1716200000000`</td></tr><tr><td>`"strategy_id"`</td><td>string</td><td>required</td><td>Strategy ID (UUID)</td><td>`0f8e7c2a-...`</td></tr><tr><td>`"expected_revision"`</td><td>integer</td><td>required</td><td>The strategy's current `revision`. The edit fails if the strategy changed since you read it</td><td>`1`</td></tr><tr><td>`"strategy_type"`</td><td>string</td><td>required</td><td>Must match the strategy's current type</td><td>`trailing_stop`</td></tr><tr><td>`"params"`</td><td>object</td><td>required</td><td>New parameters. See [Strategy parameters](https://docs.pacifica.fi/api-documentation/api/rest-api/order-strategies/strategy-parameters.md)</td><td>See below</td></tr><tr><td>`"scheduled_start_at"`</td><td>integer</td><td>optional</td><td>Start time in milliseconds. Can change only while the strategy is `pending`</td><td>`1716203600000`</td></tr><tr><td>`"scheduled_end_at"`</td><td>integer</td><td>optional</td><td>End time in milliseconds</td><td>`1716207200000`</td></tr><tr><td>`"expires_at"`</td><td>integer</td><td>optional</td><td>Expiry time in milliseconds</td><td>`1716207200000`</td></tr><tr><td>`"agent_wallet"`</td><td>string</td><td>optional</td><td>Agent wallet address</td><td>`69trU9A5...`</td></tr><tr><td>`"expiry_window"`</td><td>integer</td><td>optional</td><td>Signature expiry in milliseconds</td><td>`30000`</td></tr></tbody></table>

```json theme={null}
{
  "account": "42trU9A5...",
  "signature": "5j1Vy9Uq...",
  "timestamp": 1716200000000,
  "strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
  "expected_revision": 1,
  "strategy_type": "trailing_stop",
  "params": {
    "symbol": "BTC",
    "side": "ask",
    "direction": "exit",
    "size_mode": "defined",
    "amount": "0.1",
    "trail_bps": 300,
    "trigger_price_type": "mid",
    "child_order_type": "market",
    "reduce_only": true
  }
}
```

#### What you can edit

* A strategy that has not placed any orders yet. This includes a strategy that is `pending`, or `open` and waiting for its trigger.
* A trailing stop that is already tracking the price. You can change its trail and other settings, but not `symbol` or `side`.

You cannot edit a strategy that is `paused` or finished, or a trigger swarm that has already triggered.

#### Response

* Status 200: Strategy updated

```json theme={null}
{
  "success": true,
  "data": {
    "strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
    "revision": 2
  },
  "error": null,
  "code": null
}
```

| Field | Type | Description |
| - | - | - |
| `'strategy_id'` | string | Strategy ID (UUID) |
| `'revision'` | integer | New revision. Use it for the next edit |

* Status 400: Invalid parameters, or the strategy cannot be edited. `STRATEGIST_NOT_EDITABLE` means the strategy's state does not allow edits. `STRATEGIST_FIELD_NOT_EDITABLE` means you changed a field that is fixed, such as `strategy_type`
* Status 404: Strategy not found (`STRATEGIST_NOT_FOUND`)
* Status 422: `expected_revision` does not match (`STRATEGIST_REVISION_CONFLICT`). Read the strategy again and retry
* Status 500: Internal server error

#### Code Example (Python)

```python theme={null}
import requests

payload = {
    "account": "42trU9A5...",
    "signature": "5j1Vy9Uq...",
    "timestamp": 1716200000000,
    "strategy_id": "0f8e7c2a-4b1d-4e5f-9a3b-2c1d0e9f8a7b",
    "expected_revision": 1,
    "strategy_type": "trailing_stop",
    "params": {
        "symbol": "BTC",
        "side": "ask",
        "direction": "exit",
        "size_mode": "defined",
        "amount": "0.1",
        "trail_bps": 300,
        "trigger_price_type": "mid",
        "child_order_type": "market",
        "reduce_only": True
    }
}

response = requests.post(
    "/api/v1/order_strategies/edit",
    json=payload,
    headers={"Content-Type": "application/json"}
)

data = response.json()
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.