# HTTL

> Get the remaining time to live of hash fields, in seconds.

URL: https://docs.hotkv.com/commands/httl/

```
HTTL key FIELDS numfields field [field ...]
```

- Group: Hash
- Complexity: O(N) where N is the number of fields given
- HotKV Cloud: all plans
- On-Premise: no license needed

`HTTL` returns how many seconds each listed field of the hash at `key` has
left before it expires. Partial seconds are rounded up.

`FIELDS` must come right after the key, and `numfields` must equal the number
of field names that follow.

## Return value

An array with one integer per field, in the order given, under both RESP2 and
RESP3:

| Value | Meaning |
| --- | --- |
| `-2` | The field or the key does not exist. |
| `-1` | The field exists but has no time to live. |
| `0` or more | The remaining time to live in seconds. |

Errors:

- `WRONGTYPE` if `key` holds a value that is not a hash.
- `ERR Mandatory argument FIELDS is missing or not at the right position`.
- `ERR Number of fields must be a positive integer`.
- ``ERR The `numfields` parameter must match the number of arguments``.

## Examples

```
127.0.0.1:6379> HSET session:9 token "abc" user "42"
(integer) 2
127.0.0.1:6379> HEXPIRE session:9 120 FIELDS 1 token
1) (integer) 1
127.0.0.1:6379> HTTL session:9 FIELDS 3 token user nope
1) (integer) 120
2) (integer) -1
3) (integer) -2
```

## Compatibility

Same as Redis 7.4. Valkey 8 does not have hash field expiration.

## See also

[HPTTL](https://docs.hotkv.com/commands/hpttl/index.md), [HEXPIRETIME](https://docs.hotkv.com/commands/hexpiretime/index.md), [HEXPIRE](https://docs.hotkv.com/commands/hexpire/index.md),
[HPERSIST](https://docs.hotkv.com/commands/hpersist/index.md), [TTL](https://docs.hotkv.com/commands/ttl/index.md)