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

# Cancel DCA Order

> Generate calldata to cancel an active DCA order and return remaining funds

## Overview

Cancels an active DCA order and returns any remaining funds to the trader. This endpoint generates the calldata needed to execute the cancellation on-chain.

## Request

<ParamField path="address" type="string" required>
  DCA order contract address to cancel
</ParamField>

## Response

<ResponseField name="chainId" type="string" required>
  Network identifier (e.g., "0x534e5f4d41494e")
</ResponseField>

<ResponseField name="calls" type="array" required>
  Array of transaction calls to cancel the order

  <Expandable title="Call Object">
    <ResponseField name="contractAddress" type="string" required>
      Contract to call (the DCA order address)
    </ResponseField>

    <ResponseField name="entrypoint" type="string" required>
      Function to call (cancel\_order)
    </ResponseField>

    <ResponseField name="calldata" type="array" required>
      Function arguments
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://starknet.api.avnu.fi/dca/v3/orders/0x0a1b2c3d.../cancel"
  ```

  ```typescript TypeScript theme={null}
  // Cancel a DCA order
  const orderAddress = "0x0a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789";

  const response = await fetch(
    `https://starknet.api.avnu.fi/dca/v3/orders/${orderAddress}/cancel`,
    {
      method: 'POST',
    }
  );

  const { calls } = await response.json();

  // Execute the cancellation
  const tx = await account.execute(calls);
  console.log(`Order cancelled: ${tx.transaction_hash}`);

  // Remaining funds are automatically returned to your wallet
  ```

  ```python Python theme={null}
  import requests

  order_address = "0x0a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789"

  response = requests.post(
      f'https://starknet.api.avnu.fi/dca/v3/orders/{order_address}/cancel'
  )

  calls = response.json()['calls']

  # Execute cancellation through your account
  # Remaining funds will be returned
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "chainId": "0x534e5f4d41494e",
    "calls": [
      {
        "contractAddress": "0x0a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789",
        "entrypoint": "cancel_order",
        "calldata": []
      }
    ]
  }
  ```
</ResponseExample>
