> ## Documentation Index
> Fetch the complete documentation index at: https://docs.compasslabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel an order

> Cancel an unfilled equity order on-chain.

Returns an EIP-712 payload the owner signs; a sponsor relays it, or the owner
broadcasts it directly. Works only on `pending` or `expired` orders, and only
the account that placed the order can cancel it.



## OpenAPI

````yaml /v2/combined_spec.json post /v2/tokenized_assets/order/{order_hash}/cancel
openapi: 3.1.0
info:
  title: Compass API
  description: Compass Labs DeFi API
  version: 0.0.1
servers:
  - url: https://api.compasslabs.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /v2/tokenized_assets/order/{order_hash}/cancel:
    post:
      tags:
        - Tokenized Assets
      summary: Cancel an order
      description: >-
        Cancel an unfilled equity order on-chain.


        Returns an EIP-712 payload the owner signs; a sponsor relays it, or the
        owner

        broadcasts it directly. Works only on `pending` or `expired` orders, and
        only

        the account that placed the order can cancel it.
      operationId: v2_tokenized_assets_order_{order_hash}_cancel
      parameters:
        - name: order_hash
          in: path
          required: true
          schema:
            type: string
            title: Order Hash
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TokenizedAssetsCancelOrderRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsCancelOrderResponse'
        '400':
          description: '`order_hash` is not 32 lowercase-hex bytes prefixed with 0x.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsErrorResponse'
        '403':
          description: >-
            `Not the order maker` — the Tokenized Assets Account predicted from
            `owner` is not the order's on-chain maker.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsErrorResponse'
        '404':
          description: '`Order not found.` — no order matches the hash.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsErrorResponse'
        '409':
          description: >-
            `Order already filled` or `Order already cancelled` — order is in a
            terminal state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '502':
          description: >-
            `Swap service unavailable` — the swap service is temporarily
            unavailable, or the order data returned from upstream is incomplete.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsErrorResponse'
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            from compass_api_sdk import CompassAPI


            with CompassAPI(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as compass_api:

                res = compass_api.tokenized_assets.tokenized_assets_order_order_hash_cancel(order_hash="<value>", owner="<value>")

                # Handle response
                print(res)
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { CompassApiSDK } from "@compass-labs/api-sdk";

            const compassApiSDK = new CompassApiSDK({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsOrderOrderHashCancel({
                orderHash: "<value>",
                tokenizedAssetsCancelOrderRequest: {
                  owner: "<value>",
                },
              });

              console.log(result);
            }

            run();
components:
  schemas:
    TokenizedAssetsCancelOrderRequest:
      properties:
        owner:
          type: string
          title: Owner
          description: >-
            Wallet that owns the Tokenized Assets Account. The account address
            derived from this owner must match the order's on-chain maker; the
            API rejects otherwise (only the order's maker can cancel it).
      type: object
      required:
        - owner
      title: TokenizedAssetsCancelOrderRequest
    TokenizedAssetsCancelOrderResponse:
      properties:
        cancel_safe_tx_eip712:
          $ref: '#/components/schemas/BatchedSafeOperationsResponse-Output'
          description: >-
            EIP-712 payload that authorizes the on-chain cancellation. Sign with
            `wallet.signTypedData(...)` from the Tokenized Assets Account's
            owner, then broadcast via `POST /v2/gas_sponsorship/prepare` or have
            the owner broadcast the resulting transaction directly.
      type: object
      required:
        - cancel_safe_tx_eip712
      title: TokenizedAssetsCancelOrderResponse
      example:
        cancel_safe_tx_eip712:
          domain:
            chainId: 1
            verifyingContract: '0x2ed5C9c14E1F8baA94CD3e9b5b6e3F8e3D27504F'
          message:
            baseGas: '0'
            data: >-
              0xb1f9f1c9000000000000000000000000000000000000000000000000000000000000000014459af3a06abf6f7a0d3c2c1fa3b64d2e1b8a7c5e3d2b1f0a9876543210596b
            gasPrice: '0'
            gasToken: '0x0000000000000000000000000000000000000000'
            nonce: '1'
            operation: 0
            refundReceiver: '0x0000000000000000000000000000000000000000'
            safeTxGas: '0'
            to: '0x111111125421cA6dc452d289314280a0f8842A65'
            value: '0'
          primaryType: SafeTx
          types:
            EIP712Domain:
              - name: chainId
                type: uint256
              - name: verifyingContract
                type: address
            SafeTx:
              - name: to
                type: address
              - name: value
                type: uint256
              - name: data
                type: bytes
              - name: operation
                type: uint8
              - name: safeTxGas
                type: uint256
              - name: baseGas
                type: uint256
              - name: gasPrice
                type: uint256
              - name: gasToken
                type: address
              - name: refundReceiver
                type: address
              - name: nonce
                type: uint256
    TokenizedAssetsErrorResponse:
      properties:
        error:
          type: string
          title: Error
          description: >-
            Short human-readable error label (e.g. `Market not found.`,
            `Insufficient liquidity`, `Order not found.`).
        message:
          type: string
          title: Message
          description: Human-readable explanation.
      type: object
      required:
        - error
        - message
      title: TokenizedAssetsErrorResponse
      description: >-
        Standard error envelope returned by every non-2xx response.


        Surfaced in OpenAPI ``responses`` declarations so SDK consumers can
        decode

        failures uniformly without inspecting per-status-code shapes.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    BatchedSafeOperationsResponse-Output:
      properties:
        domain:
          $ref: >-
            #/components/schemas/compass__api_backend__v2__models__safe__transact__response__batched_safe_operations__EIP712Domain
          description: EIP-712 domain separator
        types:
          $ref: >-
            #/components/schemas/compass__api_backend__v2__models__safe__transact__response__batched_safe_operations__EIP712Types
          description: EIP-712 type definitions
        primaryType:
          type: string
          const: SafeTx
          title: Primarytype
          description: Primary type for the structured data
        message:
          $ref: '#/components/schemas/SafeTxMessage'
          description: Safe transaction message data
      type: object
      required:
        - domain
        - types
        - primaryType
        - message
      title: BatchedSafeOperationsResponse
      description: Response containing EIP-712 typed data for Safe transaction signing.
      example:
        domain:
          chainId: 8453
          verifyingContract: '0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1'
        message:
          baseGas: '0'
          data: >-
            0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020
          gasPrice: '0'
          gasToken: '0x0000000000000000000000000000000000000000'
          nonce: '7'
          operation: 1
          refundReceiver: '0x0000000000000000000000000000000000000000'
          safeTxGas: '0'
          to: '0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA'
          value: '0'
        primaryType: SafeTx
        types:
          EIP712Domain:
            - name: chainId
              type: uint256
            - name: verifyingContract
              type: address
          SafeTx:
            - name: to
              type: address
            - name: value
              type: uint256
            - name: data
              type: bytes
            - name: operation
              type: uint8
            - name: safeTxGas
              type: uint256
            - name: baseGas
              type: uint256
            - name: gasPrice
              type: uint256
            - name: gasToken
              type: address
            - name: refundReceiver
              type: address
            - name: nonce
              type: uint256
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    compass__api_backend__v2__models__safe__transact__response__batched_safe_operations__EIP712Domain:
      properties:
        chainId:
          type: integer
          title: Chainid
          description: Chain ID
        verifyingContract:
          type: string
          title: Verifyingcontract
          description: Address of the Product Account
      type: object
      required:
        - chainId
        - verifyingContract
      title: EIP712Domain
      description: The EIP-712 domain separator.
    compass__api_backend__v2__models__safe__transact__response__batched_safe_operations__EIP712Types:
      properties:
        EIP712Domain:
          items:
            $ref: '#/components/schemas/EIP712DomainField'
          type: array
          title: Eip712Domain
          description: EIP712Domain type definition
        SafeTx:
          items:
            $ref: '#/components/schemas/SafeTxField'
          type: array
          title: Safetx
          description: SafeTx type definition
      type: object
      required:
        - EIP712Domain
        - SafeTx
      title: EIP712Types
      description: The type definitions for EIP-712 structured data.
    SafeTxMessage:
      properties:
        to:
          type: string
          title: To
          description: Destination address
        value:
          type: string
          title: Value
          description: Value in wei as a string
        data:
          type: string
          title: Data
          description: Transaction data as hex string
        operation:
          $ref: '#/components/schemas/OperationType'
          description: Operation type (0=Call, 1=DelegateCall)
        safeTxGas:
          type: string
          title: Safetxgas
          description: Gas for the transaction
        baseGas:
          type: string
          title: Basegas
          description: Base gas costs
        gasPrice:
          type: string
          title: Gasprice
          description: Gas price
        gasToken:
          type: string
          title: Gastoken
          description: Token address for gas payment
        refundReceiver:
          type: string
          title: Refundreceiver
          description: Address to receive gas refund
        nonce:
          type: string
          title: Nonce
          description: Transaction nonce
      type: object
      required:
        - to
        - value
        - data
        - operation
        - safeTxGas
        - baseGas
        - gasPrice
        - gasToken
        - refundReceiver
        - nonce
      title: SafeTxMessage
      description: The message data for the transaction.
    EIP712DomainField:
      properties:
        name:
          type: string
          title: Name
        type:
          type: string
          title: Type
      type: object
      required:
        - name
        - type
      title: EIP712DomainField
      description: A field in the EIP712Domain type definition.
    SafeTxField:
      properties:
        name:
          type: string
          title: Name
        type:
          type: string
          title: Type
      type: object
      required:
        - name
        - type
      title: SafeTxField
      description: A field in the SafeTx type definition.
    OperationType:
      type: integer
      enum:
        - 0
        - 1
      title: OperationType
      description: Safe operation types.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Compass API Key. Get your key
        [here](https://www.compasslabs.ai/dashboard).

````