# HPEXPIREAT

> Sets an expiration time for field(s) in a hash in milliseconds since the Unix epoch.

## Arguments

<ParamField body="key" type="str" required>
  The key of the hash.
</ParamField>

<ParamField body="fields" type="Union[str, List[str]]" required>
  The field or list of fields to set an expiration time for.
</ParamField>

<ParamField body="timestamp" type="int" required>
  The expiration time as a Unix timestamp in milliseconds.
</ParamField>

<ParamField body="nx" type="bool" optional>
  Set expiry only when the field has no expiry. Defaults to `False`.
</ParamField>

<ParamField body="xx" type="bool" optional>
  Set expiry only when the field has an existing expiry. Defaults to `False`.
</ParamField>

<ParamField body="gt" type="bool" optional>
  Set expiry only when the new expiry is greater than the current one. Defaults to `False`.
</ParamField>

<ParamField body="lt" type="bool" optional>
  Set expiry only when the new expiry is less than the current one. Defaults to `False`.
</ParamField>

## Response

<ResponseField type="List[int]" required>
  A list of integers indicating whether the expiry was successfully set.

  - `-2` if the field does not exist in the hash or if the key doesn't exist.
  - `0` if the expiration was not set due to the condition.
  - `1` if the expiration was successfully set.
  - `2` if called with 0 seconds/milliseconds or a past Unix time.

  For more details, see [HPEXPIREAT documentation](https://redis.io/commands/hpexpireat).
</ResponseField>

<RequestExample>
```py Example
redis.hset(hash_name, field, value)

assert redis.hpexpireat(hash_name, field, int(time.time() * 1000) + 1000) == [1]
```
</RequestExample>
