> ## 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.

# Affiliate Campaigns

> Manage the campaigns that affiliates (publishers) are promoting on your Invoca network, including opt-ins, payouts, and status, via the Network Integration API.

Affiliate Campaign status can be replicated using this API. You are not allowed to delete affiliate campaigns.

## Affiliate Campaign Properties

| Property                     | Type                    | Description                                                                                    |
| ---------------------------- | ----------------------- | ---------------------------------------------------------------------------------------------- |
| affiliate\_id\_from\_network | string (read only)      | Network specific id of the affiliate.                                                          |
| status                       | string (read and write) | One of: Applied, Approved, Suspended, Declined.                                                |
| id                           | integer (read-only)     | The internal Invoca id of the affiliate campaign.                                              |
| id\_from\_network            | string (read and write) | Network specific id of the affiliate campaign.                                                 |
| max\_promo\_numbers          | integer (read only)     | Promo number limit.                                                                            |
| object\_url                  | string (read-only)      | URL for reaching the affiliate campaign in the UI.                                             |
| current\_terms               | (read only)             |                                                                                                |
| **advertiser\_payin**        |                         |                                                                                                |
| max                          | decimal                 | Maximum payin amount (base + bonuses).                                                         |
| min                          | decimal                 | Minimum payin amount (base).                                                                   |
| pricing                      | string                  | Human-friendly representation of the payin pricing (eg. "\$5.07 per call").                    |
| currency                     | string                  | USD, GBP, EUR.                                                                                 |
| range                        | string                  | Formatted string including min and max payin values.                                           |
| **policies**                 |                         |                                                                                                |
| amount                       | decimal                 | Payin policy amount.                                                                           |
| currency                     | string                  | USD, GBP, EUR.                                                                                 |
| type                         | string                  | Base, Bonus.                                                                                   |
| condition                    | string                  | Condition options used to determine the base or bonus payout (eg. "duration >= 1 min 30 sec"). |
| pricing\_type                | string                  | Fixed, OverallMargin, IndividualMargin.                                                        |
| ivr\_tree                    | hash                    | Interactive Voice Response tree.                                                               |
| **affiliate\_payout**        |                         |                                                                                                |
| max                          | decimal                 | Maximum payout amount (base + bonuses).                                                        |
| min                          | decimal                 | Minimum payout amount (base).                                                                  |
| pricing                      | string                  | Human-friendly representation of the payout pricing (eg. "\$5.07 per call").                   |
| currency                     | string                  | USD, GBP, EUR.                                                                                 |
| range                        | string                  | Formatted string including min and max payin values policies.                                  |
| **policies**                 |                         |                                                                                                |
| amount                       | decimal                 | Payout policy amount.                                                                          |
| currency                     | string                  | USD, GBP, EUR.                                                                                 |
| type                         | string                  | Base, Bonus.                                                                                   |
| condition                    | string                  | Condition options used to determine the base or bonus payout (eg. "duration >= 1 min 30 sec"). |

### Custom Data

Affiliate campaigns may have Custom Data Fields applied to them, which will be applied to calls originating through the affiliate campaign. To apply Custom Data Values to an affiliate campaign, the top level parameter `custom_data` should be assigned a hash with each pair's key corresponding to a partner name. The value of the pair should be the value to be applied.

For the following example, we would apply the value "Offline newspaper" to the Custom Data Field "channel".

```json theme={null}
{
  "custom_data": {
    "channel": "Offline newspaper"
  }
}
```

**Endpoint:**

`https://invoca.net/api/@@NETWORK_API_VERSION/<network_id>/advertisers/<advertiser_id_from_network>/advertiser_campaigns/<advertiser_campaign_id_from_network>/affiliates/<affiliate_id_from_network>/affiliate_campaigns.json`

***

## GET All Affiliate Campaigns

Get all Affiliate Campaigns for a given advertiser campaign.

**Endpoint:** `https://invoca.net/api/@@NETWORK_API_VERSION/<network_id>/advertisers/<advertiser_id_from_network>/advertiser_campaigns/<advertiser_campaign_id_from_network>/affiliate_campaigns.json`

**Format:** application/json

**Response Code:** 200

***

## GET an Affiliate Campaign

GET of Affiliate Campaign status for a specific advertiser campaign and affiliate.

**Endpoint:** `https://invoca.net/api/@@NETWORK_API_VERSION/<network_id>/advertisers/354/advertiser_campaigns/12/affiliates/976/affiliate_campaigns.json`

**Format:** application/json

**Response Code:** 200

### Response Example

```json theme={null}
{
  "max_promo_numbers": 10,
  "current_terms": {
    "advertiser_payin": {
      "max": 3.5,
      "min": 3.5,
      "pricing": "$3.50 per call",
      "currency": "USD",
      "range": "$3.50 per call",
      "policies": [
        {
          "amount": 3.5,
          "currency": "USD",
          "type": "Base",
          "condition": ""
        }
      ]
    },
    "pricing_type": "Fixed",
    "ivr_tree": {
      "root": {
        "children": [
          {
            "destination_country_code": "",
            "destination_phone_number": "",
            "node_type": "Connect",
            "prompt": ""
          },
          {
            "destination_country_code": "",
            "destination_phone_number": "",
            "node_type": "Connect",
            "prompt": ""
          }
        ],
        "node_type": "Menu",
        "prompt": "Press one for transfer to a normal campaign (scottad pro 0903), press two for normal campaign (scott ad pro 3122), press three for transfer to a syndicated campaign!"
      },
      "record_calls": false
    },
    "affiliate_payout": {
      "max": 3.5,
      "min": 3.5,
      "pricing": "$3.50 per call",
      "currency": "USD",
      "range": "$3.50 per call",
      "policies": [
        {
          "amount": 3.5,
          "currency": "USD",
          "type": "Base",
          "condition": ""
        }
      ]
    }
  },
  "status": "Approved_NotActive",
  "id": 1,
  "id_from_network": "11",
  "affiliate_id_from_network": "976",
  "object_url": "https://invoca.net/p_campaigns/terms/19/11",
  "custom_data": {
    "channel": "Online lead"
  }
}
```

***

## POST Create an Affiliate Campaign

Create Affiliate Campaign with status for a given advertiser campaign and affiliate.

<Note>The Network Integration API only provides the ability to create an affiliate campaign with status "Applied". If the Advertiser Campaign is set to "Approve All", the campaign will automatically transition to "Approved".</Note>

**Endpoint:** `https://invoca.net/api/@@NETWORK_API_VERSION/<network_id>/advertisers/354/advertiser_campaigns/12/affiliates/975/affiliate_campaigns.json`

**Format:** application/json

### Request Example

```json theme={null}
{
  "status": "Applied",
  "id_from_network": "2234",
  "custom_data": {
    "channel": "Offline lead"
  }
}
```

### Response Example

Same as a GET response, includes all the affiliate campaign properties.

***

### Error Example: Not Found (404)

Attempting to transition to an invalid status returns a 403 error.

**Endpoint:** `https://invoca.net/api/@@NETWORK_API_VERSION/<network_id>/advertisers/354/advertiser_campaigns/13/affiliates/976/affiliate_campaigns.json`

**Format:** application/json

#### Request Body

```json theme={null}
{
  "status": "Approved"
}
```

**Response Code:** 403

#### Response Body

```json theme={null}
{
  "errors": {
    "status": [
      "cannot transition from 'Approved'"
    ]
  },
  "status": "Applied"
}
```

***

## PUT Update an Affiliate Campaign

Update Affiliate Campaign status for a given advertiser campaign and affiliate.

**Endpoint:** `https://invoca.net/api/@@NETWORK_API_VERSION/<network_id>/advertisers/354/advertiser_campaigns/12/affiliates/976/affiliate_campaigns.json`

**Format:** application/json

### Request Example

```json theme={null}
{
  "status": "Approved"
}
```

### Response Example

Same as a GET response, includes all the affiliate campaign properties.

***

## DELETE an Affiliate Campaign

<Warning>You are not allowed to delete an Affiliate Campaign.</Warning>
