{
  "id": "ts.madd",
  "title": "TS.MADD",
  "url": "https://redis.io/docs/latest/commands/ts.madd/",
  "summary": "Append new samples to one or more time series",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-04-09T10:29:34-04:00",
  "page_type": "content",
  "content_hash": "0e3fcfbcc94f5c3086baed07a72d508250eef9bc262f84ad43b8e1c7ce7c8c07",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "This command's behavior varies in clustered Redis environments. See the [multi-key operations]() page for more information.\n\n\n\n\nAppend new samples to one or more time series\n\n[Examples](#examples)"
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open>\n<summary><code>key</code></summary> \n\nis the key name for the time series.\n</details>\n\n<details open>\n<summary><code>timestamp</code></summary>\n\nis Unix time (integer, in milliseconds) specifying the sample timestamp or `*` to set the sample timestamp to the Unix time of the server's clock.\n\nUnix time is the number of milliseconds that have elapsed since 00:00:00 UTC on 1 January 1970, the Unix epoch, without adjustments made due to leap seconds.\n</details>\n\n<details open>\n<summary><code>value</code></summary>\n\nis numeric data value of the sample (double). The double number should follow <a href=\"https://tools.ietf.org/html/rfc7159\">RFC 7159</a> (JSON standard). The parser rejects overly large values that would not fit in binary64. It does not accept infinite values. NaN (Not a Number) values are supported starting from Redis 8.6.\n</details>\n\n<note><b>Notes:</b>\n- If `timestamp` is older than the retention period compared to the maximum existing timestamp, the sample is discarded and an error is returned.\n- Explicitly adding samples to a compacted time series (using [`TS.ADD`](), `TS.MADD`, [`TS.INCRBY`](), or [`TS.DECRBY`]()) may result in inconsistencies between the raw and the compacted data. The compaction process may override such samples.\n- `ignoreMaxTimeDiff` and `ignoreMaxValDiff` cannot be specified as is the case with `TS.ADD`. However, the same logic still applies based on the values of the per-key configuration parameters. See the [`TS.ADD`]() command page for more information.\n</note>"
    },
    {
      "id": "complexity",
      "title": "Complexity",
      "role": "performance",
      "text": "If a compaction rule exits on a time series, TS.MADD performance might be reduced.\nThe complexity of TS.MADD is always `O(N*M)`, where `N` is the amount of series updated and `M` is the number of compaction rules or `O(N)` with no compaction."
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "<details open>\n<summary><b>Add stock prices at different timestamps</b></summary>\n\nCreate two stocks and add their prices at three different timestamps.\n\n\n127.0.0.1:6379> TS.CREATE stock:A LABELS type stock name A\nOK\n127.0.0.1:6379> TS.CREATE stock:B LABELS type stock name B\nOK\n127.0.0.1:6379> TS.MADD stock:A 1000 100 stock:A 1010 110 stock:A 1020 120 stock:B 1000 120 stock:B 1010 110 stock:B 1020 100\n1) (integer) 1000\n2) (integer) 1010\n3) (integer) 1020\n4) (integer) 1000\n5) (integer) 1010\n6) (integer) 1020\n\n</details>"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Supported</span><br /> | <span title=\"Supported\">&#x2705; Flexible & Annual</span><br /><span title=\"Supported\">&#x2705; Free & Fixed</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n* [Array reply](), where each element is an [Integer reply]() representing the timestamp of a upserted sample. For each element that is ignored (see `IGNORE` in [`TS.CREATE`]()), the reply element value will be the largest timestamp in the time series.\n* [Simple error reply]() in these cases: invalid arguments, wrong key type, duplication policy is `BLOCK`, or when `timestamp` is older than the retention period compared to the maximum existing timestamp.\n\n**RESP3:**\n\nOne of the following:\n* [Array reply](), where each element is an [Integer reply]() representing the timestamp of a upserted sample. For each element that is ignored (see `IGNORE` in [`TS.CREATE`]()), the reply element value will be the largest timestamp in the time series.\n* [Simple error reply]() in these cases: invalid arguments, wrong key type, duplication policy is `BLOCK`, or when `timestamp` is older than the retention period compared to the maximum existing timestamp."
    },
    {
      "id": "see-also",
      "title": "See also",
      "role": "related",
      "text": "[`TS.MRANGE`]() | [`TS.RANGE`]() | [`TS.MREVRANGE`]() | [`TS.REVRANGE`]()"
    },
    {
      "id": "related-topics",
      "title": "Related topics",
      "role": "related",
      "text": "[RedisTimeSeries]()"
    }
  ],
  "examples": []
}
