---
description: >-
  Campaign Memberships handle the relationship between subscribers and referral
  programs. For example, to add a subscriber to a referral program you must
  create a Campaign Membership relationship.
---

# Campaign Memberships

## Create a campaign membership

<mark style="color:green;">`POST`</mark> `https://api.sparkloop.app/v2/campaigns/:identifier/campaign_memberships`

Use to endpoint to add a subscriber to a referral program

#### Path Parameters

| Name                                          | Type   | Description                                |
| --------------------------------------------- | ------ | ------------------------------------------ |
| :identifier<mark style="color:red;">\*</mark> | String | Referral campaign UUID, e.g. MF9a78983d1c. |

#### Request Body

| Name                                               | Type   | Description                        |
| -------------------------------------------------- | ------ | ---------------------------------- |
| subscriber\_uuid<mark style="color:red;">\*</mark> | string | Subscriber's UUID or email address |

{% tabs %}
{% tab title="201: Created " %}
```json
{
    "campaign_membership": {
        "uuid": "membership_0cf7ec1e76d1",
        "campaign_uuid": "MF3c31fb034e",
        "subscriber_uuid": "sub_509eafef8d9d",
        "created_at": "2022-12-19T14:45:30.593Z"
    }
}
```
{% endtab %}

{% tab title="400 " %}
{% tabs %}
{% tab title="Campaign Membership already present" %}
```
{
    "error": "manuel@sparkloop.app has already been added to this campaign"
}
```
{% endtab %}

{% tab title="Subscriber not found" %}
```
{
    "error": "manuel@sparkloop not found!"
}
```
{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

## Delete a campaign membership.

<mark style="color:red;">`DELETE`</mark> `https://api.sparkloop.app/v2/campaigns/:identifier/campaign_memberships/:uuid`

Use this endpoint to remove a subscriber from a campaign.

#### Path Parameters

| Name                                          | Type   | Description                                                                  |
| --------------------------------------------- | ------ | ---------------------------------------------------------------------------- |
| :identifier<mark style="color:red;">\*</mark> | string | Subscriber's Referral campaign UUID, e.g. MF9a78983d1c.UUID or email address |
| :uuid<mark style="color:red;">\*</mark>       | String | Membership's UUID.                                                           |

{% tabs %}
{% tab title="200 " %}
```
{
    "message": "Successfully deleted membership membership_34c8e39cf4"
}
```
{% endtab %}

{% tab title="400 " %}
```
{
    "error": "Failed to delete membership_34c8e39cf4"
}
```
{% endtab %}

{% tab title="404 " %}
{% tabs %}
{% tab title="Subscriber not found" %}
```
{
    "error": "Membership membership_34c8e39cf4 not found!"
}
```
{% endtab %}

{% tab title="Campaign not found" %}
```
{
    "error": "Campaign MF9a7d8983d1c not found!"
}
```
{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}
