> For the complete documentation index, see [llms.txt](https://docs.sigrex.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sigrex.io/api-reference/reference/strategies/reactions/code-reaction.md).

# Code Reaction

## GET /api/v2/strategy/reaction/code

> Get all code reactions

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{}},"paths":{"/api/v2/strategy/reaction/code":{"get":{"summary":"Get all code reactions","tags":["code-reaction"],"responses":{"200":{"description":"List of user's code reactions","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CodeReaction"}}}}}}}}}}
```

## POST /api/v2/strategy/reaction/code

> Create a new code reaction

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{"CreateCodeReactionRequest":{"type":"object","required":["data_webhook_id","code"],"properties":{"name":{"type":"string","description":"The name of the strategy max 255 characters"},"folder_id":{"type":"number","description":"The folder id of the reaction"},"data_webhook_id":{"type":"number","description":"The id of the data hook witch will be used to get data"},"send_signal":{"type":"boolean","description":"Set true to enable signal generation"},"webhook_id":{"type":"number","description":"The id of the bot hook where signal will be sent (required if send_signal is true)"},"symbol":{"type":"string","description":"The signal symbol or symbols of the strategy separated by comma (required if send_signal is true)"},"delay":{"type":"number","description":"Set how often the reaction will check for new signals. eg. 10 means 10 in 1 second"},"code":{"type":"string","description":"The JavaScript code of the strategy"},"use_price":{"type":"boolean","description":"Set true if you want to use price ($.Price) in code"},"exchange_id":{"type":"number","description":"The id of the exchange where the price is fetched (required exchange with hasExchangeRate set to true)"},"price_symbol":{"type":"string","description":"The symbol of the price (required if use_price is true)"}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/api/v2/strategy/reaction/code":{"post":{"summary":"Create a new code reaction","tags":["code-reaction"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCodeReactionRequest"}}}},"responses":{"201":{"description":"Code reaction created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodeReaction"}}}},"400":{"description":"Missing required fields, invalid code, or reaction limit reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Exchange, webhook, or data hook not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## GET /api/v2/strategy/reaction/code/{id}

> Get code reaction by ID

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/api/v2/strategy/reaction/code/{id}":{"get":{"summary":"Get code reaction by ID","tags":["code-reaction"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Code reaction details with storage","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodeReactionWithStorage"}}}},"400":{"description":"Missing id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Strategy not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## PUT /api/v2/strategy/reaction/code/{id}

> Update code reaction

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{"UpdateCodeReactionRequest":{"type":"object","required":["data_webhook_id","code"],"properties":{"name":{"type":"string","description":"The name of the strategy max 255 characters"},"folder_id":{"type":"number","description":"The folder id of the reaction"},"data_webhook_id":{"type":"number","description":"The id of the data hook witch will be used to get data"},"send_signal":{"type":"boolean","description":"Set true to enable signal generation"},"webhook_id":{"type":"number","description":"The id of the bot hook where signal will be sent (required if send_signal is true)"},"symbol":{"type":"string","description":"The signal symbol or symbols of the strategy separated by comma (required if send_signal is true)"},"delay":{"type":"number","description":"Set how often the reaction will check for new signals. eg. 10 means 10 in 1 second"},"code":{"type":"string","description":"The JavaScript code of the strategy"},"use_price":{"type":"boolean","description":"Set true if you want to use price ($.Price) in code"},"exchange_id":{"type":"number","description":"The id of the exchange where the price is fetched (required exchange with hasExchangeRate set to true)"},"price_symbol":{"type":"string","description":"The symbol of the price (required if use_price is true)"}}},"SuccessResponse":{"type":"object","properties":{"message":{"type":"string"}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/api/v2/strategy/reaction/code/{id}":{"put":{"summary":"Update code reaction","tags":["code-reaction"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateCodeReactionRequest"}}}},"responses":{"200":{"description":"Code reaction updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"400":{"description":"Missing id, invalid code, or validation errors","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Reaction, exchange, webhook, or data hook not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## DELETE /api/v2/strategy/reaction/code/{id}

> Delete code reaction

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{"SuccessResponse":{"type":"object","properties":{"message":{"type":"string"}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/api/v2/strategy/reaction/code/{id}":{"delete":{"summary":"Delete code reaction","tags":["code-reaction"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Code reaction deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"400":{"description":"Missing id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Strategy not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## POST /api/v2/strategy/reaction/code/duplicate

> Duplicate a code reaction

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/api/v2/strategy/reaction/code/duplicate":{"post":{"summary":"Duplicate a code reaction","tags":["code-reaction"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["id"],"properties":{"id":{"type":"string","description":"Reaction ID to duplicate"}}}}}},"responses":{"201":{"description":"Code reaction duplicated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodeReaction"}}}},"400":{"description":"Missing id or reaction limit reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## PUT /api/v2/strategy/reaction/code/{id}/reset

> Reset code reaction triggers and/or storage

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{"ResetCodeTriggersRequest":{"type":"object","required":["resetTriggers","resetStore"],"properties":{"resetTriggers":{"type":"boolean","description":"Set true to reset triggers"},"resetStore":{"type":"boolean","description":"Set true to reset store"}}},"SuccessResponse":{"type":"object","properties":{"message":{"type":"string"}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/api/v2/strategy/reaction/code/{id}/reset":{"put":{"summary":"Reset code reaction triggers and/or storage","tags":["code-reaction"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResetCodeTriggersRequest"}}}},"responses":{"200":{"description":"Triggers and/or storage reset successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"400":{"description":"Missing id, invalid options, or nothing to reset","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Strategy not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## PUT /api/v2/strategy/reaction/code/{id}/status

> Update code reaction status

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{"UpdateStatusRequest":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["ACTIVE","INACTIVE"]}}},"SuccessResponse":{"type":"object","properties":{"message":{"type":"string"}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/api/v2/strategy/reaction/code/{id}/status":{"put":{"summary":"Update code reaction status","tags":["code-reaction"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateStatusRequest"}}}},"responses":{"200":{"description":"Status updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"400":{"description":"Missing id, invalid status, or reaction limit reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Strategy not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## PUT /api/v2/strategy/reaction/code/{id}/public

> Update code reaction public visibility

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{"UpdatePublicRequest":{"type":"object","required":["isPublic"],"properties":{"isPublic":{"type":"boolean","description":"Set true to make the strategy public"}}},"SuccessResponse":{"type":"object","properties":{"message":{"type":"string"}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/api/v2/strategy/reaction/code/{id}/public":{"put":{"summary":"Update code reaction public visibility","tags":["code-reaction"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePublicRequest"}}}},"responses":{"200":{"description":"Public visibility updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"400":{"description":"Missing id or invalid public flag","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Strategy not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## DELETE /api/v2/strategy/reaction/code/{id}/store

> Delete code reaction storage

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{"SuccessResponse":{"type":"object","properties":{"message":{"type":"string"}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/api/v2/strategy/reaction/code/{id}/store":{"delete":{"summary":"Delete code reaction storage","tags":["code-reaction"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Storage deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}}},"400":{"description":"Missing id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Strategy not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
```

## GET /api/v2/strategy/reaction/code/folder

> Get all code reaction folders

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{}},"paths":{"/api/v2/strategy/reaction/code/folder":{"get":{"summary":"Get all code reaction folders","tags":["code-reaction"],"responses":{"200":{"description":"List of user's code reaction folders","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CodeReactionFolder"}}}}}}}}}}
```

## POST /api/v2/strategy/reaction/code/folder

> Create a new code reaction folder

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{}},"paths":{"/api/v2/strategy/reaction/code/folder":{"post":{"summary":"Create a new code reaction folder","tags":["code-reaction"],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"Folder name (optional, auto-generated if not provided)"}}}}}},"responses":{"201":{"description":"Folder created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodeReactionFolder"}}}},"400":{"description":"Invalid name or max folder limit reached"}}}}}}
```

## GET /api/v2/strategy/reaction/code/folder/root

> Get code reactions from root folder

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{}},"paths":{"/api/v2/strategy/reaction/code/folder/root":{"get":{"summary":"Get code reactions from root folder","tags":["code-reaction"],"responses":{"200":{"description":"List of code reactions in root folder","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CodeReaction"}}}}}}}}}}
```

## GET /api/v2/strategy/reaction/code/folder/{id}

> Get code reaction folder by ID

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}},"schemas":{}},"paths":{"/api/v2/strategy/reaction/code/folder/{id}":{"get":{"summary":"Get code reaction folder by ID","tags":["code-reaction"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"},"description":"Folder ID"}],"responses":{"200":{"description":"Folder with its items","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodeReactionFolder"}}}},"400":{"description":"Missing id"},"404":{"description":"Folder not found"}}}}}}
```

## PUT /api/v2/strategy/reaction/code/folder/{id}

> Update code reaction folder

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}}},"paths":{"/api/v2/strategy/reaction/code/folder/{id}":{"put":{"summary":"Update code reaction folder","tags":["code-reaction"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"},"description":"Folder ID"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"New folder name (optional, auto-generated if not provided)"}}}}}},"responses":{"200":{"description":"Folder updated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"400":{"description":"Missing id, invalid name, or folder not found"},"404":{"description":"Folder not found"}}}}}}
```

## DELETE /api/v2/strategy/reaction/code/folder/{id}

> Delete code reaction folder

```json
{"openapi":"3.0.0","info":{"title":"Sigrex API","version":"2.1.0"},"tags":[{"name":"code-reaction"}],"servers":[{"url":"https://api.sigrex.io"}],"security":[{"ApiKey":[],"Signature":[],"Timestamp":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"api-key","description":"Your public API key"}}},"paths":{"/api/v2/strategy/reaction/code/folder/{id}":{"delete":{"summary":"Delete code reaction folder","tags":["code-reaction"],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string"},"description":"Folder ID"}],"responses":{"200":{"description":"Folder deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"400":{"description":"Missing id, folder not found, or folder is not empty"},"404":{"description":"Folder not found"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sigrex.io/api-reference/reference/strategies/reactions/code-reaction.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
