Rules
Create and schedule a new trading rule for the specified user. The rule definition includes any conditions, operators, and actions that make up the trading strategy. If the rule is time-based (scheduled), it will run according to the provided schedule. If the rule has immediate conditions or a direct trigger, it may execute trades as soon as conditions are met.
Authentication: Requires X-API-Key (business API key) and X-User-Public-Key (user's wallet public key) headers.
Optional human-readable name for the rule.
Client timestamp of when the rule is created, in ISO 8601 format. This can be used for request auditing or to schedule relative triggers (optional).
2025-07-16T10:11:35.214ZRule successfully created.
Bad Request – the request body is missing required fields or has invalid data.
Unauthorized – API key is missing or invalid.
Forbidden – The client is authenticated but not allowed to perform this action (e.g., using an API key without permission, or trying to create a rule for a user that is not accessible).
Internal Server Error – An unexpected server error occurred.
POST /v3/rules HTTP/1.1
Host: api.coinrule.com
X-API-Key: YOUR_API_KEY
X-User-Public-Key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 689
{
"name": "Daily DCA for ETH and AAVE",
"trigger": {
"type": "time",
"schedule": {
"start": "2025-07-16T11:08:00Z",
"interval": {
"unit": "days",
"value": 1
},
"repeatCount": 100
}
},
"data": {
"sequences": [
{
"t": "ACTION",
"d": {
"do": "trade",
"ta": {
"at": "buy",
"b": [
"ETH"
],
"q": "USDC",
"ot": "market",
"ort": "base",
"v": {
"v": "50",
"iv": "50",
"s": "USD"
},
"ls": 0,
"maxgf": "63244506424060",
"maxgfinbasecurrency": "0.2",
"maxpi": "",
"maxsl": "0.5",
"sr": null
}
}
},
{
"t": "ACTION",
"d": {
"do": "trade",
"ta": {
"at": "buy",
"b": [
"AAVE"
],
"q": "USDC",
"ot": "market",
"ort": "base",
"v": {
"v": "30",
"iv": "30",
"s": "USD"
},
"ls": 0,
"maxgf": "63244506424060",
"maxgfinbasecurrency": "0.2",
"maxpi": "",
"maxsl": "0.5",
"sr": null
}
}
}
]
},
"timestamp": "2025-07-16T10:11:35.214Z"
}{
"ruleId": "60d5adf568a3e60012345678",
"status": "active",
"message": "Rule created successfully."
}Last updated