API reference ยท Alerts
/v1/accounts/{account_id}/alertsCreate a price alert.
ReadIdempotency-Key
Arms an alert on the market: alert.triggered is sent once (the account stream, webhooks, GET /v1/events) when the price reaches the level. Its condition, above or below, is set from the price now. A read key is enough: an alert never trades.
Path parameters#
-
The account number.
Headers#
-
A unique value per action: a retry with the same value never does it twice.
Request body#
-
A market id: the asset and USD; an option adds its venue or hours after a dot.
-
The level; not the price now.
-
notestringYour note (at most 280 characters).
Responses#
201Created
-
The alert.
-
The account number.
-
A market id: the asset and USD; an option adds its venue or hours after a dot.
-
Its level.
-
above: it fires once the price reaches the level from below; below: from above. Set from the price when the level was set.
One of
abovebelow -
Your note, sent with it.
-
armed: it waits for its level. triggered: it fired (rearm arms it again). disabled: its account or market went away before it fired.
One of
armedtriggereddisabled -
The price it watches: the market's last trade (the middle of the book until there is one), the price trailing stops follow.
One of
last -
The price it fired at.
-
When it fired.
-
Why it was disabled.
One of
account_removedmarket_removed -
When it was set.
-
Its latest change.
400The request is malformed.
{
"error": {
"type": "invalid_request",
"code": "invalid_request",
"message": "The request is not valid.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#invalid_request"
}
}401The request has no Authorization header.
{
"error": {
"type": "authentication",
"code": "missing_api_key",
"message": "No API key: send it as Authorization: Bearer <key>.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#missing_api_key"
}
}403The key only works from the addresses you listed.
{
"error": {
"type": "permission",
"code": "ip_not_allowed",
"message": "This address is not on the key's allowlist.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#ip_not_allowed"
}
}404The account does not exist in this environment, or the key does not reach it.
{
"error": {
"type": "not_found",
"code": "account_not_found",
"message": "No account with that id is reachable with this key.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#account_not_found"
}
}409A retry came while the first was not finished.
{
"error": {
"type": "conflict",
"code": "operation_in_progress",
"message": "The first request with this Idempotency-Key is still running.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": true,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#operation_in_progress"
}
}422The key is limited to some markets (details.markets).
{
"error": {
"type": "key_limit",
"code": "key_market_not_allowed",
"message": "This key may not trade this market.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": false,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#key_market_not_allowed"
}
}429A request budget is used up (details.scope says which).
{
"error": {
"type": "rate_limit",
"code": "rate_limited",
"message": "Too many requests: slow down.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": true,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#rate_limited"
}
}500An error we did not expect.
{
"error": {
"type": "server",
"code": "internal_error",
"message": "Something went wrong on our side.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": true,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#internal_error"
}
}503The trading engine did not give a complete answer in time; nothing partial is returned.
{
"error": {
"type": "engine",
"code": "state_unavailable",
"message": "The account's figures cannot be read right now.",
"request_id": "req_0f9c2a7d8e1b4c6a9f3e5d7b1a2c4e6f",
"retryable": true,
"doc_url": "https://docs.phoenixperpsfunding.com/reference/errors#state_unavailable"
}
}Errors#
Codes this endpoint can return. Match on the code, never on the message.
- 401
missing_api_key - 401
invalid_api_key - 401
expired_api_key - 401
revoked_api_key - 401
invalid_token - 401
expired_token - 401
revoked_token - 401
wrong_resource - 401
wrong_environment - 403
ip_not_allowed - 403
api_disabled - 429
rate_limited - 404
account_not_found - 503
state_unavailable - 400
invalid_request - 400
unknown_field - 400
idempotency_key_required - 400
invalid_idempotency_key - 400
idempotency_key_reused - 409
operation_in_progress - 404
market_not_found - 422
key_market_not_allowed - 503
stale_quote - 422
alert_at_price - 422
alert_limit