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

# Unstake

> Unlock a stake position and credit principal plus accrued rewards

<span style={{display:"none"}}>For the complete documentation index, see [llms.txt](/llms.txt).</span>

Unlocks a specific stake position by its index (0-based). The customer's available balance is credited with the principal plus pro-rata rewards based on how long the stake was held. Customers may unstake early, in which case rewards are scaled proportionally.

<Info>
  Look up the right index with [`/stake-info`](/api-reference/tokens/staking/stake-info) or [`/stake-count`](/api-reference/tokens/staking/stake-count) before calling. Indexes do not change once assigned.
</Info>

### Request Body

<ParamField body="customer_ref" type="string" required>
  Your unique identifier for this customer
</ParamField>

<ParamField body="stake_index" type="integer" required>
  0-based index of the stake position
</ParamField>

### Response

<ResponseField name="tx_hash" type="string">
  Reference identifier for the unstake
</ResponseField>

```javascript theme={null}
await fetch("https://tokens.shakesco.com/unstake", {
  method: "POST",
  headers: { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ customer_ref: "customer-123", stake_index: 0 }),
});
```

<ResponseExample>
  ```json 200 OK theme={null}
  { "tx_hash": "0xabc..." }
  ```

  ```json 409 Already Unlocked theme={null}
  { "error": "Stake is already unlocked" }
  ```
</ResponseExample>
