# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sparkloop.app/api-v2/endpoints/campaigns/subscribers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
