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

# Create vesting lock

> Build a transaction that locks tokens into a vesting contract

Builds an unsigned transaction that locks tokens into the Snekfun vesting contract.

**Auth:** Public

## Request body

<ParamField body="address" type="string" required>
  Caller's Cardano address.
</ParamField>

<ParamField body="assetId" type="string" required>
  Token asset ID to lock.
</ParamField>

<ParamField body="amount" type="string" required>
  Amount of tokens to lock (bigint string). When divided by `stagesCount`, each stage amount must remain positive.
</ParamField>

<ParamField body="lockEnd" type="number" required>
  Unlock time as a Unix timestamp in milliseconds.
</ParamField>

<ParamField body="stagesCount" type="number" required>
  Number of vesting stages from 1 to 10. Tokens unlock in equal tranches across stages.
</ParamField>

## Response

<ResponseField name="cbor" type="string">
  Hex-encoded unsigned transaction CBOR.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://token-vesting.snek.fun/create-lock \
    --header 'Content-Type: application/json' \
    --data '{
      "address": "addr1...",
      "assetId": "policyId.assetNameHex",
      "amount": "1000000000",
      "lockEnd": 1735689600000,
      "stagesCount": 4
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "cbor": "84a500..."
  }
  ```
</ResponseExample>

## Error response

<ResponseField name="cause" type="string">
  Machine-readable error code.
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable error message.
</ResponseField>

Possible errors:

* `400 INVALID_PARAMS` — one or more required fields are missing or have the wrong type.
* `400 INVALID_LOCK_END` — `lockEnd` must be in the future.
* `400 INVALID_AMOUNT` — `amount / stagesCount` is zero after integer division, so the per-stage amount is not positive.
* `500 SERVER_ERROR` — unexpected server-side failure.

<ResponseExample>
  ```json 400 theme={null}
  {
    "cause": "INVALID_LOCK_END",
    "message": "lockEnd must be in the future"
  }
  ```
</ResponseExample>
