# Create a trigger

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

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

Creates a trigger that runs its actions when all of its indicator conditions are met on the chosen market.

The handler checks no OAuth scope: any valid access token can call it. name and exchange are required; indicators and actions are lists of keys from Get trigger options, and indicator_configs and action_configs are objects keyed by those same keys. candle_size is in seconds. cooldown_val is minutes, hours or days (default minutes). status 1 enables the trigger. 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 |
|---|---|---|---|
| `id` | string | yes | Hopper ID. |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `trigger_name` | string | yes |  |
| `enabled` | integer | no |  |
| `exchange` | string | no |  |
| `trading_pair` | array of string | no |  |
| `candle_size` | string | no | One of: 5_min, 15_min, 30_min, 1_hour, 2_hours, 4_hours, 1_day. |
| `indicators` | object | no |  |
| &nbsp;&nbsp;`price` | object | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`condition` | string | no | One of: >, >=, =, <, <=. |
| &nbsp;&nbsp;&nbsp;&nbsp;`value` | number | no |  |
| &nbsp;&nbsp;`pct_change` | object | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`condition` | string | no | One of: >, >=, =, <, <=. |
| &nbsp;&nbsp;&nbsp;&nbsp;`value` | number | no |  |
| &nbsp;&nbsp;`RSI` | object | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`condition` | string | no | One of: >, >=, =, <, <=. |
| &nbsp;&nbsp;&nbsp;&nbsp;`value` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`RSI_period` | number | no |  |
| &nbsp;&nbsp;`stochastic` | object | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`condition` | string | no | One of: >, >=, =, <, <=. |
| &nbsp;&nbsp;&nbsp;&nbsp;`value` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`stoch_fast_K_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`stoch_slow_K_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`stoch_slow_KMA_type` | string | no | One of: sma, ema, wma, dema, tema, trima, kama, mama, t3. |
| &nbsp;&nbsp;&nbsp;&nbsp;`stoch_slow_D_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`stoch_slow_DMA_type` | string | no | One of: sma, ema, wma, dema, tema, trima, kama, mama, t3. |
| &nbsp;&nbsp;`stoch_RSI` | object | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`condition` | string | no | One of: >, >=, =, <, <=. |
| &nbsp;&nbsp;&nbsp;&nbsp;`value` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`stoch_RSI_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`stoch_RSI_fast_K_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`stoch_RSI_fast_D_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`stoch_RSI_fast_DMA_type` | string | no | One of: sma, ema, wma, dema, tema, trima, kama, mama, t3. |
| &nbsp;&nbsp;`bollinger_bands` | object | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`condition` | string | no | One of: signals_buy, signals_neutral, signals_sell. |
| &nbsp;&nbsp;&nbsp;&nbsp;`bollinger_bands_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`bollinger_bands_deviation_upper_band` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`bollinger_bands_deviation_lower_band` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`bollinger_bands_MA_type` | string | no | One of: sma, ema, wma, dema, tema, trima, kama, mama, t3. |
| &nbsp;&nbsp;`MACD` | object | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`condition` | string | no | One of: signals_buy, signals_neutral, signals_sell. |
| &nbsp;&nbsp;&nbsp;&nbsp;`MACD_fast_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`MACD_slow_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`MACD_signal_period` | number | no |  |
| &nbsp;&nbsp;`EMA` | object | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`condition` | string | no | One of: signals_buy, signals_neutral, signals_sell. |
| &nbsp;&nbsp;&nbsp;&nbsp;`EMA_short_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`EMA_long_period` | number | no |  |
| &nbsp;&nbsp;`SMA` | object | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`condition` | string | no | One of: signals_buy, signals_neutral, signals_sell. |
| &nbsp;&nbsp;&nbsp;&nbsp;`SMA_short_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`SMA_long_period` | number | no |  |
| &nbsp;&nbsp;`KAMA` | object | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`condition` | string | no | One of: signals_buy, signals_neutral, signals_sell. |
| &nbsp;&nbsp;&nbsp;&nbsp;`KAMA_short_period` | number | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`KAMA_long_period` | number | no |  |
| `actions` | object | no |  |
| &nbsp;&nbsp;`load_template` | integer | no |  |
| &nbsp;&nbsp;`set_buying_status` | integer | no |  |
| &nbsp;&nbsp;`set_selling_status` | integer | no |  |
| &nbsp;&nbsp;`hold_positions` | array of string | no |  |
| &nbsp;&nbsp;`release_positions` | array of string | no |  |
| &nbsp;&nbsp;`set_pct_profit` | object | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`coins` | array of string | no |  |
| &nbsp;&nbsp;&nbsp;&nbsp;`pct_profit` | number | no | Minimum 0. |
| &nbsp;&nbsp;`buy` | array of string | no |  |
| &nbsp;&nbsp;`sell` | array of string | no |  |
| &nbsp;&nbsp;`sell_everything` | integer | no |  |
| &nbsp;&nbsp;`send_email_msg` | string | no |  |
| `cooldown_until` | integer | no |  |
| `cooldown_time_unit` | string | no | One of: minutes, hours, days. |

## Example request

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

## 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.
