Skip to content

Circle events

POST /api/v1/circles/:number/events is the circle-scoped inbound event endpoint. Circle owners and admins can use their existing API keys to synchronize trading strategies from their own services or external systems into circles they manage. The first release supports 7 strategy lifecycle actions; all field validation, state transitions, visibility, and notification rules follow the native circle strategy model.

Item Value
Method and path POST /api/v1/circles/:number/events (:number is the circle number, e.g. 7773580)
Full URL https://ohmy.xin/api/v1/circles/:number/events
Auth & role Existing Bearer key (omx_live_...); the key owner must hold an existing owner or admin membership in the target circle
Request format Content-Type: application/json, body limit 16 KiB
Success response 202 Accepted with data.receipt_id and data.event_id (accepted, not yet applied)
Idempotency key (circle, caller, event_id) — identical replay returns the original receipt; different content returns 409
Strategy identity (circle, caller, source_external_id) — isolated per caller; rotating API keys preserves identity
Processing Asynchronous and serialized per strategy in acceptance order; inspect outcomes in Console → Strategies → External events

Authentication, rate limiting, and common response headers follow the shared API conventions; this page covers only what is specific to this endpoint.

  • No extra key type or scopes: reuse any active omx_live_... key generated on the Developer API page. One key can submit events to every circle where the key owner is an owner or admin.
  • Existing circle role required: the server resolves API key → API account → User and checks that user’s existing membership in the target circle. Only circle owner and admin roles are permitted; regular members, lecturers, non-members, and platform admins who are not admins of that circle receive 403 forbidden. Unknown circle numbers return 404 circle_not_found.
  • Author is always the caller: imported strategies are always authored by the key owner’s membership in that circle; requests cannot pass author_id.
  • Re-checked before async execution: after acceptance and before applying the event, the worker re-verifies that the API key is still active, the API account is not frozen, and the caller still has circle owner/admin access. If access was revoked while queued, the event is marked ignored (authorization_revoked) without modifying strategies.
  • Per-caller isolation: strategies are keyed by (circle, caller, source_external_id). Two admins using the same source_external_id never collide, and API-imported strategies stay separate from OpenX signal imports and manually created strategies. Rotating your API key does not change strategy identity.
POST /api/v1/circles/7773580/events HTTP/1.1
Host: ohmy.xin
Authorization: Bearer omx_live_xxxxxxxx_yyyyyyyy...
Content-Type: application/json
Accept: application/json
Location Name Required Description
Path number Yes Target circle number (same as /circles/:number).
Header Authorization Yes Bearer <API Key>.
Header Content-Type Yes Must have media type application/json (optional ; charset=utf-8), otherwise 422 invalid_event.

The request body must be a JSON object containing only these 4 top-level keys (any unknown key returns 422 invalid_event). v1 does not use body-level version, revision, or sequence fields.

Field Type Required Format & semantics
event_id string Yes Caller-generated idempotency ID for one action. 1–128 printable ASCII characters (^[!-~]{1,128}$, no whitespace). Keep identical across retries.
type string Yes Event action type — see the Action reference below. Unsupported types return 422 invalid_event.
occurred_at string Yes ISO 8601 business timestamp with timezone (e.g. 2026-12-01T08:30:00Z or 2026-12-01T16:30:00+08:00, up to 6 fractional digits). Keep unchanged across retries; the platform records received_at separately.
data object Yes Action payload, validated against a strict per-type allow-list; disallowed keys (such as state or author_id) return 422 invalid_event.

Every strategy action requires source_external_id inside data (1–128 printable ASCII chars, no whitespace) as your stable identifier for that strategy in the circle. If one account pushes from multiple external systems, prefix source_external_id and event_id per source (for example desk-a:btc-42).

type Required in data Optional in data Valid current state Effect
strategy.create source_external_id, symbol, side, entry_price, target_price, stop_price note, source_name, external_url, gate, audience, pending_stage_prices, publish Strategy does not exist Creates a strategy. Defaults to a draft (publish: false); publish: true requests publishing in the same transaction (governed by the circle’s auto-publish toggle).
strategy.update source_external_id + at least one editable field symbol, side, entry_price, target_price, stop_price, note, source_name, external_url, gate, audience, pending_stage_prices drafted (not pending settlement), running Partial update: patches only the fields present; omitted fields stay untouched. Rejected on terminal or pending-settlement strategies.
strategy.publish source_external_id None drafted (not pending settlement) Requests publishing a draft: immediately transitions to running (with notifications) when auto-publish is on, otherwise marks awaiting_review.
strategy.reach_stage source_external_id, level reached_price running Cumulatively marks take-profit stages 1..level reached at occurred_at; already-reached stages are locked.
strategy.take_profit source_external_id exit_price drafted (not pending settlement), running Settles as take-profit with closed_at = occurred_at. Running strategies settle and notify immediately; drafts follow review or silent settlement rules.
strategy.stop_loss source_external_id exit_price drafted (not pending settlement), running Settles as stop-loss with closed_at = occurred_at. Running strategies settle and notify immediately; drafts follow review or silent settlement rules.
strategy.cancel source_external_id None drafted (not pending settlement), running Cancels the strategy (cancelled). Cancelling a draft stays silent and is never shown to members.
Field Type Nullable Constraints & defaults
source_external_id string No 1–128 printable ASCII chars (^[!-~]{1,128}$, no whitespace). Required on all strategy actions.
symbol string No Trading symbol; non-empty string, up to 100 chars, no NUL bytes.
side string No Direction: long or short.
entry_price string No (see note) Entry price as a decimal string (^-?\d{1,16}(\.\d{1,8})?$). Never send JSON numbers.
target_price string No (see note) Target price as a decimal string (same pattern).
stop_price string No (see note) Stop-loss price as a decimal string (same pattern).
exit_price string Yes Settlement exit price (take_profit / stop_loss only); decimal string or null.
reached_price string Yes Actual price when the stage was reached (reach_stage only); decimal string or null (defaults to that stage’s target price when omitted or null).
pending_stage_prices array of strings No Up to 5 decimal price strings replacing unreached stages only; send [] to clear unreached stages. Reached stages are permanently locked. Pending prices must be strictly ordered between entry (or the last reached stage) and target_price (ascending for long, descending for short).
level integer No reach_stage only, 1–5. 1-based cumulative stage index; skipping ahead marks earlier unreached stages too (using their target prices).
note string Yes Strategy note, up to 4096 chars (no NUL); pass null to clear.
source_name string Yes Display name of the signal source, up to 4096 chars (no NUL); pass null to clear.
external_url string Yes Original signal URL (http:// or https://, no whitespace, up to 2048 chars); pass null or "" to clear.
gate string No Access gate: none (default) or reward_inviter. Omitted on update keeps the existing value.
audience string No Target audience; non-empty string up to 32 chars. Defaults to everyone, or a member tier key configured in the circle; omitted on update keeps the existing value. Unknown tiers fail asynchronously with invalid_strategy.
publish boolean No strategy.create only. Strict JSON boolean (true / false), default false.

A typical sequence from creation through update, stage hit, and take-profit settlement:

1. Create a strategy (draft or request publish)

Section titled “1. Create a strategy (draft or request publish)”
终端窗口
curl -s -X POST https://ohmy.xin/api/v1/circles/7773580/events \
-H "Authorization: Bearer omx_live_xxxxxxxx_yyyyyyyy..." \
-H "Content-Type: application/json" \
-d '{
"event_id": "desk-a:evt_0101",
"type": "strategy.create",
"occurred_at": "2026-12-01T08:00:00Z",
"data": {
"source_external_id": "desk-a:btc-42",
"symbol": "BTCUSDT",
"side": "long",
"entry_price": "96000",
"target_price": "102000",
"stop_price": "94500",
"pending_stage_prices": ["98000", "100000"],
"note": "4H breakout retest confirmed",
"source_name": "Desk A",
"external_url": "https://example.com/signals/btc-42",
"gate": "none",
"audience": "everyone",
"publish": true
}
}'

Every valid submission returns 202 Accepted:

{
"data": {
"receipt_id": 1024,
"event_id": "desk-a:evt_0101"
},
"meta": {
"request_id": "9f4f2d1e-7c3b-4c68-9f9f-0a1b2c3d4e5f"
}
}

3. Patch stop price and clear a nullable field

Section titled “3. Patch stop price and clear a nullable field”
终端窗口
curl -s -X POST https://ohmy.xin/api/v1/circles/7773580/events \
-H "Authorization: Bearer omx_live_xxxxxxxx_yyyyyyyy..." \
-H "Content-Type: application/json" \
-d '{
"event_id": "desk-a:evt_0102",
"type": "strategy.update",
"occurred_at": "2026-12-01T08:30:00Z",
"data": {
"source_external_id": "desk-a:btc-42",
"stop_price": "96500",
"note": null
}
}'
终端窗口
curl -s -X POST https://ohmy.xin/api/v1/circles/7773580/events \
-H "Authorization: Bearer omx_live_xxxxxxxx_yyyyyyyy..." \
-H "Content-Type: application/json" \
-d '{
"event_id": "desk-a:evt_0103",
"type": "strategy.publish",
"occurred_at": "2026-12-01T08:35:00Z",
"data": {
"source_external_id": "desk-a:btc-42"
}
}'
终端窗口
curl -s -X POST https://ohmy.xin/api/v1/circles/7773580/events \
-H "Authorization: Bearer omx_live_xxxxxxxx_yyyyyyyy..." \
-H "Content-Type: application/json" \
-d '{
"event_id": "desk-a:evt_0104",
"type": "strategy.reach_stage",
"occurred_at": "2026-12-01T10:15:00Z",
"data": {
"source_external_id": "desk-a:btc-42",
"level": 1,
"reached_price": "98120.5"
}
}'
终端窗口
curl -s -X POST https://ohmy.xin/api/v1/circles/7773580/events \
-H "Authorization: Bearer omx_live_xxxxxxxx_yyyyyyyy..." \
-H "Content-Type: application/json" \
-d '{
"event_id": "desk-a:evt_0105",
"type": "strategy.take_profit",
"occurred_at": "2026-12-01T14:20:00Z",
"data": {
"source_external_id": "desk-a:btc-42",
"exit_price": "102150"
}
}'

For stop-loss, use strategy.stop_loss; to cancel, use strategy.cancel with only source_external_id in data.

Idempotency, ordering & delivery guarantees

Section titled “Idempotency, ordering & delivery guarantees”
  1. Safe retries: on network timeouts or 5xx responses, resend the exact same event_id, occurred_at, and data. Deduplication is scoped to (circle, caller, event_id): identical replays return the original receipt_id (202) without re-applying the action.
  2. Conflict detection: reusing an event_id with a different type, occurred_at, or data returns 409 event_id_conflict.
  3. Fix with a new event_id: once a receipt reaches a terminal status (processed, ignored, or failed), that event_id is final. After fixing a payload or state problem, submit a new event_id.
  4. Serialized in acceptance order: pending events for one strategy (circle, caller, source_external_id) are processed strictly in server acceptance order. occurred_at is recorded for business timestamps and diagnostics — the server never reorders events by occurred_at, so submit events in business order.
  5. Durable intake: 202 is returned only after the receipt is persisted. If immediate job enqueueing fails, a per-minute recovery sweep picks up pending receipts automatically.

Circles default to manual review for API-imported strategies. Toggle Publish API-imported strategies automatically under Console → Strategies → Push settings:

  • Draft by default: strategy.create with publish omitted or false always creates a drafted strategy, even when auto-publish is enabled.
  • Review mode (default, auto-publish off):
    • strategy.create with publish: true or a later strategy.publish keeps the strategy in drafted and marks the receipt awaiting_review until an admin publishes it in the strategy list.
    • If a draft receives strategy.take_profit or strategy.stop_loss before being published, its pending terminal state, exit_price, and closed_at are stored for review; publishing it from the console applies that terminal state silently as a historical result (no push notification).
  • Auto-publish mode (toggle on):
    • strategy.create with publish: true creates, publishes, and updates the receipt in one transaction; if publishing fails, no partial draft is left behind.
    • strategy.publish transitions straight to running and notifies members.
    • Settling a draft directly transitions to take_profit or stop_loss silently without creating an intermediate running state or firing open-position alerts.
  • Running strategies need no extra review: once a strategy is running, subsequent update, reach_stage, take_profit, stop_loss, and cancel events apply directly and follow native notification, subscription feed, and visibility rules. Public-eligible strategies also appear in GET /api/v1/strategies.
  • Terminal states are final: settled (take_profit, stop_loss), cancelled, and soft-deleted strategies are never reopened.

202 Accepted confirms receipt, not execution. Circle owners and admins can inspect recent submissions under Console → Strategies → External events, ordered newest first, showing: Status, Event ID, Action, Caller, Occurred at, Received at, Strategy, Detail.

Status Console label Meaning
pending Pending Persisted and waiting for background execution.
awaiting_review Awaiting review Recorded a pending publish or settlement on a draft; waiting for an admin to publish in the strategy list. Resolves automatically to Applied once published, or Ignored if the draft is cancelled or deleted.
processed Applied Action succeeded on the linked strategy.
ignored Ignored No change applied (for example, the stage was already reached or access was revoked before processing).
failed Failed Async processing failed validation or state-machine checks — see the reason table below.
reason Status Meaning & fix
running awaiting_review Requested publish, waiting for review (enable auto-publish in Push settings or publish manually in the strategy list).
take_profit awaiting_review Take profit recorded on draft, waiting for review.
stop_loss awaiting_review Stop loss recorded on draft, waiting for review.
strategy_not_found failed No strategy with this source_external_id was created by this caller in this circle. Submit strategy.create first (or check the caller and ID).
strategy_already_exists failed A strategy with this source_external_id already exists for this caller (including settled or deleted records). Use strategy.update or a new source_external_id.
strategy_deleted failed The strategy was deleted; events never revive deleted strategies.
invalid_transition failed The current strategy state does not allow this action (e.g. updating a settled/cancelled strategy or publishing a non-draft).
invalid_strategy failed Payload failed model validations (common causes: null core price, out-of-order pending_stage_prices, or an audience tier not configured in the circle). Fix and resubmit with a new event_id.
stage_unavailable failed Stage cannot be reached (strategy is not running, or level exceeds the configured number of stages).
stage_already_reached ignored Every stage up to level was already reached; nothing changed.
authorization_revoked ignored Before processing, the key was disabled/revoked, the API account was frozen, or the caller lost circle owner/admin access.

In addition to the shared gateway errors (401, 429, 503, 500 in API reference), this endpoint returns:

HTTP status error.code When it happens
400 malformed_event Request body is not valid JSON.
403 forbidden Credentials are valid, but the key owner is not an owner or admin of the target circle.
404 circle_not_found No circle matches the :number in the URL.
409 event_id_conflict The same (circle, caller, event_id) was already accepted with different content.
422 invalid_event Content-Type is not application/json, body exceeds 16 KiB, unsupported type, disallowed keys, missing required fields, or invalid field values. error.message explains what failed and names the field when applicable.

Example 422 invalid_event:

{
"error": {
"code": "invalid_event",
"message": "Invalid stop_price."
},
"meta": {
"request_id": "9f4f2d1e-7c3b-4c68-9f9f-0a1b2c3d4e5f"
}
}

Example 409 event_id_conflict:

{
"error": {
"code": "event_id_conflict",
"message": "This event ID already has different content."
},
"meta": {
"request_id": "9f4f2d1e-7c3b-4c68-9f9f-0a1b2c3d4e5f"
}
}
  • API reference — authentication, rate limits, response envelope, and shared error codes
  • Quickstart — generate an API key and make your first call
  • Strategies list — GET /api/v1/strategies, reading publicly visible strategies
  • Customize Trading Hub — strategy console settings and signal import
  • OpenAPI spec — machine-readable OpenAPI 3.1 contract (including all 7 event schemas)