---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://docs.sendcorex.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.sendcorex.com/llms.txt"
---

Source: https://docs.sendcorex.com/pl/api-reference/receive-emails/rules/update-rule

Odbieranie e-maili: reguły

# Update Rule

Zastąp warunki, wyjątki i akcje reguły. Pozycja i liczba dopasowań zostają.

POST `https://g.sendcorex.com/v1` command: update_rule

Wyślij całą regułę, z tymi samymi polami co Create Rule. Brakujące pola nie są przenoszone ze starej wersji.

## Argumenty

- `id` string wymagane
`rule_id`.
- `name` string wymagane
Do 80 znaków.
- `conditions` object[] wymagane
Zobacz Create Rule.
- `actions` object[] wymagane
Zobacz Create Rule.
- `match` string opcjonalne
`all` lub `any`.
- `except` object[] opcjonalne
Wyjątki.
- `stop` boolean opcjonalne
Zatrzymaj przetwarzanie.
- `enabled` boolean opcjonalne
Włączona lub wyłączona.
- `timezone` string opcjonalne
Strefa czasowa IANA.

## Szybki start

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "update_rule",
        args: {
          id: "Vj0xUlVMRTAx",
          name: "Clients always in Inbox",
          match: "all",
          conditions: [
            {
              field: "from_domain",
              op: "in_list",
              value: "acme.com, globex.com"
            },
            {
              field: "provider",
              op: "is_any_of",
              value: [
                "microsoft_365",
                "google_workspace"
              ]
            }
          ],
          except: [
            {
              field: "subject",
              op: "contains",
              value: "newsletter"
            }
          ],
          actions: [
            {
              type: "keep_inbox"
            },
            {
              type: "label",
              value: "Clients"
            },
            {
              type: "star"
            }
          ],
          stop: false,
          timezone: "Asia/Kuala_Lumpur"
        }
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_TOKEN } },
);

const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);
```

## Odpowiedź

```
{
  "type": "SUCCESS",
  "results": [
    {
      "command": "update_rule",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "id": "Vj0xUlVMRTAx",
        "rule_id": "Vj0xUlVMRTAx",
        "name": "Clients always in Inbox",
        "match": "all",
        "conditions": [
          {
            "field": "from_domain",
            "op": "in_list",
            "value": "acme.com, globex.com"
          },
          {
            "field": "provider",
            "op": "is_any_of",
            "value": [
              "microsoft_365",
              "google_workspace"
            ]
          }
        ],
        "except": [
          {
            "field": "subject",
            "op": "contains",
            "value": "newsletter"
          }
        ],
        "actions": [
          {
            "type": "keep_inbox"
          },
          {
            "type": "label",
            "value": "Clients"
          },
          {
            "type": "star"
          }
        ],
        "stop": false,
        "timezone": "Asia/Kuala_Lumpur",
        "enabled": true,
        "position": 0,
        "hits": 128,
        "last_hit_at": "2026-10-25T09:12:44Z",
        "created_at": "2026-10-01T02:00:00Z",
        "updated_at": "2026-10-20T08:30:00Z"
      }
    }
  ]
}
```

## Błędy

Błędy na poziomie HTTP zwracają `type`, `code` i `message`. Błędy oznaczone CMD wracają w wyniku polecenia, z HTTP 200.

- 401`TOKEN_EXPIRED`
Access token wygasł. Wywołaj Refresh Token i powtórz zapytanie.
- 401`INVALID_TOKEN`
Token jest uszkodzony, nieznany lub unieważniony.
- 429`RATE_LIMITED`
Ponad 15 zapytań/s lub 15 jednocześnie dla tego samego IP + skrzynki. Odczekaj liczbę sekund z Retry-After.
- CMD`INVALID_ARGS`
Brakuje wymaganego argumentu lub jest nieprawidłowy.
- CMD`INVALID_RULE`
Reguła jest nieprawidłowa. Komunikat mówi, który warunek lub akcja i dlaczego.
- CMD`NOT_FOUND`
Wiadomość, wątek lub folder nie istnieje dla tego tokena.
- CMD`INTERNAL`
Błąd serwera. Szczegóły trafiają tylko do logu serwera.
