# IMQLock.token() method · @imqueue/rpc

Source: https://imqueue.org/api/rpc/latest/rpc.imqlock.token/
Published: 2026-08-31
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/rpc 3.9.0 — generated reference, not hand-written

Returns the token identifying the current holder of a given key, or `undefined` when the key is not locked.

**Signature:**

```typescript
static token(key: string): number | undefined;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| key | string | key to read the current holder's token for |


**Returns:**

number \| undefined

## Remarks

Read it immediately after [IMQLock.acquire()](https://imqueue.org/api/rpc/latest/rpc.imqlock.acquire/) resolves and [IMQLock.locked()](https://imqueue.org/api/rpc/latest/rpc.imqlock.locked/) confirms you are the holder, then hand it back to [IMQLock.release()](https://imqueue.org/api/rpc/latest/rpc.imqlock.release/) — that is what proves the release is yours. There is no way to recover it later: once the deadlock timeout has freed the key, this returns the NEXT holder's token, which is exactly the confusion the token exists to prevent.

