> ## Documentation Index
> Fetch the complete documentation index at: https://invoca-5bd45748-mintlify-8d5425ca.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Call Recording Condition

> Define conditional logic that controls when Invoca records inbound calls on a campaign, using the Network Integration call_recording_condition endpoint.

## Manage call recording conditions for campaigns

A call recording condition can be set for a campaign to determine whether or not the call should be recorded. The call will be recorded if the full condition is met.

### Set Call Recording Condition

To conditionally record calls, set `"record_calls"` to `true` and set `"call_recording_condition"` to the expression you want to evaluate.

POST

`https://invoca.net/api/@@CAMPAIGN_FEATURES_API_VERSION/<network_id>/advertisers/<advertiser_id_from_network>/advertiser_campaigns/<advertiser_campaign_id_from_network>.json`

Example Request Body

```json theme={null}
{
  "ivr_tree": {
    "record_calls": true,
    "call_recording_condition": "during_hours and repeat",
    "root": {
      "node_type": "Connect",
      "destination_phone_number": "8056173768",
      "destination_country_code": ""
    }
  }
}
```

### Record All Calls

To record all calls (and to remove an existing call recording condition), set `"record_calls"` to `true` and set `"call_recording_condition"` to empty string `""`.

POST

`https://invoca.net/api/@@CAMPAIGN_FEATURES_API_VERSION/<network_id>/advertisers/<advertiser_id_from_network>/advertiser_campaigns/<advertiser_campaign_id_from_network>.json`

Example Request Body

```json theme={null}
{
  "ivr_tree": {
    "record_calls": true,
    "call_recording_condition": "",
    "root": {
      "node_type": "Connect",
      "destination_phone_number": "8056173768",
      "destination_country_code": ""
    }
  }
}
```

### Record No Calls

To record no calls (and to remove an existing call recording condition), set `"record_calls"` to `false` and set `"call_recording_condition"` to empty string `""`.

(If `"record_calls"` is `false`, no calls will be recorded even if there is a `"call_recording_condition"` set.)

POST

`https://invoca.net/api/@@CAMPAIGN_FEATURES_API_VERSION/<network_id>/advertisers/<advertiser_id_from_network>/advertiser_campaigns/<advertiser_campaign_id_from_network>.json`

Example Request Body

```json theme={null}
{
  "ivr_tree": {
    "record_calls": false,
    "call_recording_condition": "",
    "root": {
      "node_type": "Connect",
      "destination_phone_number": "8056173768",
      "destination_country_code": ""
    }
  }
}
```

### Conditions

| Condition                           | Details                                                                                                                                                                                                                                                                                                                                              | Examples                                                                                                                                                                                              |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| during\_hours                       | True if the caller is calling during the hours specified in the campaign.                                                                                                                                                                                                                                                                            | during\_hours                                                                                                                                                                                         |
| repeat                              | True if the caller has already called this campaign in the last N days (the interval N can be set on the campaign; the default is 30 days).                                                                                                                                                                                                          | repeat                                                                                                                                                                                                |
| landline                            | True if the caller is calling from a landline phone.                                                                                                                                                                                                                                                                                                 | landline                                                                                                                                                                                              |
| mobile                              | True if the caller is calling from a mobile phone.                                                                                                                                                                                                                                                                                                   | mobile                                                                                                                                                                                                |
| pressed\[key]                       | True if the caller pressed the key. Supported characters (case sensitive): \[1-9, a-z, W, N]. For a sub-menu keypress, join characters in their expected order with spaces (e.g. 1 1 2).                                                                                                                                                             | pressed\[3]                                                                                                                                                                                           |
| custom\_data\[field\_partner\_name] | True if the custom data field value matches (=) the expected value; True if the custom data field value does not match (!=) the expected value; True if the custom data field value contains (contains) the expected value; True if the custom data field value is present (present)                                                                 | custom\_data\[product] = "Printer"; custom\_data\[product] != "Fax Machine"; custom\_data\[product] contains "Chair"; custom\_data\[product] present                                                  |
| affiliate\_name                     | True if the affiliate name value matches (=) the expected value; True if the affiliate name value does not match (!=) the expected value; True if the affiliate name value contains (contains) the expected value; True if the affiliate name value is present (present)                                                                             | affiliate\_name = "Captain Crunch Publishing"; affiliate\_name != "Count Chocula Publishing"; affiliate\_name contains "Cocoa"; affiliate\_name present                                               |
| media\_type                         | True if the media type for the promo number called matches (=) the expected value; True if the media type for the promo number called does not match (!=) the expected value; True if the media type for the promo number called contains (contains) the expected value; True if the media type for the promo number called is present (present)     | media\_type = "Online: Content / Review Site"; media\_type != "Online: Email"; media\_type contains "Online"; media\_type present                                                                     |
| promo\_number\_description          | True if the description for the promo number called matches (=) the expected value; True if the description for the promo number called does not match (!=) the expected value; True if the description for the promo number called contains (contains) the expected value; True if the description for the promo number called is present (present) | promo\_number\_description = "Very important number"; promo\_number\_description != "Old marketing number"; promo\_number\_description contains "New ad campaign"; promo\_number\_description present |
| and                                 | Joins two conditions and is true if both conditions are true.                                                                                                                                                                                                                                                                                        | repeat and during\_hours                                                                                                                                                                              |
| or                                  | Joins two conditions and is true if either condition is true.                                                                                                                                                                                                                                                                                        | repeat or during\_hours                                                                                                                                                                               |
| not                                 | Inverts the following condition.                                                                                                                                                                                                                                                                                                                     | not during\_hours                                                                                                                                                                                     |
| ( )                                 | Used for grouping.                                                                                                                                                                                                                                                                                                                                   | mobile and (repeat or during\_hours)                                                                                                                                                                  |

Note that **and** is higher precedence than **or**. So if you use both in a condition like this:

```
mobile or repeat and during_hours
```

it is equivalent to this:

```
mobile or (repeat and during_hours)
```
