# Change settings of open positions

`POST https://api.cryptohopper.com/v1/hopper/{id}/position/setpositionsetting`

Part of [Positions](https://www.cryptohopper.com/api-documentation/api-reference/positions.md) in the Cryptohopper API reference.

Changes one or more settings on the given open positions: take profit, auto close time, stop-loss on or off, stop-loss percentage, trailing stop-loss on or off, trailing arm percentage and trailing percentage.

OAuth scope: `read`, `manage`

setting is an object of setting names and values. Allowed names: take_profit, auto_close_time (Unix timestamp in seconds; 0 or a time in the past turns auto close off), stop_loss_enabled, stop_loss_percentage, trailing_enabled, trailing_arm_percentage, trailing_percentage. Other names are ignored. setting can also be a comma separated list of names, with the values sent as top-level body fields. If some but not all of several settings fail, data is null. Not available for exchange arbitrage, market maker, copy and grid bots.

## Headers

| Name | Type | Required | Description |
|---|---|---|---|
| `access-token` | string | yes | The OAuth access token of the user. |

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | Hopper ID. |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `position_ids` | array of integer | no |  |
| `setting` | object | no |  |
| &nbsp;&nbsp;`take_profit` | number | no | Minimum 0. |
| &nbsp;&nbsp;`auto_close_time` | number | no | Minimum 0. |
| &nbsp;&nbsp;`stop_loss_percentage` | number | no | Minimum 0. |
| &nbsp;&nbsp;`stop_loss_enabled` | integer | no |  |
| &nbsp;&nbsp;`trailing_enabled` | integer | no |  |
| &nbsp;&nbsp;`trailing_arm_percentage` | number | no | Minimum 0. |
| &nbsp;&nbsp;`trailing_percentage` | number | no | Minimum 0. |

## Example request

```bash
curl -X POST "https://api.cryptohopper.com/v1/hopper/HOPPER_ID/position/setpositionsetting" \
  -H "access-token: YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"position_ids":[123456],"setting":{"take_profit":3.5,"stop_loss_enabled":1,"stop_loss_percentage":2}}'
```

## Response

Example response (illustrative values):

```json
{
    "data": "All updates successfull."
}
```

Status codes: 200. Errors return JSON with `status`, `error` and `message`, plus a numeric `code` when the error comes from the API itself rather than the gateway.
