---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/dev/direct/doc/dg-v4/en/live/RetargetingCondition_Add.md
  - https://yandex.com/dev/direct/doc/dg-v4/ru/live/RetargetingCondition_Add.md
  - href: en/live/RetargetingCondition_Add.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/direct/doc/dg-v4/en/llms.txt

# Add
Creates a retargeting condition.

{% note alert %}

Disabled method. Use version 5 of the API.

For information about the compatibility of methods between versions Live 4 and 5, see the [Migration guide](https://yandex.com/dev/direct/doc/migration/concepts/methods.md).

{% endnote %}


## Input data

The input data structure in JSON is shown below.

```javascript
{
   "method": "RetargetingCondition",
   "param": {
      /* RetargetingConditionRequest */
      "Action": (string),
      "RetargetingConditions": [
         {  /* RetargetingCondition */
            "RetargetingConditionName": (string),
            "RetargetingConditionDescription": (string),
            "Login": (string),
            "RetargetingCondition": [
               {  /* RetargetingConditionItem */
                  "Type": (string),
                  "Goals": [
                     {  /* RetargetingConditionGoalItem */
                        "Time": (int),
                        "GoalID": (long)
                     }
                     ...
                  ] 
               } 
               ...
            ]
         }
         ...
      ]
   }
}
```

Parameters are described below.


#|
||
**<sup >Parameter</sup>**
|
**<sup >Description</sup>**
|
**<sup >Required</sup>**
||

||
**<sub >RetargetingConditionRequest object</sub>**
||
||
`Action`
|
Action: Add.
|
Yes
||
||
`RetargetingConditions`
|
Array of `RetargetingCondition` objects containing information about retargeting conditions.
|
Yes
||

||
**<sub >RetargetingCondition object</sub>**
||
||
`RetargetingConditionName`
|
Name of the retargeting condition (maximum 250 characters).
|
Yes
||
||
`RetargetingConditionDescription`
|
Text description of the retargeting condition (maximum 4096 characters).
|
No
||
||
`Login`
|
Username of the condition's owner.

Direct advertisers set their own Yandex username; advertising agencies set their client's username.
|
Yes
||
||
`RetargetingCondition`
|
Array of `RetargetingConditionItem` objects. Each object contains a group that describes the desired user behavior. If the retargeting condition has several groups, they are united with the logical AND operator (the condition is satisified if all the groups of goals are achieved).
|
Yes
||

||
**<sub >RetargetingConditionItem object</sub>**
||
||
`Type`
|
Type of group:

- all — The group is satisfied if all the goals and segments are met.
- or — The group is satisfied if at least one of the goals or segments is met.
- not — The group is satisfied if none of the goals or segments is met.

A retargeting condition that uses Yandex Metrica segments or Yandex Audience segments must contain at least one "all" or "or" type of group. A retargeting condition that consists solely of "not" groups can only use Yandex Metrica goals.
|
Yes
||
||
`Goals`
|
Array of goals and segments (`RetargetingConditionGoalItem` objects).
|
Yes
||

||
**<sub >RetargetingConditionGoalItem object</sub>**
||
||
`Time`
|
Number of days (from 1 to 90) for checking whether goals are completed or segments are matched.
|
For Yandex Metrica goals and segments
||
||
`GoalID`
|
ID of the goal or segment.
|
Yes
||
|#

## Output data


{% note alert %}

An error when adding one of the retargeting conditions does not cause the entire operation to be canceled, and does not affect the success of adding other retargeting conditions.

{% endnote %}


The output data structure in JSON is shown below.

```javascript
{
   "data": {
      /* RetargetingConditionResponse */
      "ActionsResult": [
         {  /* RetargetingConditionActionResult */
            "Warnings": [
               {  /* Warning */
                  "WarningCode": (int),
                  "WarningString": (string),
                  "Description": (string)
               }
               ...
            ],
            "Errors": [
               {  /* Error */
                  "FaultCode": (int),
                  "FaultString": (string),
                  "FaultDetail": (string)
               }
               ...
            ],
            "RetargetingConditionID": (int)
         }
         ...
      ]
   }
}
```

Parameters are described below.


#|
||
**<sup >Parameter</sup>**
|
**<sup >Description</sup>**
||

||
**<sub >RetargetingConditionResponse object</sub>**
||
||
`ActionsResult`
|
Array of `RetargetingConditionActionResult` objects. Each object corresponds to an item in the `RetargetingConditions` input array.

- If the operation was completed successfully, the object contains the ID of the added/updated retargeting condition.
- If the operation was completed but issues occurred during the operation, the object contains the ID of the added/updated retargeting condition and a `Warnings` array containing a description of those issues.
- The `Errors` array, if an error occurred.

The items in the array are in the same order as the objects in the `RetargetingConditions` input array.
||

||
**<sub >RetargetingConditionActionResult object</sub>**
||
||
`Warnings`
|
Array of `Warning` objects describing issues that occurred while performing the operation.
||
||
`Errors`
|
Array of `Error` objects with errors that occurred while performing the operation.
||
||
`RetargetingConditionID`
|
ID of the retargeting condition.
||

||
**<sub >Warning object</sub>**
||
||
`WarningCode`
|
Warning code.
||
||
`WarningString`
|
Warning text.
||
||
`Description`
|
Warning description in JSON format.
||

||
**<sub >Error object</sub>**
||
||
`FaultCode`
|
Error code.
||
||
`FaultString`
|
Textual message about the error.
||
||
`FaultDetail`
|
Detailed description of the reason for the error.
||
|#

## Examples of input data

# Python

```python
{
   'Action': 'Add',
   'RetargetingConditions': [
      {
         'RetargetingConditionName': u'Order incomplete',
 'RetargetingConditionDescription': u'Added items to basket but didn't complete the order',
 'Login': 'agrom',
 'RetargetingCondition': [
            {
               'Type': 'or',
               'Goals': [
                  {  
                     'Time': 14,
                     'GoalID': 1557799
                  },
                  {  
                     'Time': 14,
                     'GoalID': 1558005
                  }
               ]
            },
            {
               'Type': 'not',
               'Goals': [
                  {  
                     'Time': 11,
                     'GoalID': 1559911
                  }
               ]
            }
         ]
      }
   ]
}
```

# PHP

```php
array(
   'Action' => 'Add',
   'RetargetingConditions' => array(
      array(
         'RetargetingConditionName' => 'Order incomplete',
 'RetargetingConditionDescription' => 'Added items to basket but didn't complete the order',
 'Login' => 'agrom',
 'RetargetingCondition' = array(
            array(
               'Type' => 'or',
               'Goals' => array(
                  array(
                     'Time' => 14,
                     'GoalID' =1557799
                  ),
                  array(
                     'Time' => 14,
                     'GoalID' =1558005
                  )
               )
            ),
            array(
               'Type' => 'not',
               'Goals' => array(
                  array(
                     'Time' => 11,
                     'GoalID' =1559911
                  )
               )
            )
         )
      )
   )
)
```

# Perl

```perl
{
   'Action' => 'Add',
   'RetargetingConditions' => [
      {
         'RetargetingConditionName' => 'Order incomplete',
 'RetargetingConditionDescription' => 'Added items to basket but didn't complete the order',
 'Login' => 'agrom',
 'RetargetingCondition' => [
            {
               'Type' => 'or',
               'Goals' => [
                  {  
                     'Time' => 14,
                     'GoalID' =1557799
                  },
                  {  
                     'Time' => 14,
                     'GoalID' =1558005
                  }
               ]
            },
            {
               'Type' => 'not',
               'Goals' => [
                  {  
                     'Time' => 11,
                     'GoalID' =1559911
                  }
               ]
            }
         ]
      }
   ]
}
```

## Related information

- [Retargeting](https://yandex.com/dev/direct/doc/dg-v4/en/concepts/retargeting.md)

