# Track status

Our status API returns the status of a cross chain transaction. The response param `status.squidTransactionStatus` tells the user what they need to do next.

{% hint style="danger" %}
**Squid Intents Transactions**: Status polling is **required** for Squid Intents. After executing a Squid Intents transaction, you **must** call the status API with the `quoteId` parameter. If `quoteId` is not included in the status call, the Squid Intents transaction will be **refunded** to the source chain. See [Integrating Squid Intents](/api-and-sdk-integration/coral-intent-swaps/integrating-squid-intents.md) for details.
{% endhint %}

### API Endpoint

```
GET https://v2.api.squidrouter.com/v2/status
```

#### Parameters

| Parameter       | Type   | Required | Description                           |
| --------------- | ------ | -------- | ------------------------------------- |
| `transactionId` | string | Yes      | The transaction hash                  |
| `quoteId`       | string | Yes      | The quote ID from the route response. |
| `fromChainId`   | string | Yes      | The source chain ID                   |
| `toChainId`     | string | Yes      | The destination chain ID              |
| `requestId`     | string | No       | The request ID (legacy parameter)     |

#### Example Request

```
/v2/status?transactionId=40E494A80393963DBC2D493E3EB6E39B7C48810CD345BF0FA8E48683B9841C43&fromChainId=cosmoshub-4&toChainId=osmosis-1&quoteId=27232c0b82fa6661b2799894bd0da80c
```

### Code Examples

#### Getting Quote ID from Route Response

The `quoteId` can be found at the top level of the route response. Including this parameter in status requests will enable volume and specific token activity sharing with integrators in the near future:

```json
{
    "route": {
        "quoteId": "6f388be5205ee044cd7fd5047a4ce72e"
    }
}
```

#### Updated SDK Interface

```typescript
interface StatusParams {
  transactionId: string;
  requestId?: string;
  integratorId?: string;
  quoteId?: string;
}
```

#### Function to Get Transaction Status

```javascript
// Function to get the status of the transaction using Squid API
const getStatus = async (params: any) => {
  try {
    const result = await axios.get("https://v2.api.squidrouter.com/v2/status", {
      params: {
        transactionId: params.transactionId,
        requestId: params.requestId,
        fromChainId: params.fromChainId,
        toChainId: params.toChainId,
        quoteId: params.quoteId, // Required for Squid Intents transactions
      },
      headers: {
        "x-integrator-id": integratorId,
      },
    });
    return result.data;
  } catch (error) {
    if (error.response) {
      console.error("API error:", error.response.data);
    }
    console.error("Error with parameters:", params);
    throw error;
  }
};
```

#### Polling for Transaction Status

```javascript
// Function to periodically check the transaction status until it completes
const updateTransactionStatus = async (txHash: string, requestId?: string, quoteId?: string) => {
  const getStatusParams = {
    transactionId: txHash,
    requestId: requestId,
    fromChainId: fromChainId,
    toChainId: toChainId,
    quoteId: quoteId, // Required for Squid Intents transactions
  };

  let status;
  const completedStatuses = ["success", "partial_success", "needs_gas", "not_found", "refund_status"];
  const maxRetries = 10; // Maximum number of retries for status check
  let retryCount = 0;

  do {
    try {
      status = await getStatus(getStatusParams);
      console.log(`Route status: ${status.squidTransactionStatus}`);
    } catch (error) {
      if (error.response && error.response.status === 404) {
        retryCount++;
        if (retryCount >= maxRetries) {
          console.error("Max retries reached. Transaction not found.");
          break;
        }
        console.log("Transaction not found. Retrying...");
        await new Promise((resolve) => setTimeout(resolve, 5000)); // Wait for 5 seconds before retrying
        continue;
      } else {
        throw error; // Rethrow other errors
      }
    }

    if (!completedStatuses.includes(status.squidTransactionStatus)) {
      await new Promise((resolve) => setTimeout(resolve, 5000)); // Wait for 5 seconds before checking the status again
    }
  } while (!completedStatuses.includes(status.squidTransactionStatus));
};
```

### Understanding squidTransactionStatus

This param will tell you what to show the user. There are 6 possible states:

```typescript
{
  SUCCESS = "success",
  NEEDS_GAS = "needs_gas",
  ONGOING = "ongoing",
  PARTIAL_SUCCESS = "partial_success",
  NOT_FOUND = "not_found",
  REFUND_STATUS = "refund"
}
```

#### SUCCESS

This indicates the transaction has completed on all chains. Whether a single chain, 2 chain or 3 chain call, the swap, stake, NFT purchase, bridge etc. has completed without any reversions and the user has received the intended funds.

#### NEEDS\_GAS

This state is specific for Axelar transactions. If the gas price has spiked on the destination chain and execution cannot complete, Squid will return this status. The best user flow in this case is to send the user to Axelarscan to view the paused transaction.

#### ONGOING

There is nothing wrong, nothing to do, just relax and wait. The transaction should have an `estimatedRouteDuration` in seconds that you can read from the `/route` response. We generally recommend contacting support after either 15 minutes has passed, or double the `estimatedRouteDuration`, whichever is larger.

#### PARTIAL\_SUCCESS

This status indicates that the transaction has completed some of its steps. Currently, there is only one case that could cause this state. In the future there will be many, but we will provide more metadata around the `PARTIAL_SUCCESS`. For now, this is what has happened:

* The source chain transaction successfully executed, along with any swaps or contract calls.
* The destination chain transaction has executed, but reverted during execution. This is usually due to slippage on volatile assets, but if you are trying to buy an NFT or do some cross-chain staking, then it could indicate that the custom hook had a failure.

**What token do I receive when a swap fails?**

The token you receive depends on the route type:

| Route Type        | Failure Behavior       | Token Received                                                                                     |
| ----------------- | ---------------------- | -------------------------------------------------------------------------------------------------- |
| **Axelar**        | Destination swap fails | **axlUSDC** on the **destination chain**                                                           |
| **Squid Intents** | Swap fails             | **RFQ bridge token** (typically the chain's native asset or USDC) refunded on the **source chain** |

{% hint style="info" %}
For Axelar routes, you will receive axlUSDC in your destination wallet. For Squid Intents routes, the funds are refunded to your source address — see the REFUND status below.
{% endhint %}

#### NOT\_FOUND

The Squid API cannot find an on-chain record of the transaction. This is usually due to our various services or service providers not having indexed the completed transaction. This state is often returned for 5-10 seconds after the transaction was executed, while chain indexing occurs.

This should not persist after maximum a few minutes (some chains such as Filecoin take a very long time to index, and for block inclusion). If it does, then get in touch with us on Discord.

#### REFUND

This status is specific to failed Squid Intents routes. When a Squid Intents transaction fails, the funds are automatically refunded on the source chain. This is the default behavior for Squid Intents routes when passing the user's address as the `fromAddress`. Refunds typically take \~10 minutes

**How Squid Intents refunds work:**

* Funds are always transferred from the `msg.sender` on the source chain (this could be the user for direct calls to Squid Intents, or a smart contract like Multicall)
* When refunded, funds are sent to the `order.fromAddress` which is encoded to the user, not the caller
* The `fromAddress` from the route request is used as the `order.fromAddress` for refunds
* This ensures that even if the transaction was initiated through a smart contract, the refund goes to the actual user


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.squidrouter.com/api-and-sdk-integration/key-concepts/track-status.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
