---
title: "Replace a stale location"
type: reference
method: POST
path: /rest-api/targeting/stale-locations/replace.do
tag: "Targeting Rules"
---

# Replace a stale location

`POST https://YOUR-NETWORK-DOMAIN/rest-api/targeting/stale-locations/replace.do`

Swaps one stale location rule for a rule naming a place the geo database knows, with the same include or exclude and the same entity, and removes the stale rule; both changes are written to the action log. Region and city are optional and checked like location targeting create. When the entity already has that rule, only the stale one is removed and 'alreadyPresent' is true. Country rules cannot be replaced; remove them instead.

## Form params

| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| `targetId` | integer | yes | `8012` | Id of the stale location rule |
| `countryCode` | string | yes | `US` | ISO 3166-1 alpha-2 country code of the new place |
| `regionName` | string | no | `Nevada` | Region of the new place, as GET /rest-api/targeting/country/region/values.do lists it |
| `cityName` | string | no | `Las Vegas` | City of the new place, as GET /rest-api/targeting/country/region/city/values.do lists it |

## Responses

- `200` — {success, removedId, targetId, value, alreadyPresent}
- `400` — Unknown country code, region or city, or the rule is a country rule
- `401` — Authentication error
- `403` — The role may not change this rule
- `404` — Not a stale rule the user may manage
- `503` — The geo service did not answer

## Example request

```bash
curl --request POST \
  --url 'https://YOUR-NETWORK-DOMAIN/rest-api/targeting/stale-locations/replace.do' \
  --header 'X-Api-Key: YOUR_API_KEY' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'targetId=8012' \
  --data-urlencode 'countryCode=US' \
  --data-urlencode 'regionName=Nevada' \
  --data-urlencode 'cityName=Las Vegas'
```

Source: https://epom.com/ad-server/docs/api/targeting-rules/post-targeting-stale-locations-replace