Upscale
Menu
On this page

Crear nueva orden

Probar ↓
POST/orders
Crear nueva ordenTrading

Coloca una orden y la devuelve tal como la almacenó el motor de trading. Las órdenes de incremento (market, limit, stop_market, stop_limit) abren o amplían una posición; las órdenes de cierre (stop, take, trailing_stop) se vinculan a una posición existente mediante positionId.

amount se lee en una unidad diferente por cada uno de los dos: en una orden de aumento es un importe de cotización reservado del saldo libre, en una orden de cierre es el tamaño del activo base de la posición a cerrar, sin reservar nada. El resto de los campos de tamaño (expectedAmount, sizeMode, baseSize, leverage) pertenecen solo a las órdenes de aumento.

Más allá del esquema a nivel de campo, la solicitud se verifica para:

  • Forma para el tipo. Cada rechazo aquí es un 400 cuyo código nombra la combinación de campos en falta:
    • tamaño — amount_not_positive, base_size_required, base_size_negative, base_size_not_allowed;
    • apalancamiento — leverage_required, leverage_negative;
    • precio de activación — trigger_price_required, trigger_price_negative;
    • stop-loss / take-profit adjuntos a una orden de incremento — stop_trigger_price_negative, take_trigger_price_negative, stop_trigger_price_gt_trigger_price, stop_trigger_price_lt_trigger_price, take_trigger_price_gt_trigger_price, take_trigger_price_lt_trigger_price;
    • precio de stop-limit — stop_limit_price_required, stop_limit_price_negative, stop_limit_price_gt_trigger_price, stop_limit_price_lt_trigger_price;
    • stop móvil — trailing_stop_activation_price_negative, trailing_stop_offset_required, trailing_stop_offset_conflict, trailing_stop_offset_negative, trailing_stop_offset_percent_negative, trailing_stop_offset_percent_gte_one;
    • órdenes de cierre — position_id_required.
  • Apalancamiento de una orden de incremento. Debe mantenerse dentro de los límites del mercado: no por debajo del mínimo del mercado ni por encima del máximo de la fase, con invalid_leverage (leverage más minLeverage o maxLeverage en el cuerpo).
  • Cuenta. Debe pertenecer al llamador y estar en un estado de trading; las órdenes de incremento se rechazan además mientras la cuenta está bloqueada por el límite de capital gestionado, y necesitan amount disponible como saldo libre.
  • Mercado. Debe estar abierto y dentro de la categoría en la que la cuenta puede operar (cripto o RWA). Un mercado de solo cierre no acepta nada más que una orden take creada sin un precio de activación.
  • Posición, cuando se proporciona positionId: debe existir (position_not_found), estar abierta, estar en la misma cuenta, pertenecer al mismo mercado y tener la misma dirección que la orden (position_not_available).
  • Precio de activación, contra el precio de mercado actual y — para stop / take — contra el precio de liquidación de la posición (trigger_price_gt_current, trigger_price_lt_current, trigger_price_gt_liquidation, trigger_price_lt_liquidation). Una orden market con un stop-loss / take-profit adjunto se comprueba contra el precio de liquidación que tendría su posición después de la ejecución: market_price_unavailable cuando no hay un precio actual contra el que comprobar, order_validation_invariant cuando faltan los campos de tamaño necesarios para esa proyección.
  • Nocional de una orden de aumento. (amount − fee) × leverage debe ajustarse al nocional abierto máximo que el mercado permite en esa dirección (order_exceeds_max_open_notional).

Una orden diferida no se ejecuta aquí, por lo que aún puede fallar cuando su disparador se active más tarde: entonces termina con el estado canceled_by_error y un errorCode (insufficient_reserve_at_execution, order_below_min_notional, order_exceeds_market_depth, order_exceeds_max_open_notional, order_zero_size_at_execution, slippage_tolerance, market_close_only_at_execution), y se libera su reserva.

Envía un encabezado x-idempotency-key para que la llamada sea segura frente a repeticiones: dentro de la ventana de repetición indicada en ese encabezado, la misma clave en la misma ruta reproduce la respuesta almacenada (marcada con X-Idempotency-Cached: true y X-Idempotency-Timestamp) en lugar de actuar de nuevo, y una segunda llamada que llegue mientras la primera aún se está ejecutando recibe 409 (idempotency_key_in_flight).

URL base https://api.upscale.trade

Autorización

bearerhttp · bearerobligatorio

Clave de API personal, con el prefijo usk_.

Parámetros

Cabecera
x-idempotency-keystringopcional

Clave de idempotencia — cualquier cadena opaca, un uuid v4 funciona bien. Repetir la llamada con la misma clave en esta ruta dentro de 1 hora reproduce la respuesta almacenada en lugar de actuar de nuevo; una reproducción incluye X-Idempotency-Cached: true y X-Idempotency-Timestamp. Omite el encabezado para optar por no participar.

Ejemplo: 9f1c2b7e-5a3d-4f61-9b0e-2c7d4a8e1f35

Cuerpo de la solicitud · obligatorio

accountIdstring · uuidobligatorio

Trader account the order is placed on. Must belong to the caller.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Ejemplo: 00000000-0000-4000-8000-000000000000
marketIdstring · uuidobligatorio

Market the order is placed on, as returned by GET /v2/markets.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Ejemplo: 00000000-0000-4000-8000-000000000000
typestring · enumobligatorio

Order type. Increase (position-opening) types: market, limit, stop_market, stop_limit. Close types, attached to an existing position: stop, take, trailing_stop. liquidation is raised by the platform itself and add_margin / remove_margin are legacy — none of the three is accepted here.

Permitido: "market" "limit" "stop" "trailing_stop" "take" "stop_limit" "stop_market"
Ejemplo: market
directionstring · enumobligatorio

Order direction. For a close order it must match the direction of the position it is attached to.

Permitido: "long" "short"
Ejemplo: long
amountstring · int32obligatorio

What the order is sized by, fp9 raw — the unit depends on the order class. On an increase order (market, limit, stop_market, stop_limit) it is a quote amount reserved from the free balance (margin, fee, spread and buffer): the account must hold at least this much, and the reserve is released when the order is cancelled. On a close order (stop, take, trailing_stop) it is the base asset size of the position to close and nothing is reserved; a size larger than the position holds closes it in full.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 100000000000
Campos opcionales: 12
positionIdstring · uuid · nullableopcional

Position a close order (stop, take, trailing_stop) is attached to. Required for those types, ignored for increase orders.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Ejemplo: 00000000-0000-4000-8000-000000000000
expectedAmountstring · int32 · nullableopcional

Slippage tolerance for increase orders: the position size the caller expects for amount, fp9 raw. Execution outside the tolerance fails with slippage_tolerance. Omitted or 0 — no tolerance check. Not applicable to close orders.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 0
leveragestring · int32 · nullableopcional

Leverage, fp9 raw (10000000000 = 10x). Required for increase orders and must be within the leverage bounds of the market.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 10000000000
triggerPricestring · int32 · nullableopcional

Price at which the order fires, fp9 raw. Required for limit, stop, take, stop_market and stop_limit, and rejected for market. For stop / take, 0 means the order is created without a trigger and can be set later.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 65000000000000
stopTriggerPricestring · int32 · nullableopcional

Stop-loss attached to an increase order, fp9 raw. Must sit below the entry trigger price for long and above it for short.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
takeTriggerPricestring · int32 · nullableopcional

Take-profit attached to an increase order, fp9 raw. Must sit above the entry trigger price for long and below it for short.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
trailingStopActivationPricestring · int32 · nullableopcional

Price at which a trailing_stop starts trailing, fp9 raw. Omitted — the order trails from the moment it is created.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
trailingStopOffsetstring · int32 · nullableopcional

Trailing distance as an absolute quote amount, fp9 raw. Exactly one of trailingStopOffset / trailingStopOffsetPercent is required.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
trailingStopOffsetPercentstring · int32 · nullableopcional

Trailing distance as a fraction of price, fp9 raw and strictly below 1000000000 (100%). Exactly one of trailingStopOffset / trailingStopOffsetPercent is required.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 50000000
stopLimitPricestring · int32 · nullableopcional

Limit price a stop_limit order is placed at once its trigger fires, fp9 raw. Required for that type; must be at or below the trigger price for long and at or above it for short.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
sizeModestring · enumopcional

How the size of an increase order is expressed: quote (default) sizes it by amount, base sizes it by baseSize while amount stays the reserve. Increase orders only — a close order is always sized by amount in base asset units.

Permitido: "quote" "base"
Ejemplo: quote
baseSizestring · int32 · nullableopcional

Order size in base asset units, fp9 raw. Required when sizeMode is base and rejected otherwise, and meaningful for increase orders only.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000

Ejemplos

curl --request POST 'https://api.upscale.trade/orders' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "accountId": "00000000-0000-4000-8000-000000000000",
  "marketId": "00000000-0000-4000-8000-000000000000",
  "type": "market",
  "direction": "long",
  "amount": "100000000000"
}'

Respuestas

401

No autorizado

403

La cuenta pertenece a otro usuario (account_access_denied), o la solicitud se autentica con una clave de API mientras api_trading está deshabilitado en la cuenta (api_trading_not_enabled). El trading en la cuenta ha terminado en su estado actual (challenge_closed), o la cuenta está bloqueada por el límite de capital gestionado (funded_limit_trading_locked). El mercado está en pausa (market_paused) o solo acepta órdenes de cierre (market_close_only).

404

No existe tal cuenta, mercado o posición.

409

Otra llamada con la misma x-idempotency-key sigue en ejecución (idempotency_key_in_flight). Reintenta cuando haya terminado.

429

Se superó el límite de velocidad de la clave de API (api_key_rate_limit_exceeded). Retry-After indica cuándo volver; el cuerpo incluye el bucket (read / write), la ventana que se activó, su límite y retryAt.

defaultRespuestaapplication/json
idstring · uuidobligatorio

Order identifier.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Ejemplo: 00000000-0000-4000-8000-000000000000
txIdstringobligatorio

Order identifier. Kept for backward compatibility, always equal to id.

Ejemplo: string
traderstring · uuidobligatorio

Trader account the order belongs to.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Ejemplo: 00000000-0000-4000-8000-000000000000
marketstring · uuidobligatorio

Market the order is placed on.

pattern
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
Ejemplo: 00000000-0000-4000-8000-000000000000
statusstring · enumobligatorio

Lifecycle state: active while it waits, executed once filled, canceled when cancelled by the trader or the platform, canceled_by_update when replaced by an edit, canceled_by_position when the position it was attached to went away, canceled_by_error when execution failed — see errorCode.

Permitido: "active" "canceled" "canceled_by_update" "canceled_by_error" "canceled_by_position" "executed"
Ejemplo: active
typestring · enumobligatorio

Order type. liquidation marks an order the engine raised itself.

Permitido: "market" "limit" "stop" "trailing_stop" "take" "stop_limit" "stop_market" "liquidation"
Ejemplo: market
directionstring · enumobligatorio

Order direction.

Permitido: "long" "short"
Ejemplo: long
triggerPricestring · int32obligatorio

Price at which the order fires, fp9 raw. 0 when the order carries no trigger.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
requestedTriggerPricestring · int32 · nullableobligatorio

Trigger price as requested, before the engine pushed it out to the minimum stop distance, fp9 raw. Null when the requested price was kept as is.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
stopPricestring · int32obligatorio

Trigger price of a stop_market / stop_limit order, fp9 raw; 0 for every other type.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
limitPricestring · int32obligatorio

Price the order is placed at once triggered, fp9 raw: the stop-limit price, falling back to the trigger price.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
stopTriggerPricestring · int32obligatorio

Stop-loss attached to the order, fp9 raw. 0 when none is attached.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
takeTriggerPricestring · int32obligatorio

Take-profit attached to the order, fp9 raw. 0 when none is attached.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
trailingStopActivationPricestring · int32obligatorio

Price at which a trailing stop starts trailing, fp9 raw. 0 when it trails from creation.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
trailingStopOffsetstring · int32obligatorio

Trailing distance as an absolute quote amount, fp9 raw. 0 when the distance is set as a percent.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
trailingStopOffsetPercentstring · int32obligatorio

Trailing distance as a fraction of price, fp9 raw. 0 when the distance is absolute.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
leveragestring · int32 · nullableobligatorio

Leverage of the order, fp9 raw. Null on close orders, which inherit the leverage of the position.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
indexstringobligatorio

Order identifier. Kept for backward compatibility, always equal to id.

Ejemplo: string
positionIdstring[]obligatorio

Position a close order is attached to. Null for orders that open or grow a position.

Elementos del array · string

string

Ver ejemplo
[
  "string"
]
parentOrderIdstring[]obligatorio

Order this one was spawned from: a stop or take created out of stopTriggerPrice / takeTriggerPrice, or the limit order a stop_limit turned into. Null when the order was submitted directly.

Elementos del array · string

string

Ver ejemplo
[
  "string"
]
expirationstring · date-time · nullableobligatorio

Always null. Kept for backward compatibility — orders do not expire on their own.

Ejemplo: 2026-05-01T12:30:00.000Z
amountstring · int32obligatorio

Size of the order, fp9 raw, in the unit its class uses: on an increase order a quote amount — the reserve while it waits, and what it actually spent once executed; on a close order (stop, take, trailing_stop) the base asset size it closes, as requested at creation.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
indexPricestring · int32 · nullableobligatorio

Index price the order executed at, fp9 raw. Null while the order has not executed.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
settlementOraclePricestring · int32obligatorio

Always 1000000000 (1.0). Kept for backward compatibility.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
createdAtstring · date-timeobligatorio

When the order was accepted.

Ejemplo: 2026-05-01T12:30:00.000Z
errorstring[]obligatorio

Always null. Kept for backward compatibility — use errorCode.

Elementos del array · string

string

Ver ejemplo
[
  "string"
]
realizedPnlstring · int32 · nullableobligatorio

Pnl realised by this order, fp9 raw. Set only on an executed close order; null while pending and on orders that open or grow a position.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
rawRealizedPnlstring · int32 · nullableobligatorio

Realised pnl before the 60-second adjustment, fp9 raw. Differs from realizedPnl only when the adjustment fired.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
profitAdjustmentAppliedbooleanobligatorio

Whether the 60-second adjustment capped the profit of this order — inside a minute of an open or increase the position pnl cannot grow above what it was at that moment.

Ejemplo: true
executedAfterPausebooleanobligatorio

Whether the order executed after a market pause. Not set by the current engine — always false.

Ejemplo: true
sizeModestring · enumobligatorio

How the size was expressed on creation: quote sizes the order by amount, base sizes it by baseSize.

Permitido: "quote" "base"
Ejemplo: quote
baseSizestring · int32 · nullableobligatorio

Order size in base asset units, fp9 raw. Null for quote-sized orders.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
reservedAmountstring · int32 · nullableobligatorio

Quote amount reserved when the order with sizeMode=base was created, fp9 raw. Stays at the original reserve after execution, while amount is rewritten to what was spent. Null for quote-sized orders, where amount is the reserve.

pattern
^(?:-?[1-9][0-9]*|0)$
Ejemplo: 1000000000
errorCodestring[]obligatorio

Why execution failed, set together with status canceled_by_error — for example insufficient_reserve_at_execution, order_below_min_notional, order_exceeds_market_depth or slippage_tolerance. Null otherwise.

Elementos del array · string

string

Ver ejemplo
[
  "string"
]
reasonstring · enum · nullableobligatorio

Why the platform cancelled the order itself, for example force_close or weekly_session_risk_close. Null for trader-driven cancellations.

Permitido: "force_close" "stop_accounts_fail" "stop_accounts_freeze" "stop_accounts_promote" "stop_accounts_manual" "weekly_session_risk_close" null
Ejemplo: force_close