alerts.v1.PriceAlertService
CreateAlert
CreateAlert creates an active alert and records the current price of its price source as its reference price. An alert whose condition already holds at that price waits for the price to cross back first. Errors: - INVALID_ARGUMENT: malformed request, or UNKNOWN_SYMBOL. - FAILED_PRECONDITION: PRICE_SOURCE_UNSUPPORTED (INDEX_PRICE requested on a market without one), or ALERT_LIMIT_REACHED. - ALREADY_EXISTS: IDEMPOTENCY_CONFLICT; the original alert stands. - UNAVAILABLE: PRICE_UNAVAILABLE or SERVICE_UNAVAILABLE; retry the same request. - PERMISSION_DENIED: SUBACCOUNT_KEY_REFUSED. - UNAUTHENTICATED: missing or invalid credentials.
Request
curl --request POST \ \
--url 'https://api.testnet.polyester.com/alerts.v1.PriceAlertService/CreateAlert' \
--header 'Content-Type: application/json' \
--header 'Connect-Protocol-Version: 1' \
--data '{
"channels": [
"IN_APP"
],
"direction": "ABOVE",
"idempotencyKey": "idem_01J5EXAMPLE0000000000000",
"priceSource": "LAST_PRICE",
"priceTicks": "61000250000000",
"symbolId": 1
}'Responses
{
"alert": {
"alertId": "1",
"armed": false,
"channels": [
"IN_APP"
],
"createdAt": "2025-01-01T00:00:00Z",
"direction": "ABOVE",
"priceSource": "LAST_PRICE",
"priceTicks": "61000250000000",
"referencePriceTicks": "61000250000000",
"revision": "1",
"status": "ACTIVE",
"symbolId": 1,
"triggeredAt": "2025-01-01T00:00:00Z",
"triggeredPriceTicks": "61000250000000",
"updatedAt": "2025-01-01T00:00:00Z"
}
}alerts.v1.CreateAlertRequestalerts.v1.CreateAlertResponseNumeric spot market identifier; resolve it with GetSpotConfig.
Price crossing to wait for.
Price to watch. Unspecified means INDEX_PRICE on a market that has an index price, which is harder to move on a thin market, and LAST_PRICE otherwise; the returned alert states the price it watches.
Alert price in quote units scaled by 1e9, for example 90000000000000 for 90,000.
Where to deliver the alert when it fires: one to two distinct channels.
Optional client-chosen key, unique per caller, that makes creating idempotent: the same key and request return the alert the first request created, in its current state; another request with the same key is IDEMPOTENCY_CONFLICT. A create key is kept as long as its alert.
Public alert ID.
Numeric spot market identifier; resolve its symbol with GetSpotConfig.
Price crossing the alert waits for.
Price the alert watches.
Alert price in quote units scaled by 1e9.
Price of price_source when the alert was created or last set again, in quote units scaled by 1e9.
True once the price has been seen on the far side of the alert price, so the next crossing fires the alert. False while an alert created past its alert price waits for the price to move back.
Current state of the alert.
Where the alert is delivered when it fires, in ascending enum order.
Revision of the alert, starting at 1. It increases with every change the caller makes; pass it as expected_revision to UpdateAlert.
When the alert was created.
When the caller last changed the alert.
When the alert fired. Omitted unless status is TRIGGERED.
Price that fired the alert, in quote units scaled by 1e9. Zero unless status is TRIGGERED.
| Key | HTTP status | Connect code | Error | When |
|---|---|---|---|---|
| unauthenticated | 401 | unauthenticated | Unauthenticated | Authentication required. |
| permission-denied | 403 | permission_denied | Permission Denied | Permission denied. |
| invalid-argument | 400 | invalid_argument | Invalid Argument | Invalid argument. |
| not-found | 404 | not_found | Not Found | Not found. |
| unavailable | 503 | unavailable | Unavailable | Service unavailable. |