> ## Documentation Index
> Fetch the complete documentation index at: https://docs.invoca.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Affiliate Campaigns

export const MethodTag = ({method = "GET", path, label, colors = {}}) => {
  const presets = {
    get: {
      label: "GET",
      light: {
        bg: "#DCFCE7",
        text: "#15803D"
      },
      dark: {
        bg: "rgba(34,197,94,0.16)",
        text: "#4ADE80"
      }
    },
    post: {
      label: "POST",
      light: {
        bg: "#DBEAFE",
        text: "#1D4ED8"
      },
      dark: {
        bg: "rgba(59,130,246,0.16)",
        text: "#60A5FA"
      }
    },
    put: {
      label: "PUT",
      light: {
        bg: "#FEF3C7",
        text: "#B45309"
      },
      dark: {
        bg: "rgba(245,158,11,0.16)",
        text: "#FBBF24"
      }
    },
    patch: {
      label: "PATCH",
      light: {
        bg: "#F3E8FF",
        text: "#7E22CE"
      },
      dark: {
        bg: "rgba(168,85,247,0.16)",
        text: "#C084FC"
      }
    },
    delete: {
      label: "DEL",
      light: {
        bg: "#FEE2E2",
        text: "#B91C1C"
      },
      dark: {
        bg: "rgba(239,68,68,0.16)",
        text: "#F87171"
      }
    }
  };
  const fallback = {
    label: String(method).toUpperCase(),
    light: {
      bg: "#F3F4F6",
      text: "#374151"
    },
    dark: {
      bg: "rgba(156,163,175,0.16)",
      text: "#D1D5DB"
    }
  };
  const preset = presets[String(method).toLowerCase()] || fallback;
  const light = {
    ...preset.light,
    ...colors.light || ({})
  };
  const dark = {
    ...preset.dark,
    ...colors.dark || ({})
  };
  const css = `
    .invoca-method-tag {
      display: inline-block;
      padding: 1px 8px;
      margin-right: 8px;
      border-radius: 8px;
      font-size: 10px;
      line-height: 18px;
      font-weight: 700;
      letter-spacing: 0.4px;
      text-transform: uppercase;
      vertical-align: middle;
      background: var(--imt-bg);
      color: var(--imt-fg);
    }
    .invoca-method-path {
      font-size: 13px;
    }
    [data-component-part="accordion-icon"]:has(.invoca-method-tag) {
      width: auto;
      height: auto;
      flex-shrink: 0;
    }
    [data-component-part="accordion-icon"] .invoca-method-tag {
      margin-right: 0;
    }
    [data-component-part="accordion-button"]:has(.invoca-method-tag) {
      flex-wrap: wrap;
      row-gap: 6px;
    }
    [data-component-part="accordion-button"]:has(.invoca-method-tag) [data-component-part="accordion-icon"] {
      flex: 1 1 0;
      min-width: 0;
      overflow-wrap: anywhere;
    }
    [data-component-part="accordion-button"]:has(.invoca-method-tag) [data-component-part="accordion-title-container"] {
      flex: 0 0 calc(100% - 8px);
      padding-left: 20px;
    }
    [data-component-part="accordion-button"]:has(.invoca-method-tag) [data-component-part="accordion-title"] {
      font-size: 12px;
    }
    .dark .invoca-method-tag,
    [data-theme="dark"] .invoca-method-tag {
      background: var(--imt-bg-dark);
      color: var(--imt-fg-dark);
    }
  `;
  const vars = {
    "--imt-bg": light.bg,
    "--imt-fg": light.text,
    "--imt-bg-dark": dark.bg,
    "--imt-fg-dark": dark.text
  };
  return <span>
      <style>{css}</style>
      <span className="invoca-method-tag" style={vars}>
        {label || preset.label}
      </span>
      {path ? <code className="invoca-method-path">{path}</code> : null}
    </span>;
};

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

Relationship properties are shown below

<table className="parameters docutils align-default"><thead><tr className="row-odd"><th className="head"><p>Property</p></th><th className="head"><p>Type</p></th><th className="head"><p>Value</p></th></tr></thead><tbody><tr className="row-even"><td><p>affiliate\_id\_from\_network</p></td><td><p>string (read only)</p></td><td><p>Network specific id of the affiliate.</p></td></tr><tr className="row-odd"><td><p>status</p></td><td><p>string (read and write)</p></td><td><p>One of: Applied, Approved, Suspended, Declined.</p></td></tr><tr className="row-even"><td><p>id</p></td><td><p>integer (read-only)</p></td><td><p>The internal Invoca id of the affiliate campaign.</p></td></tr><tr className="row-odd"><td><p>id\_from\_network</p></td><td><p>string (read and write)</p></td><td><p>Network specific id of the affiliate campaign.</p></td></tr><tr className="row-even"><td><p>max\_promo\_numbers</p></td><td><p>integer (read only)</p></td><td><p>Promo number limit.</p></td></tr><tr className="row-odd"><td><p>object\_url</p></td><td><p>string (read-only)</p></td><td><p>URL for reaching the affiliate campaign in the UI.</p></td></tr><tr className="row-even"><td><p>current\_terms</p></td><td><p>(read only)</p></td><td /></tr><tr className="row-odd"><td><p><strong>advertiser\_payin</strong></p></td><td /><td /></tr><tr className="row-even"><td><p>max</p></td><td><p>decimal</p></td><td><p>Maximum payin amount (base + bonuses).</p></td></tr><tr className="row-odd"><td><p>min</p></td><td><p>decimal</p></td><td><p>Minimum payin amount (base).</p></td></tr><tr className="row-even"><td><p>pricing</p></td><td><p>string</p></td><td><p>Human‐friendly representation of the payin pricing (eg. “$5.07 per call”).</p></td></tr><tr className="row-odd"><td><p>currency</p></td><td><p>string</p></td><td><p>USD, GBP, EUR.</p></td></tr><tr className="row-even"><td><p>range</p></td><td><p>string</p></td><td><p>Formatted string including min and max payin values.</p></td></tr><tr className="row-odd"><td><p><strong>policies</strong></p></td><td></td><td></td></tr><tr className="row-even"><td><p>amount</p></td><td><p>decimal</p></td><td><p>Payin policy amount.</p></td></tr><tr className="row-odd"><td><p>currency</p></td><td><p>string</p></td><td><p>USD, GBP, EUR.</p></td></tr><tr className="row-even"><td><p>type</p></td><td><p>string</p></td><td><p>Base, Bonus.</p></td></tr><tr className="row-odd"><td><p>condition</p></td><td><p>string</p></td><td><p>Condition options used to determine the base or bonus payout (eg. “duration &gt;= 1 min 30 sec”).</p></td></tr><tr className="row-even"><td><p>pricing_type</p></td><td><p>string</p></td><td><p>Fixed, OverallMargin, IndividualMargin.</p></td></tr><tr className="row-odd"><td><p>ivr_tree</p></td><td><p>hash</p></td><td><p>Interactive Voice Response tree.</p></td></tr><tr className="row-even"><td><p><strong>affiliate_payout</strong></p></td><td></td><td></td></tr><tr className="row-odd"><td><p>max</p></td><td><p>decimal</p></td><td><p>Maximum payout amount (base + bonuses).</p></td></tr><tr className="row-even"><td><p>min</p></td><td><p>decimal</p></td><td><p>Minimum payout amount (base).</p></td></tr><tr className="row-odd"><td><p>pricing</p></td><td><p>string</p></td><td><p>Human‐friendly representation of the payout pricing (eg. “$5.07 per call”).</p></td></tr><tr className="row-even"><td><p>currency</p></td><td><p>string</p></td><td><p>USD, GBP, EUR.</p></td></tr><tr className="row-odd"><td><p>range</p></td><td><p>string</p></td><td><p>Formatted string including min and max payin values policies.</p></td></tr><tr className="row-even"><td><p><strong>policies</strong></p></td><td /><td /></tr><tr className="row-odd"><td><p>amount</p></td><td><p>decimal</p></td><td><p>Payout policy amount.</p></td></tr><tr className="row-even"><td><p>currency</p></td><td><p>string</p></td><td><p>USD, GBP, EUR.</p></td></tr><tr className="row-odd"><td><p>type</p></td><td><p>string</p></td><td><p>Base, Bonus.</p></td></tr><tr className="row-even"><td><p>condition</p></td><td><p>string</p></td><td><p>Condition options used to determine the base or bonus payout (eg. “duration >= 1 min 30 sec”).</p></td></tr></tbody></table>

## 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/2019-05-01/<network_id>/advertisers/<advertiser_id_from_network>/advertiser_campaigns/<advertiser_campaign_id_from_network>/affiliates/<affiliate_id_from_network>/affiliate_campaigns.json`

<AccordionGroup>
  <Accordion title="Get all Affiliate Campaigns" icon={<MethodTag method="get" path="/affiliate_campaigns"/>}>
    #### Examples

    Get all Affiliate Campaigns

    Endpoint:

    `https://invoca.net/api/2019-05-01/<network_id>/advertisers/<advertiser_id_from_network>/advertiser_campaigns/<advertiser_campaign_id_from_network>/affiliate_campaigns.json`
  </Accordion>

  <Accordion title="Get an Affiliate Campaign" icon={<MethodTag method="get" path="/affiliates/<affiliate_id>/affiliate_campaigns"/>}>
    #### Examples

    GET of Affiliate Campaign status for Advertiser 354 Campaign 12 to Affiliate 976

    Endpoint:

    `https://invoca.net/api/2019-05-01/<network_id>/advertisers/354/advertiser_campaigns/12/affiliates/976/affiliate_campaigns.json`

    Format: application/json

    Response Body:

    ```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"
      }
    }
    ```
  </Accordion>

  <Accordion title="Create an Affiliate Campaign" icon={<MethodTag method="post" path="/affiliates/<affiliate_id>/affiliate_campaigns"/>}>
    #### Examples

    Create Affiliate Campaign with status for Advertiser 354 Campaign 12 to Affiliate 975

    Please 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”.

    Endpoint:

    `https://invoca.net/api/2019-05-01/<network_id>/advertisers/354/advertiser_campaigns/12/affiliates/975/affiliate_campaigns.json`

    Format: application/json

    Request Body:

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

    Response Body:

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

    ***

    Not Found - 404

    Endpoint:

    `https://invoca.net/api/api/2019-05-01/<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"
    }
    ```
  </Accordion>

  <Accordion title="Update an Affiliate Campaign" icon={<MethodTag method="put" path="/affiliates/<affiliate_id>/affiliate_campaigns"/>}>
    #### Examples

    Update Affiliate Campaign status for Advertiser 354 Campaign 12 to Affiliate 976

    Endpoint:

    `https://invoca.net/api/2019-05-01/<network_id>/advertisers/354/advertiser_campaigns/12/affiliates/976/affiliate_campaigns.json`

    Format: application/json

    Request Body:

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

    Response Body:

    Same as a GET response, includes all the affiliate campaign properties.
  </Accordion>

  <Accordion title="Delete an Affiliate Campaign" icon={<MethodTag method="delete" path="/affiliates/<affiliate_id>/affiliate_campaigns"/>}>
    #### Examples

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