# Update trigger

`PATCH https://api.cryptohopper.com/v1/hopper/{id}/trigger/{trigger_id}`

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

Updates a trigger of the hopper. All trigger fields are overwritten, so send the complete trigger, as for Create a trigger.

The handler checks no OAuth scope: any valid access token can call it. Not available for AI bots.

## Headers

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

## Path parameters

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

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `trigger_id` | integer | yes |  |
| `name` | string | no |  |
| `enabled` | integer | no |  |
| `exchange` | integer | no |  |
| `trading_pair` | array of integer | no |  |
| `candle_size` | integer | no |  |
| `indicators` | array of object | no |  |
| &nbsp;&nbsp;`type` | string | no |  |
| &nbsp;&nbsp;`items` | integer | no |  |
| `actions` | array of object | no |  |
| &nbsp;&nbsp;`type` | string | no |  |
| &nbsp;&nbsp;`items` | integer | no |  |
| `cooldown_until` | integer | no |  |
| `cooldown_time_unit` | integer | no |  |

## Example request

```bash
curl -X PATCH "https://api.cryptohopper.com/v1/hopper/HOPPER_ID/trigger/TRIGGER_ID" \
  -H "access-token: YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Stop buying above 72k","exchange":"binance","market":"BTCUSDT","candle_size":1800,"indicators":["price"],"indicator_configs":{"price":{"trig_when":">","trig_when_value":72000}},"actions":["setbuyingstatus"],"action_configs":{"setbuyingstatus":{"config":0}},"status":1,"cooldown_count":1,"cooldown_val":"hours"}'
```

## Response

Example response (illustrative values):

```json
{
    "data": {
        "trigger_id": 12845001,
        "status": 1,
        "triggers_left": 4,
        "triggers_total": 1,
        "message": "Trigger saved."
    }
}
```

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.
