# XAUTOCLAIM

> Changes the ownership of pending messages from one consumer to another in a stream consumer group.

## Arguments

<ParamField body="key" type="string" required>
  The key of the stream.
</ParamField>

<ParamField body="group" type="string" required>
  The consumer group name.
</ParamField>

<ParamField body="consumer" type="string" required>
  The consumer name that will claim the messages.
</ParamField>

<ParamField body="minIdleTime" type="number" required>
  The minimum idle time in milliseconds for messages to be claimed.
</ParamField>

<ParamField body="start" type="string" required>
  The stream entry ID to start claiming from.
</ParamField>


<ParamField body="options" type="object">
  <Expandable title="options">
    <ParamField body="count" type="number">
      The maximum number of messages to claim.
    </ParamField>
    <ParamField body="justid" type="boolean">
      Return only the message IDs instead of the full message data.
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField type="[string, Array<[string, string[]]>, string[]]">
  Returns a tuple containing:
  - Next start ID for pagination
  - Array of claimed messages (ID and field-value pairs)
  - Array of deleted message IDs
</ResponseField>

<RequestExample>
```ts Basic autoclaim
const result = await redis.xautoclaim(
  "mystream",
  "mygroup", 
  "consumer1",
  60000,
  "0-0"
);
```

```ts With count and justid
const result = await redis.xautoclaim(
  "mystream",
  "mygroup",
  "consumer1", 
  60000,
  "0-0",
  { count: 5, justid: true }
);
```
</RequestExample>

<ResponseExample>
```ts
[
  "1638360173533-1", // next start ID
  [["1638360173533-0", ["field1", "value1", "field2", "value2"]]], // claimed messages
  [] // deleted message IDs
]
```
</ResponseExample>
