Developers

Create order

Place an order.

On this page

URLs and generated code samples on this page: Testnet (chain ID 326). Other code on this page doesn't change: it stays on testnet until you switch it in your code. Tutorials, signing cases and live tools always use testnet.

STABLE_PERP orders require the sub-account to be in multi-asset mode.

SDKclient.create_order(...)
HTTPPOST https://trades.testnet.grvt.io/full/v1/create_order, or /lite/v1/create_order for lite names (the SDKs' default)
WebSocketmethod v1/create_order on wss://trades.testnet.grvt.io/ws/full, or /ws/lite for lite names
AuthSession required (Authentication)
Signedorder.signature is signed: Order / OrderWithBuilderFee. Use OrderWithBuilderFee when order.builder is set to a non-zero address, otherwise Order. (Signing)
RetriesWrite: never retried automatically (why)
Contract idorder.create_order (RPCCreateOrderV1)

Request

Body type ApiCreateOrderRequest. Fields the server fills are left out.

orderlite name oobject Orderrequired#
The order to create
  • sub_account_idlite name sastring (uint64)required#
    The sub-account placing the order.
  • is_marketlite name imbooloptionaldefault false#
    True for a market order. A market order has no limit price, never rests on the book and fills at the prices of the resting orders it meets.

    On STABLE_PERP a slippage bound is mandatory: limit_price must carry the signed bound (reference price ± the chosen slippage), or the order is rejected (STABLE_PERP_REQUIRES_PRICE_BOUND). There, is_market = false with a limit price behaves the same; the flag only records intent.

  • time_in_forcelite name tienum TimeInForcerequired#
    How long the order stays open and whether it may fill partly. The order book takes GOOD_TILL_TIME, IMMEDIATE_OR_CANCEL, FILL_OR_KILL and RETAIL_PRICE_IMPROVEMENT. An RFQ maker quote uses GOOD_TILL_TIME or ALL_OR_NONE; an RFQ taker uses IMMEDIATE_OR_CANCEL or FILL_OR_KILL.
    5 values
    GOOD_TILL_TIME, ALL_OR_NONE, IMMEDIATE_OR_CANCEL, FILL_OR_KILL, RETAIL_PRICE_IMPROVEMENT (details).
  • post_onlylite name pobooloptionaldefault false#
    If true, the order must rest on the book as a maker order: if it would match at once, it is rejected (FAIL_POST_ONLY). A market, IMMEDIATE_OR_CANCEL or FILL_OR_KILL order cannot be post-only.

    If false, the order may take or make liquidity. Such orders can be held for a short speed bump before matching, so they meet up-to-date quotes; the exchange sets the delay, and it can differ per instrument.

  • reduce_onlylite name robooloptionaldefault false#
    If true, the order may only reduce your position; the part that would increase it is cancelled.
  • legslite name larray<OrderLeg>required#
    What to trade. Send exactly one leg: the order book rejects orders with more than one (MULTI_LEGGED_ORDER).
    4 fields of OrderLeg
    • instrumentlite name istring (instrument name)required#
      The instrument to trade, e.g. BTC_USDT_Perp.
    • sizelite name sstringrequired#
      How much to trade, in the base asset. Decimal string, e.g. "0.01"; up to the instrument's base_decimals and a multiple of its minimum size. Scaled to an integer only inside the signature.
    • limit_pricelite name lpstringoptionaldefault 0#
      The worst price you accept, in the quote currency per unit. Decimal string, e.g. "65000.5"; up to 9 decimals and a multiple of the instrument's tick size. Scaled to an integer only inside the signature.

      Leave it out (or "0") on a market order. Exception: a STABLE_PERP market order must carry the signed slippage bound (reference price ± the chosen slippage) here.

    • is_buying_assetlite name ibboolrequired#
      True to buy, false to sell.
  • signaturelite name sobject Signaturerequired#
    The EIP-712 signature that authorises this order. The SDKs fill it in; the Signing guide shows how to build it yourself.
    7 fields of Signature
    • signerlite name sstring (uint256)required#
      The address of the wallet that signed (0x + 40 hex characters). That wallet must be allowed to act for the account; for an order, to trade for the sub-account.
    • rlite name rstring (uint256)required#
      The signature's r, as 0x + 64 hex characters. Without the 0x the signature fails to verify.
    • slite name s1string (uint256)required#
      The signature's s, as 0x + 64 hex characters. Without the 0x the signature fails to verify.
    • vlite name vinteger (uint8)required#
      The signature's v, 27 or 28.
    • expirationlite name estring (int64 unix ns)required#
      When the signature stops being valid, in unix nanoseconds, measured on the exchange's clock. At most 30 days ahead (take-profit and stop-loss orders may be accepted up to 180 days ahead); one already past fails with 2001. On an order it is also the order's lifetime: an order still open then is cancelled with reason EXPIRED. The SDKs use now + 24 hours.
    • noncelite name ninteger (uint32)required#
      A number you choose, 0 to 4,294,967,295 (uint32), so that two otherwise identical requests have different signatures. Use a new random one for each request you sign.

      A transfer whose signed fields (nonce and expiration included) exactly repeat an earlier one is rejected, not ignored: it fails with 4007.

      Orders are different. An exact resend of a signed order can be accepted and rest on the book, but the exchange counts fills per signed order, so all copies together never fill more than the signed size, and a resent IMMEDIATE_OR_CANCEL order whose first copy already filled is rejected. An order signed again (new nonce or expiration) is a new order and can fill in full again.

    • chain_idlite name cistring (uint64)required#
      The chain id in the signed EIP-712 domain, as a string. Testnet 326, production 325; "0" means the environment's chain id.
  • metadatalite name mobject OrderMetadatarequired#
    Unsigned data the exchange uses but the chain never sees, such as your client_order_id.
    8 fields of OrderMetadata
    • client_order_idlite name costring (uint64)required#
      Your own id for the order, to find or cancel it later. Any non-zero uint64 (0 fails with 2011) that none of the sub-account's open orders uses, take-profit and stop-loss orders waiting for their price included: a duplicate fails with 2012 (or is rejected with OVERLAPPING_CLIENT_ORDER_ID), and repeating the sub-account's last client order id fails with 2013. After an order closes, its id is accepted again, so use a new id for each order.

      The Grvt web app picks ids below 2^63, so ids from 2^63 up never clash with orders placed there. That is a convention, not a rule the exchange checks. The SDKs set one for you when you leave it out. Not signed and not sent on chain.

    • triggerlite name tobject TriggerOrderMetadataoptional#
      Trigger fields are used to support any type of trigger order such as TP/SL
      2 fields of TriggerOrderMetadata
      • trigger_typelite name ttenum TriggerTyperequired#
        Type of the trigger order. eg: Take Profit, Stop Loss, etc
        3 values
        UNSPECIFIED, TAKE_PROFIT, STOP_LOSS (details).
      • tpsllite name tobject TPSLOrderMetadatarequired#
        Contains metadata for Take Profit (TP) and Stop Loss (SL) trigger orders. Fields: see TPSLOrderMetadata.
    • brokerlite name benum BrokerTagoptional#
      Specifies the broker who brokered the order
      4 values
      UNSPECIFIED, COIN_ROUTES, ALERTATRON, ORIGAMI (details).
    • is_ecnlite name iebooloptionaldefault false#
      Marks an ECN order, eligible for market maker last look. Only on STABLE_PERP instruments, for qualified market makers.
    • slippage_bpslite name sbinteger (uint16)optionaldefault 0#
      Maximum slippage from the mark price for an IMMEDIATE_OR_CANCEL limit order, in basis points (800 = 8%). Only valid on IOC limit orders; 0 means no slippage protection.
    • rfq_idlite name ristring (uint128)optional#
      Binds this order to an RFQ (see ApiCreateRfqRequest and the v1.rfq / v1.quote streams). Optional.

      As a taker acceptance: unlocks that RFQ's private quote pool, so the order matches across the private pool merged with the public book (firm resting liquidity + public quotes). The acceptance must be a single-leg order with time_in_force = IOC or FOK. Setting rfq_id on a non-ECN GTT order is rejected. If the referenced RFQ has expired, been cancelled, or is unknown, the order is rejected.

      As a maker quote (is_ecn = true): identifies which RFQ the quote is responding to.

      Omit rfq_id to match the public book only — private RFQ liquidity requires an RFQ.

    • is_privatelite name ip1booloptionaldefault false#
      Maker quotes only. true = a private quote delivered to a single RFQ's taker (appears only on that taker's v1.quote book); false = a public quote resting on the order book, visible to all. When true, rfq_id is required.
    • algo_order_idlite name aostring (uint128)optional#
      The algo order that placed this order as a sub-order; zero for an ordinary order.
  • builderlite name bstring (0x address)optional#
    The main account id of a builder (a third party that routes your order and charges a fee on it). Leave it out unless you trade through a builder: setting it switches the signature to OrderWithBuilderFee.
  • builder_feelite name bfstringoptional#
    The builder's fee for this order, as a percentage: "0.001" means 0.001%. Only with builder.

Response

Body type ApiCreateOrderResponse (the same object is the JSON-RPC result over WebSocket).

resultlite name robject Orderrequired#
The created order
  • order_idlite name oistring (uint128)optionaldefault 0#
    Set by the server. The exchange's 128-bit id for the order. The reply to create_order or bulk_orders comes before the id is assigned, so it is zero there; the order stream and get_order carry it. Every replace creates a new order with a new order_id.
  • sub_account_idlite name sastring (uint64)required#
    The sub-account placing the order.
  • is_marketlite name imbooloptionaldefault false#
    True for a market order. A market order has no limit price, never rests on the book and fills at the prices of the resting orders it meets.

    On STABLE_PERP a slippage bound is mandatory: limit_price must carry the signed bound (reference price ± the chosen slippage), or the order is rejected (STABLE_PERP_REQUIRES_PRICE_BOUND). There, is_market = false with a limit price behaves the same; the flag only records intent.

  • time_in_forcelite name tienum TimeInForcerequired#
    How long the order stays open and whether it may fill partly. The order book takes GOOD_TILL_TIME, IMMEDIATE_OR_CANCEL, FILL_OR_KILL and RETAIL_PRICE_IMPROVEMENT. An RFQ maker quote uses GOOD_TILL_TIME or ALL_OR_NONE; an RFQ taker uses IMMEDIATE_OR_CANCEL or FILL_OR_KILL.
    5 values
    GOOD_TILL_TIME, ALL_OR_NONE, IMMEDIATE_OR_CANCEL, FILL_OR_KILL, RETAIL_PRICE_IMPROVEMENT (details).
  • post_onlylite name pobooloptionaldefault false#
    If true, the order must rest on the book as a maker order: if it would match at once, it is rejected (FAIL_POST_ONLY). A market, IMMEDIATE_OR_CANCEL or FILL_OR_KILL order cannot be post-only.

    If false, the order may take or make liquidity. Such orders can be held for a short speed bump before matching, so they meet up-to-date quotes; the exchange sets the delay, and it can differ per instrument.

  • reduce_onlylite name robooloptionaldefault false#
    If true, the order may only reduce your position; the part that would increase it is cancelled.
  • legslite name larray<OrderLeg>required#
    What to trade. Send exactly one leg: the order book rejects orders with more than one (MULTI_LEGGED_ORDER).
    4 fields of OrderLeg
    • instrumentlite name istring (instrument name)required#
      The instrument to trade, e.g. BTC_USDT_Perp.
    • sizelite name sstringrequired#
      How much to trade, in the base asset. Decimal string, e.g. "0.01"; up to the instrument's base_decimals and a multiple of its minimum size. Scaled to an integer only inside the signature.
    • limit_pricelite name lpstringoptionaldefault 0#
      The worst price you accept, in the quote currency per unit. Decimal string, e.g. "65000.5"; up to 9 decimals and a multiple of the instrument's tick size. Scaled to an integer only inside the signature.

      Leave it out (or "0") on a market order. Exception: a STABLE_PERP market order must carry the signed slippage bound (reference price ± the chosen slippage) here.

    • is_buying_assetlite name ibboolrequired#
      True to buy, false to sell.
  • signaturelite name sobject Signaturerequired#
    The EIP-712 signature that authorises this order. The SDKs fill it in; the Signing guide shows how to build it yourself.
    7 fields of Signature
    • signerlite name sstring (uint256)required#
      The address of the wallet that signed (0x + 40 hex characters). That wallet must be allowed to act for the account; for an order, to trade for the sub-account.
    • rlite name rstring (uint256)required#
      The signature's r, as 0x + 64 hex characters. Without the 0x the signature fails to verify.
    • slite name s1string (uint256)required#
      The signature's s, as 0x + 64 hex characters. Without the 0x the signature fails to verify.
    • vlite name vinteger (uint8)required#
      The signature's v, 27 or 28.
    • expirationlite name estring (int64 unix ns)required#
      When the signature stops being valid, in unix nanoseconds, measured on the exchange's clock. At most 30 days ahead (take-profit and stop-loss orders may be accepted up to 180 days ahead); one already past fails with 2001. On an order it is also the order's lifetime: an order still open then is cancelled with reason EXPIRED. The SDKs use now + 24 hours.
    • noncelite name ninteger (uint32)required#
      A number you choose, 0 to 4,294,967,295 (uint32), so that two otherwise identical requests have different signatures. Use a new random one for each request you sign.

      A transfer whose signed fields (nonce and expiration included) exactly repeat an earlier one is rejected, not ignored: it fails with 4007.

      Orders are different. An exact resend of a signed order can be accepted and rest on the book, but the exchange counts fills per signed order, so all copies together never fill more than the signed size, and a resent IMMEDIATE_OR_CANCEL order whose first copy already filled is rejected. An order signed again (new nonce or expiration) is a new order and can fill in full again.

    • chain_idlite name cistring (uint64)required#
      The chain id in the signed EIP-712 domain, as a string. Testnet 326, production 325; "0" means the environment's chain id.
  • metadatalite name mobject OrderMetadatarequired#
    Unsigned data the exchange uses but the chain never sees, such as your client_order_id.
    9 fields of OrderMetadata
    • client_order_idlite name costring (uint64)required#
      Your own id for the order, to find or cancel it later. Any non-zero uint64 (0 fails with 2011) that none of the sub-account's open orders uses, take-profit and stop-loss orders waiting for their price included: a duplicate fails with 2012 (or is rejected with OVERLAPPING_CLIENT_ORDER_ID), and repeating the sub-account's last client order id fails with 2013. After an order closes, its id is accepted again, so use a new id for each order.

      The Grvt web app picks ids below 2^63, so ids from 2^63 up never clash with orders placed there. That is a convention, not a rule the exchange checks. The SDKs set one for you when you leave it out. Not signed and not sent on chain.

    • create_timelite name ctstring (int64 unix ns)optionaldefault 0#
      Set by the server. When the exchange received the order, in unix nanoseconds.
    • triggerlite name tobject TriggerOrderMetadataoptional#
      Trigger fields are used to support any type of trigger order such as TP/SL
      2 fields of TriggerOrderMetadata
      • trigger_typelite name ttenum TriggerTyperequired#
        Type of the trigger order. eg: Take Profit, Stop Loss, etc
        3 values
        UNSPECIFIED, TAKE_PROFIT, STOP_LOSS (details).
      • tpsllite name tobject TPSLOrderMetadatarequired#
        Contains metadata for Take Profit (TP) and Stop Loss (SL) trigger orders. Fields: see TPSLOrderMetadata.
    • brokerlite name benum BrokerTagoptional#
      Specifies the broker who brokered the order
      4 values
      UNSPECIFIED, COIN_ROUTES, ALERTATRON, ORIGAMI (details).
    • is_ecnlite name iebooloptionaldefault false#
      Marks an ECN order, eligible for market maker last look. Only on STABLE_PERP instruments, for qualified market makers.
    • slippage_bpslite name sbinteger (uint16)optionaldefault 0#
      Maximum slippage from the mark price for an IMMEDIATE_OR_CANCEL limit order, in basis points (800 = 8%). Only valid on IOC limit orders; 0 means no slippage protection.
    • rfq_idlite name ristring (uint128)optional#
      Binds this order to an RFQ (see ApiCreateRfqRequest and the v1.rfq / v1.quote streams). Optional.

      As a taker acceptance: unlocks that RFQ's private quote pool, so the order matches across the private pool merged with the public book (firm resting liquidity + public quotes). The acceptance must be a single-leg order with time_in_force = IOC or FOK. Setting rfq_id on a non-ECN GTT order is rejected. If the referenced RFQ has expired, been cancelled, or is unknown, the order is rejected.

      As a maker quote (is_ecn = true): identifies which RFQ the quote is responding to.

      Omit rfq_id to match the public book only — private RFQ liquidity requires an RFQ.

    • is_privatelite name ip1booloptionaldefault false#
      Maker quotes only. true = a private quote delivered to a single RFQ's taker (appears only on that taker's v1.quote book); false = a public quote resting on the order book, visible to all. When true, rfq_id is required.
    • algo_order_idlite name aostring (uint128)optional#
      The algo order that placed this order as a sub-order; zero for an ordinary order.
  • statelite name s1object OrderStateoptional#
    Set by the server. The order's status, filled size and average fill price; not signed.
    6 fields of OrderState
    • statuslite name senum OrderStatusrequired#
      The order's status. FILLED, REJECTED and CANCELLED are final.
      5 values
      PENDING, OPEN, FILLED, REJECTED, CANCELLED (details).
    • reject_reasonlite name rrenum OrderRejectReasonrequired#
      Why the order was rejected or cancelled. UNSPECIFIED while it is not.
      76 values
      UNSPECIFIED, CLIENT_CANCEL, CLIENT_BULK_CANCEL, CLIENT_SESSION_END, MARKET_CANCEL, IOC_CANCEL, AON_CANCEL, FOK_CANCEL, EXPIRED, FAIL_POST_ONLY, FAIL_REDUCE_ONLY, MM_PROTECTION, SELF_TRADE_PROTECTION, SELF_MATCHED_SUBACCOUNT, OVERLAPPING_CLIENT_ORDER_ID, BELOW_MARGIN, LIQUIDATION, INSTRUMENT_INVALID, INSTRUMENT_DEACTIVATED, SYSTEM_FAILOVER, UNAUTHORISED, SESSION_KEY_EXPIRED, SUB_ACCOUNT_NOT_FOUND, NO_TRADE_PERMISSION, UNSUPPORTED_TIME_IN_FORCE, MULTI_LEGGED_ORDER, EXCEED_MAX_POSITION_SIZE, EXCEED_MAX_SIGNATURE_EXPIRATION, MARKET_ORDER_WITH_LIMIT_PRICE, CLIENT_CANCEL_ON_DISCONNECT_TRIGGERED, OCO_COUNTER_PART_TRIGGERED, REDUCE_ONLY_LIMIT, CLIENT_REPLACE, DERISK_MUST_BE_IOC, DERISK_MUST_BE_REDUCE_ONLY, DERISK_NOT_SUPPORTED, INVALID_ORDER_TYPE, CURRENCY_NOT_DEFINED, INVALID_CHAIN_ID, BUILDER_ORDER_FEE_EXCEED, BUILDER_ORDER_FEE_NEGATIVE, BUILDER_ORDER_BUILDER_NOT_AUTHORIZED, BUILDER_ORDER_BUILDER_NOT_EXIST, TRADE_PRICE_WORSE_THAN_BANKRUPTCY_PRICE, TOO_MANY_MAKER_ORDERS, REDUCE_ONLY_NOT_SUPPORTED_FOR_SPOT_ORDER, TPSL_NOT_SUPPORTED_FOR_SPOT_ORDER, SPOT_ORDER_NOT_SUPPORTED, INSUFFICIENT_BALANCE, SPOT_TRADING_BLOCKED_DURING_SOCIALIZED_LOSS, BELOW_MARGIN_WITH_PENALTY_DEVIATION, CORPORATE_ACTION, NOT_QUALIFIED_MAKER, PRIVATE_QUOTE_REQUIRES_RFQ, STABLE_PERP_REQUIRES_PRICE_BOUND, UNSUPPORTED_TRIGGER_BY, RFQ_NOT_FOUND, RESTING_ORDER_WOULD_CROSS, SESSION_CLOSED, RFQ_TERMINATED, STABLE_PERP_REQUIRES_MULTI_ASSET_MODE, BORROW_LIMIT_EXCEEDED_AFTER_TRADE, UNDEPLOYED_LOAN_AUTO_EXCHANGE, LIQUIDATION_AUTO_EXCHANGE, USDC_COLLATERAL_DISABLED, SFP_POST_ONLY_NOT_ALLOWED, VAULT_NON_QUOTE_INVESTMENT_CURRENCY, RFQ_ID_REQUIRES_STABLE_PERP, RFQ_PRIVATE_POOL_NOT_SUPPORTED, RFQ_REQUIRES_IOC, RFQ_MISMATCH, RFQ_ALREADY_BOUND, RFQ_MAKER_MUST_BE_ECN, FOK_NOT_SUPPORTED, MARKET_ORDER_NOT_SUPPORTED, STABLE_PERP_ORDER_NOT_SUPPORTED (details).
    • book_sizelite name bsarray<string>required#
      The size still open to fill, per leg (same order as legs), in the base asset.
    • traded_sizelite name tsarray<string>required#
      The size filled so far, per leg (same order as legs), in the base asset.
    • update_timelite name utstring (int64 unix ns)required#
      When the order last changed, in unix nanoseconds.
    • avg_fill_pricelite name afarray<string>required#
      The average price of the fills so far, per leg (same order as legs); 0 before the first fill.
  • builderlite name bstring (0x address)optional#
    The main account id of a builder (a third party that routes your order and charges a fee on it). Leave it out unless you trade through a builder: setting it switches the signature to OrderWithBuilderFee.
  • builder_feelite name bfstringoptional#
    The builder's fee for this order, as a percentage: "0.001" means 0.001%. Only with builder.

Errors

Errors come back as {"code", "message", "status"} (lite {"c", "m", "s"}) with the HTTP status. Codes this call can return (all error codes):

1400NoTradePermission403
Signer does not have trade permission
2000SignerUnauthorized403Inspect
Signature is from an unauthorized signer
2001SignatureExpired403Inspect
Signature has expired
2002SignatureDoesNotMatchPayload403Inspect
Signature does not match payload
2003OrderSubAccountDoesNotMatchLoggedInUser403
Order sub account does not match logged in user
2004SessionKeySignerExpired403
Signature is from an expired session key
2005SignatureInvalidV403Inspect
Signature V must be 27/28
2006SignatureInvalidRSLength403Inspect
Signature R/S must have exactly 64 characters long without 0x prefix
2007SignatureSIsNotCurveLowerHalf403Inspect
Signature S must be in the lower half of the curve
2010OrderIDShouldBeEmpty400
Order ID should be empty when creating an order
Show 68 more errors for this call
2011ClientOrderIDShouldBeSupplied400
Client Order ID should be supplied when creating an order
2012ClientOrderIDOverlaps400
Client Order ID overlaps with existing active order
2020MarketOrderWithLimitPrice400
Market Order must always be supplied without a limit price
2021LimitOrderWithoutLimitPrice400
Limit Order must always be supplied with a limit price
2030InvalidTimeInForceOrderbook400
Orderbook Orders must have a TimeInForce of GTT/IOC/FOK
2031InvalidTimeInForceRFQ400
RFQ Orders must have a TimeInForce of GTT/AON/IOC/FOK
2032PostOnlyWhenTakerOrder400
Post Only can only be set to true for GTT/AON orders
2040LegsEmpty400
Order must contain at least one leg
2041LegsNotSorted400
Order Legs must be sorted by Derivative.Instrument/Underlying/BaseCurrency/Expiration/StrikePrice
2042LegsMultipleOrderbook400
Orderbook Orders must contain only one leg
2050NonEmptyState400
Order state must be empty upon creation
2051ExecutionMetadataShouldBeEmpty400
Order execution metadata must be empty upon creation
2060InactiveDerivative400
Order Legs contain one or more inactive derivative
2061InstrumentNotSupported400
Unsupported Instrument Requested
2062NumContractsUnderMinSize400
Order size smaller than min size
2063NumContractsUnderMinBlockSize400
Order size smaller than min block size in block trade venue
2064InvalidLimitPriceTick400
Invalid limit price tick
2065InvalidContractGrainSize400
Order size too granular
2066NotionalBelowMinimum400
Order below minimum notional. Please try again with a higher price or size.
2067PositionClosingNotionalBelowMinimum400
Order below minimum notional. Please try reducing your position again with a higher price or size.
2070LiquidationOrderNotSupported400
Liquidation Order is not supported
2080InsufficientMargin400
Insufficient margin to create order
2081MaximumPositionSizeExceeded400
Order Fill would result in exceeding maximum position size
2082FailedPreOrderCheck400
Pre-order check failed
2083MaximumLeverageConfigPositionSizeExceeded400
Order Fill would result in exceeding maximum position size under current configurable leverage tier
2084FailedPostOrderCheck400
Post-order check failed
2090MaxOpenOrdersExceeded429
Max open orders exceeded
2091SessionOrderReduceOnlyRequired403
As a precaution, only position-reducing (`reduce_only` as true) orders are currently allowed on your account. Please contact support so we can help complete the necessary checks.
2110InvalidTriggerBy400
Invalid trigger by
2111UnsupportedTriggerBy400
Unsupported trigger by
2112InvalidTriggerOrder400
Invalid trigger order
2113EmptyTriggerPrice400
Trigger price must be non-zero
2114InvalidPTPSLReduceOnly400
Invalid position linked TPSL orders, position linked TPSL must be a reduce-only order
2115InvalidPTPSLSize400
Invalid position linked TPSL orders, position linked TPSL must not have smaller size than the position
2116PTPSLOrderAlreadyExists400
Position linked TPSL order for this asset already exists
2117PTPSLMustBeFromWebOrMobile400
Position linked TPSL orders must be created from web or mobile clients
2118InvalidTriggerPriceTick400
Invalid trigger price tick
2147StablePerpRequiresMultiAssetMode400
stable perp orders require a multi-asset-mode sub-account
2148VaultCannotTrade400
a vault whose investment currency is not its quote currency cannot trade
2242SplitTPSLNotSupported400
Split TPSL functionality not supported; you may be using a deprecated API, or this functionality is temporarily disabled
2400ReduceOnlyOrderWithNoPosition400
Reduce only order with no position
2401ReduceOnlyOrderIncreaseSize400
Reduce only order must not increase position size
2402ReduceOnlyOrderSizeExceeded400
Reduce only order size exceeds maximum allowed value
2450SpotOrderNotSupported400
Spot order is not supported
2451SpotOrderReduceOnlyNotSupported400
Spot order must not be a reduce-only order
2452SpotOrderTPSLNotSupported400
Spot order must not be a TPSL order
2453SpotTradingBlockedDuringSocializedLoss400
Spot trading is blocked during socialized loss
3004MMConfigNotFound500
Instrument does not have a valid maintenance margin configuration
3005AssetUnderlyingBalDecConfigNotFound500
Instrument's underlying currency does not have a valid balance decimal configuration
3006AssetQuoteBalDecConfigNotFound500
Instrument's quote currency does not have a valid balance decimal configuration
7303DelistCreateOrderBlocked400
Order creations have been blocked for this delisted asset.
7304DelistPositionOpenBlocked400
Only position-reducing orders (`reduce_only` as true) allowed for this asset right now.
7600SlippageFeatureDisabled400
Order slippage protection is not enabled.
7601SlippageRequiresIOCLimitOrder400
Slippage protection is only supported on IOC limit orders.
7602SlippageBelowMinimum400
Slippage is below the minimum allowed value.
7603SlippageExceedsPriceProtectionBand400
Slippage exceeds the asset's price protection band.
7701SfpIndicativeNotQualifiedMaker403
You are not a qualified market maker or designated market maker for this instrument.
7704SfpOrderNotSupported400
Stable Funding Perpetual orders are not yet supported.
7705SfpInstrumentMismatch400
The order's instrument does not match the referenced RFQ's instrument.
7706SfpPrivateQuoteNotSupported400
Private maker quotes are not yet supported.
7707SfpRfqNotLive400
The referenced RFQ is not open.
7708SfpRfqAlreadyHasTakerOrder400
The referenced RFQ already has a taker order.
7709SfpTakerInvalidTimeInForce400
Invalid time in force for a Stable Funding Perpetual taker order.
7711SfpMarketOrderNotAllowed400
Market orders are not allowed for Stable Funding Perpetual taker orders; a market-order slippage bound must be set.
7712RfqIDNotAllowedForNonSFP400
Non-Stable-Funding-Perpetual orders must always be supplied without rfq_id.
7723UsdcCollateralDisabled400
USDC must be enabled as collateral on this sub account to trade USDC-quoted instruments.
7724SfpPostOnlyNotAllowedForRetail400
Post-only orders are not allowed on Stable Funding Perpetuals.
7726SfpMarketClosed400
The Stable Funding Perpetual market is closed.
Plus 10 errors any call can return
1000Unauthorized401
You need to authenticate prior to using this functionality
1001Forbidden403
You are not authorized to access this functionality
1002InternalServer500
Internal Server Error
1003InvalidRequest400
Request could not be processed due to malformed syntax
1004NotFound404
Data Not Found
1005UnknownErr500
Unknown Error
1006RateLimit429retryable
You have surpassed the allocated rate limit for your tier
1008IPNotWhitelisted401
Your IP has not been whitelisted for access
1009APIEndpointTemporarilyDeactivated503retryable
We are temporarily deactivating this API endpoint, please try again later
1012InvalidSignatureChainID400Inspect
Invalid signature chain ID

Example

Example code
import os
from decimal import Decimal

from grvt import Grvt, enums as e, PrivateKeySigner, models as m

with Grvt(
    env=os.environ.get("GRVT_ENV", "testnet"),
    api_key=os.environ["GRVT_API_KEY"],
    signer=PrivateKeySigner(os.environ["GRVT_PRIVATE_KEY"]),
) as client:
    resp = client.create_order(
        order=m.OrderInput(
            sub_account_id=os.environ["GRVT_SUB_ACCOUNT_ID"],
            is_market=False,
            time_in_force=e.TimeInForce("GOOD_TILL_TIME"),
            post_only=True,
            reduce_only=False,
            legs=[
                m.OrderLeg(
                    instrument="BTC_USDT_Perp",
                    size=Decimal("0.01"),
                    limit_price=Decimal("60000"),
                    is_buying_asset=True,
                ),
            ],
        ),
    )
    print(resp)

Raw HTTP (set GRVT_DOMAIN, see Environments; GRVT_COOKIE and GRVT_ACCOUNT_ID come from login):

The body below is the limit_order signing case: a real signature by the public test key for chain id 326. Build your own with the Signing guide; the server will reject this one (unknown account). signature.expiration is unix nanoseconds: use now + 1 day (the signing case uses 2100-01-01 so it never expires).

With full field names:

curl -sS "https://trades.testnet.grvt.io/full/v1/create_order" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "order": {
    "sub_account_id": "8289849667772468",
    "is_market": false,
    "time_in_force": "GOOD_TILL_TIME",
    "post_only": true,
    "reduce_only": false,
    "legs": [
      {
        "instrument": "BTC_USDT_Perp",
        "size": "0.01",
        "limit_price": "60000",
        "is_buying_asset": true
      }
    ],
    "signature": {
      "signer": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
      "expiration": "4102444800000000000",
      "nonce": 1001,
      "chain_id": "326",
      "r": "0x62b6d0047530e701aa06d4b7de9dca76916219b8561424bd246a519bdc31bf7d",
      "s": "0x2447b83565fa6cac90c607e5c4a3f96cda386f92d7fb51f45dea12c2f8e09904",
      "v": 27
    },
    "metadata": {
      "client_order_id": "1001"
    }
  }
}
EOF

With lite field names:

curl -sS "https://trades.testnet.grvt.io/lite/v1/create_order" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "o": {
    "sa": "8289849667772468",
    "im": false,
    "ti": "GOOD_TILL_TIME",
    "po": true,
    "ro": false,
    "l": [
      {
        "i": "BTC_USDT_Perp",
        "s": "0.01",
        "lp": "60000",
        "ib": true
      }
    ],
    "s": {
      "s": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
      "e": "4102444800000000000",
      "n": 1001,
      "ci": "326",
      "r": "0x62b6d0047530e701aa06d4b7de9dca76916219b8561424bd246a519bdc31bf7d",
      "s1": "0x2447b83565fa6cac90c607e5c4a3f96cda386f92d7fb51f45dea12c2f8e09904",
      "v": 27
    },
    "m": {
      "co": "1001"
    }
  }
}
EOF
Build & sign locally
esc

↑ ↓ move↵ open⇧↵ open .mdTry an error code like 2002

Keyboard shortcuts

⌘ K
Search the docs
/
Search
l
Next code language (Python → TypeScript → Go → Rust → curl → WebSocket)
j / k
Next / previous page
t
Light / dark theme
?
This help
Esc
Close dialogs and drawers