---
title: "Save Campaign Targeting"
method: PUT
path: "/campaigns/{campaign_id}/rules"
tags: ["authenticated", "campaigns"]
---

# Save Campaign Targeting

`PUT /campaigns/{campaign_id}/rules`

## Request

- Base URL: `https://api-docs.upsmith.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api-docs.upsmith.com/campaigns/{campaign_id}/rules`
- Auth: one of:
  - API key in header `x-api-key`
  - HTTP bearer

Persist the targeting rule builder's state as campaign-level rules.

Converts each rule group into a ``campaign_rule`` row (``rule_type_key``
= the group's source, ``params`` = the group payload) and proxies to
campaign-service's full-replacement PUT, which validates params against
the engine's discriminated union.

## Path parameters

- `campaign_id` string, required

## Headers

- `organization-id` string, nullable
- `x-user-id` string, nullable
- `timezone` string
- `x-actor-email` string, nullable
- `x-request-source` string, nullable
- `x-operation-id` string, nullable
- `x-commit-message` string, nullable
- `x-confirmation-id` string, nullable
- `x-chat-id` string, nullable

## Request body

- SaveCampaignTargetingBody: Full replacement rule set in the rule-builder's wire shape. Each entry is a rule group as produced by the frontend serializer (``source``, ``mode``, ``match``, ``filters``, optional ``groups`` / ``groups_match``) — the same shape ``targeting-preview`` accepts, so what the user previewed is exactly what gets persisted.
  - `rules` object[], required

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/upsmith/apis/upsmith-api.md) - [All operations](https://skmtc.dev/upsmith/apis/upsmith-api/llms.txt) - [OpenAPI document](https://skmtc.dev/upsmith/apis/upsmith-api/revisions/86e2c2bd93af?raw)
