> For the complete documentation index, see [llms.txt](https://apidocs-ga092.stockhero.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs-ga092.stockhero.ai/bot-execution/update-bot.md).

# Update Bot

**Update existing bot**

<mark style="color:green;">**`POST`**</mark> **`https://api.aitrade.com/api/bots/{bot_id}`**

**Request Body**

<table><thead><tr><th width="241">Name</th><th width="121">Type</th><th width="109" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>exchange_pair_id</td><td>integer</td><td>false</td><td>A unique ID to identify the pair. Refer <a href="/pages/JTqVYPFsrzMdDy4isGwh">Trading Pairs</a> Api to get the list of pairs available. <code>pair_id</code> of a pair object is passed as <code>exchange_pair_id</code></td></tr><tr><td>stock_code</td><td>string</td><td>false</td><td>Stock symbol</td></tr><tr><td>initial_fund</td><td>float</td><td>false</td><td>Fund allocation for the bot</td></tr><tr><td>frequency</td><td>integer</td><td>false</td><td>options are, 1,5,15,60,240,1440</td></tr><tr><td>base_order_type</td><td>string</td><td>false</td><td>Options <code>static</code>, <code>dynamic</code>. Static will always use the same Base Order Limit set, regardless of the bots performance. Dynamic allows the bot to use profits from it’s previous trades for it’s next trade or lowers the base order if it has encountered a loss previously</td></tr><tr><td>order_type</td><td>string</td><td>false</td><td>Options are <code>limit</code>,<code>market</code> . Limit order is normally used to ensure price level especially when your take profit level is small. Market order is typically used when you need to ensure immediate Filled condition</td></tr><tr><td>base_order_percentage</td><td>integer</td><td>false</td><td>Base order limt</td></tr><tr><td>profit</td><td>float</td><td>false</td><td>take profit percentage</td></tr><tr><td>stop_loss</td><td>float</td><td>false</td><td>Stop loss percentage</td></tr><tr><td>name</td><td>string</td><td>false</td><td>A name to identify the bot created</td></tr><tr><td>bot_indicators</td><td>Object</td><td>false</td><td>An object containing the indicators.<a data-footnote-ref href="#user-content-fn-1"><br></a>Please refer to <strong>Bot Indicator Parameter Sample</strong> </td></tr><tr><td>indicator_triggers_entry</td><td>integer</td><td>false</td><td>Number of entry indicators</td></tr><tr><td>indicator_triggers_exit</td><td>integer</td><td>false</td><td>Number of exit indicators</td></tr><tr><td>category</td><td>string</td><td>false</td><td><code>manual</code>, <code>marketplace</code>, <code>marketplace_custom</code></td></tr><tr><td>apply_to_current_deal</td><td>integer</td><td>false</td><td>Options are 0 or 1</td></tr></tbody></table>

**Bot Indicator Parameter Sample**

Both exit and entry indicators are send together as an array of an object . To get the default available indicators please refer to [Indicators API](/bot-execution/indicators.md)

Several indicators support settings that require more than two values. In such cases, utilize `value3`, `value4`, `value5,` and `value6` accordingly. If a setting does not apply to a specific indicator, pass `null`

```javascript
   {
        "id": null, // Id null when creating new and is returned after creating bot. Has to pass id when updating 
        "name": "EMA",
        "description": null,
        "period_num": 50,
        "value2": 9,
        "value3": null, // null if there is no values for the indicator setting
        "value4": null,
        "value5": null,
        "value6": null,
        "updated_at": null,
        "created_at": null,
        "indicator_id": 2, // should match the id of the indicator from indicator api. 
        "type": "entry"
    },
    {
        "id": null,
        "name": "Stochastic RSI",
        "description": null,
        "period_num": 14,
        "value2": 18.5,
        "value3": 81.5,
        "value4": 1,
        "value5": 18.5,
        "value6": 81.5,
        "updated_at": null,
        "created_at": null,
        "indicator_id": 3,
        "type": "exit"
    }
]
```

**Responses:**

* **Success (200)**: Returns the details of the bot that has been created or updated. Details include ID, name, status, and other specific settings.
* **Failure (401)**: Unauthenticated, indicating you're not logged in or lack permission to carry out the request.
* **Failure (500)**: Server error.&#x20;

{% tabs %}
{% tab title="200  successfully returned" %}

```javascript
{
    "code": 200,
    "message": "Success",
    "bot": {
        "id": 13331,
        "user_id": 1,
        "name": "New Bot",
        "status": "active",
        "frequency": 15,
        "exchange_pair_id": 2,
        "strategy": "Long",
        "initial_fund": 1000,
        "base_order_percentage": 50,
        "base_order_type": "static",
        "extra_order_percentage": 25,
        "stop_loss": 0,
        "updated_at": "2024-03-26 16:13:59",
        "created_at": "2024-03-26 16:13:59",
        "pair_id": 1,
        "order_type": "market",
        "indicators":[],
        "category":"manual",
    }
}
```

{% endtab %}

{% tab title="401 Unauthenticated" %}

```
{
  "code": 401,
  "success": false,
  "message": "Unauthenticated."
}
```

{% endtab %}
{% endtabs %}

[^1]: Bot&#x20;
