## PATCH /api/v2/domains/{id}/email-forwarding/{ruleId}

**Update domain email forwarding rule recipients**

Replace the recipients of one domain-level email forwarding rule. Get `{id}` from `GET /api/v2/domains` `data[].id` and `{ruleId}` from `GET /api/v2/domains/{id}/email-forwarding` `rules[].id`; `{ruleId}` must be the public `ef_...` ID. The body may contain only `destinations`. The source address of a rule cannot be changed: delete the rule with `DELETE /api/v2/domains/{id}/email-forwarding/{ruleId}` and create a new one. Recipients that are not verified yet are registered and sent a verification email; the response then reports `createOutcome.status: "verification_required"` and the rule keeps forwarding to its current recipients until the request is repeated after verification. Rules managed outside the forwarding editor cannot be edited and return 409 `email_forwarding_not_editable`. The response is the refreshed forwarding state, the same shape as `POST /api/v2/domains/{id}/email-forwarding`.

### Related Endpoints

- `DELETE /api/v2/domains/{id}/email-forwarding/{ruleId}`: Delete domain email forwarding rule
- `GET /api/v2/domains/{id}/email-forwarding`: Get domain email forwarding
- `POST /api/v2/domains/{id}/email-forwarding`: Create domain email forwarding rule

### Headers

- `Accept`: application/json
- `Authorization`: Bearer YOUR_API_KEY
- Required API scopes: `write:email`, `write:domains`
- `Content-Type`: application/json

### Parameters

- `id` (path, string, required): Public domain ID from `GET /api/v2/domains` `data[].id`. Do not invent this value; use the exact ID returned by the referenced API response. Example: `dom_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `ruleId` (path, string, required): Public email-forwarding rule ID from `rules[].id`. Do not invent this value; use the exact ID returned by the referenced API response. Example: `dom_01hxa3b4c5d6e7f8g9h0j1k2m3`

### Request Body

- `destinations` (array<string>, required): The complete new recipient list for the rule; addresses not listed stop receiving mail. Example: `["owner@example.net","backup@example.org"]`

### Request Examples

#### Forward to two addresses

```bash
curl -X PATCH "https://cloud.hostup.se/api/v2/domains/dom_01hxa3b4c5d6e7f8g9h0j1k2m3/email-forwarding/dom_01hxa3b4c5d6e7f8g9h0j1k2m3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "destinations": [
      "owner@example.net",
      "backup@example.org"
    ]
  }'
```

```json
{
  "destinations": [
    "owner@example.net",
    "backup@example.org"
  ]
}
```

### Response Schema

- `enabled` (boolean, optional) Example: `true`
- `integrationStatus` (string, optional) Example: `enabled`
  Allowed values: enabled, disabled, unavailable
- `reason` (string, optional, nullable): Nullable (may be null when not applicable). Example: `null`
- `maxRules` (integer, optional) Example: `200`
- `ruleCount` (integer, optional) Example: `1`
- `rules` (array<object>, optional)
- `rules[].id` (string, required) Example: `ef_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `rules[].email` (string, required) Example: `hello@example.com`
- `rules[].destination` (string, required) Example: `owner@example.net`
- `rules[].isEnabled` (boolean, required) Example: `true`
- `rules[].name` (string, required, nullable): Nullable (may be null when not applicable). Example: `null`
- `rules[].priority` (integer, required) Example: `0`
- `destinations` (array<object>, optional)
- `destinations[].id` (string, required) Example: `efd_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `destinations[].email` (string, required) Example: `owner@example.net`
- `destinations[].verificationStatus` (string, required) Example: `verified`
  Allowed values: verified, pending, unverified
- `destinations[].createdAt` (string, required, nullable): Nullable (may be null when not applicable). Example: `2026-04-27T12:00:00.000Z`
- `destinations[].verifiedAt` (string, required, nullable): Nullable (may be null when not applicable). Example: `2026-04-27T12:05:00.000Z`
- `catchAll` (object | null, optional) Example: `{"action":"disabled","destination":null}`
- `catchAll.action` (string, required) Example: `disabled`
  Allowed values: forward, drop, disabled
- `catchAll.destination` (string, required, nullable): Nullable (may be null when not applicable). Example: `null`
- `existingMxRecords` (array<object>, optional)
- `existingMxRecords[].type` (string, required) Example: `MX`
  Allowed values: MX
- `existingMxRecords[].value` (string, required) Example: `mail.example.com`
- `existingMxRecords[].priority` (integer, required, nullable): Nullable (may be null when not applicable). Example: `10`
- `dnsActivation` (object, optional): Live state of the managed DNS zone this integration runs on. `active`: routing can be enabled now. `activating`: the domain already points at our nameservers and the zone is being activated — reading this resource requests the activation check, so poll until `active` (usually minutes). `not_delegated`: the domain's nameservers are elsewhere. `unavailable`: no managed zone, or the status could not be read.
- `dnsActivation.status` (string, required) Example: `activating`
  Allowed values: active, activating, not_delegated, unavailable
- `dnsActivation.reason` (string, required, nullable): Plain-English explanation for every non-active status; null when active. Example: `The domain points at our nameservers and its DNS zone is being activated. This usually completes within a few minutes.`
- `dnsActivation.checkedAt` (string, required) Example: `2026-08-22T12:00:00.000Z`
- `actions` (object, optional)
- `actions.canCreateNewRule` (object, required)
- `actions.canCreateNewRule.allowed` (boolean, required) Example: `true`
- `actions.canCreateNewRule.reason` (string, required, nullable): Nullable (may be null when not applicable). Example: `null`
- `actions.canCreateNewRule.code` (string, optional, nullable): Machine-readable reason code when an action is blocked. Example: `pending_order`
- `actions.canSetCatchAll` (object, required)
- `actions.canSetCatchAll.allowed` (boolean, required) Example: `true`
- `actions.canSetCatchAll.reason` (string, required, nullable): Nullable (may be null when not applicable). Example: `null`
- `actions.canSetCatchAll.code` (string, optional, nullable): Machine-readable reason code when an action is blocked. Example: `pending_order`
- `createOutcome` (object, optional)
- `createOutcome.createdRuleCount` (integer, required) Example: `1`
- `createOutcome.createdRules` (array<object>, required)
- `createOutcome.createdRules[].id` (string, required) Example: `ef_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `createOutcome.createdRules[].email` (string, required) Example: `hello@example.com`
- `createOutcome.createdRules[].destination` (string, required) Example: `owner@example.net`
- `createOutcome.createdRules[].isEnabled` (boolean, required) Example: `true`
- `createOutcome.createdRules[].name` (string, required, nullable): Nullable (may be null when not applicable). Example: `null`
- `createOutcome.createdRules[].priority` (integer, required) Example: `0`

### Responses

#### 200 - Recipients replaced, or verification requested for a new recipient. Refreshed forwarding state.
```json
{
  "enabled": true,
  "integrationStatus": "enabled",
  "reason": null,
  "maxRules": 200,
  "ruleCount": 1,
  "rules": [
    {
      "id": "ef_01hxa3b4c5d6e7f8g9h0j1k2m3",
      "email": "hello@example.com",
      "destination": "backup@example.org",
      "isEnabled": true,
      "name": "hello",
      "priority": 0
    }
  ],
  "destinations": [
    {
      "id": "efd_01hxa3b4c5d6e7f8g9h0j1k2m3",
      "email": "owner@example.net",
      "verificationStatus": "verified",
      "createdAt": "2026-04-27T12:00:00.000Z",
      "verifiedAt": "2026-04-27T12:05:00.000Z"
    }
  ],
  "catchAll": {
    "action": "disabled",
    "destination": null
  },
  "existingMxRecords": [],
  "actions": {
    "canCreateNewRule": {
      "allowed": true,
      "reason": null
    },
    "canSetCatchAll": {
      "allowed": true,
      "reason": null
    }
  },
  "createOutcome": {
    "createdRuleCount": 0,
    "createdRules": []
  }
}
```

#### 400 - The body contains something other than `destinations`, or a recipient is invalid.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Invalid request",
  "status": 400,
  "detail": "Only destinations can be updated.",
  "code": "invalid_request",
  "instance": "/api/v2/domains/dom_01hxa3b4c5d6e7f8g9h0j1k2m3/email-forwarding/ef_01hxa3b4c5d6e7f8g9h0j1k2m3"
}
```

#### 401 - Unauthorized. Authentication is required.
```json
{
  "type": "https://developer.hostup.se/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Authentication is required.",
  "code": "unauthorized",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 403 - Forbidden. The caller lacks a required scope or does not own the resource.
```json
{
  "type": "https://developer.hostup.se/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "The caller lacks a required scope or does not own the resource.",
  "code": "forbidden",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 404 - Unknown domain, forwarding not configured for the domain, or unknown rule ID.
```json
{
  "type": "https://developer.hostup.se/errors/email_forwarding_rule_not_found",
  "title": "Email forwarding rule not found",
  "status": 404,
  "detail": "The requested email forwarding rule could not be found.",
  "code": "email_forwarding_rule_not_found",
  "instance": "/api/v2/domains/dom_01hxa3b4c5d6e7f8g9h0j1k2m3/email-forwarding/ef_01hxa3b4c5d6e7f8g9h0j1k2m3"
}
```

#### 409 - The rule cannot be changed right now.
```json
{
  "type": "https://developer.hostup.se/errors/email_forwarding_not_editable",
  "title": "Rule cannot be edited",
  "status": 409,
  "detail": "This rule is managed outside the forwarding editor.",
  "code": "email_forwarding_not_editable",
  "instance": "/api/v2/domains/dom_01hxa3b4c5d6e7f8g9h0j1k2m3/email-forwarding/ef_01hxa3b4c5d6e7f8g9h0j1k2m3"
}
```

#### 429 - Rate limited. Retry after the limit resets. 429 responses include `Retry-After` seconds plus `X-RateLimit-*` headers.
```json
{
  "type": "https://developer.hostup.se/errors/rate_limit_exceeded",
  "title": "Too many requests",
  "status": 429,
  "detail": "Too many requests. Retry after the limit resets.",
  "code": "rate_limit_exceeded",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 500 - Internal error. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/internal_error",
  "title": "Internal server error",
  "status": 500,
  "detail": "An unexpected error occurred. Retry later or contact support if the issue persists.",
  "code": "internal_error",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 502 - The email provider did not confirm the change.
```json
{
  "type": "https://developer.hostup.se/errors/external_provider_failed",
  "title": "External provider failed",
  "status": 502,
  "detail": "Could not confirm the recipient change. Refresh the forwarding list before retrying.",
  "code": "external_provider_failed",
  "instance": "/api/v2/domains/dom_01hxa3b4c5d6e7f8g9h0j1k2m3/email-forwarding/ef_01hxa3b4c5d6e7f8g9h0j1k2m3"
}
```
