Create a bot
POST https://rest.haasapi.com/v1/bots
Creates a trading bot from a script, an account and a market. The bot is created DEACTIVATED - activate it with POST /bots/{bot_id}/start. Answers 201 with the created bot’s row (the same shape GET /bots lists).
Requires the bots scope.
Request body
Section titled “Request body”{ "name": "v1 API verify bot", "script_id": "7a4b2f91d6e53c8942a0bd7e1f5896c4", "account_id": "af85799d-a214-4fd2-92ea-443c5eed18ad", "market_tag": "GEMINI_BTC_USDT"}CreateBotRequest
Section titled “CreateBotRequest”| Field | Type | Description |
|---|---|---|
name |
string | Bot name, 1-150 characters. |
script_id |
string | The HaasScript the bot will run - a script_id the authenticated user can access. |
account_id |
string | The exchange account the bot trades on - an account_id from GET /v1/accounts. |
market_tag |
string | The market the bot trades - a market_tag from GET /v1/markets. |
Example request
Section titled “Example request”curl "https://rest.haasapi.com/v1/bots" \ -X POST \ -H "Authorization: Bearer hk_live_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"name":"v1 API verify bot","script_id":"7a4b2f91d6e53c8942a0bd7e1f5896c4","account_id":"af85799d-a214-4fd2-92ea-443c5eed18ad","market_tag":"GEMINI_BTC_USDT"}'Response
Section titled “Response”201 Created. Returns a Bot.
{ "bot_id": "e7bfbc5292494679bde177d0c1601e65", "name": "v1 API verify bot", "account_id": "af85799d-a214-4fd2-92ea-443c5eed18ad", "market_tag": "GEMINI_BTC_USDT", "script_id": "7a4b2f91d6e53c8942a0bd7e1f5896c4", "is_activated": false, "is_paused": false, "realized_profit": "0", "unrealized_profit": "0", "roi": "0"}Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
bot_id |
string | Bot identifier - the id every other bot endpoint accepts. Copy it from this endpoint; never construct one. |
name |
string | User-chosen bot name. |
account_id |
string | The exchange account the bot trades on - joins against account_id on /v1/accounts. |
market_tag |
string, nullable | The market the bot trades - joins against market_tag on /v1/markets. null when the bot has no market assigned. |
script_id |
string | The HaasScript the bot runs. |
is_activated |
boolean | Whether the bot is currently activated (running). |
is_paused |
boolean | Whether the bot is paused - activated but not processing ticks. |
realized_profit |
string (decimal) | Realized profit since activation, in the bot’s profit currency. |
unrealized_profit |
string (decimal) | Unrealized profit of open positions, in the bot’s profit currency. |
roi |
string (decimal) | Return on investment since activation, percent. |
Errors
Section titled “Errors”All errors are RFC 9457 problem documents.
| Status | Description |
|---|---|
400 |
The request is malformed (invalid limit, unusable cursor, …). (code: invalid_request) |
401 |
Missing, malformed, disabled, or revoked API key. (code: invalid_api_key) |
403 |
Creation refused: your plan’s bot limit is reached, or the account is not activated for bot creation. (code: forbidden) |
404 |
No accessible script with that script_id. An unknown account_id answers 404 with code account_not_found. (code: script_not_found) |
409 |
A request with this Idempotency-Key is still being processed. (code: idempotency_in_progress) |
422 |
The Idempotency-Key was already used with a different request. (code: idempotency_key_reuse) |
500 |
An unexpected error inside the API. Nothing about the request caused it; retry, and quote the instance value if it persists. (code: internal_error) |
502 |
An internal service answered in a way the API could not serve. Retry. (code: upstream_error) |
503 |
The request could not be served right now. Retry with the same key - do not discard it. (code: temporarily_unavailable) |
504 |
An internal service did not answer within the deadline. Retry with backoff. (code: upstream_timeout) |
{ "type": "https://docs.haasapi.com/errors/invalid_request", "title": "Invalid request", "status": 400, "detail": "The request is malformed (invalid limit, unusable cursor, …).", "code": "invalid_request"}