# Campaigns

## Get Campaigns

<mark style="color:blue;">`GET`</mark> `https://api.sparkloop.app/v1/campaigns`

Returns all of your campaigns. At the moment you're only allowed to have one campaign per Sparkloop account.

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-Api-Key<mark style="color:red;">\*</mark> | string | API key     |

{% tabs %}
{% tab title="200 Campaigns successfully retrieved." %}

```json
{ 
  "campaigns": [
    { 
      "uuid": "MF9a78983d1c",
      "name": "My cool newsletter"
    }
  ]
}
```

{% endtab %}

{% tab title="401 " %}
{% tabs %}
{% tab title="Missing API key" %}

```
{ "error": "API key is missing!" }
```

{% endtab %}

{% tab title="User not found for API key" %}

```
{ "error": "User not found!" }
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

## Get Campaign

<mark style="color:blue;">`GET`</mark> `https://api.sparkloop.app/v1/campaigns/:uuid`

Returns a campaign.

#### Path Parameters

| Name                                   | Type   | Description                               |
| -------------------------------------- | ------ | ----------------------------------------- |
| uuid<mark style="color:red;">\*</mark> | string | Campaign's UUID, for example MF9a78983d1c |

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-Api-Key<mark style="color:red;">\*</mark> | string | API key     |

{% tabs %}
{% tab title="200 " %}

```json
{ 
  "campaign": { 
    "uuid": "MF9a78983d1c",
    "name": "My cool newsletter"
  }
}
```

{% endtab %}

{% tab title="401 " %}
{% tabs %}
{% tab title="Missing API key" %}

```
{ "error": "API key is missing!" }
```

{% endtab %}

{% tab title="User not found for API key" %}

```
{ "error": "User not found!" }
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="404 " %}

```
{ "error": "Campaign MF9a78983d1c not found!"}
```

{% endtab %}
{% endtabs %}

## Update Campaign

<mark style="color:orange;">`PUT`</mark> `https://api.sparkloop.app/v1/campaigns/:uuid`

Updates the campaign

#### Path Parameters

| Name                                   | Type   | Description                               |
| -------------------------------------- | ------ | ----------------------------------------- |
| uuid<mark style="color:red;">\*</mark> | string | Campaign's UUID, for example MF9a78983d1c |

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-Api-Key<mark style="color:red;">\*</mark> | string | API key     |

#### Request Body

| Name | Type   | Description     |
| ---- | ------ | --------------- |
| name | string | Campaign's name |

{% tabs %}
{% tab title="200 " %}

```json
{
  "campaign": {
    "uuid": "MF9a78983d1c",
    "name": "Even better campaign name!"
  }
}
```

{% endtab %}

{% tab title="401 " %}
{% tabs %}
{% tab title="Missing API key" %}

```
{ "error": "API key is missing!" }
```

{% endtab %}

{% tab title="User not found for API key" %}

```
{ "error": "User not found!" }
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="404 " %}

```
{ "error": "Campaign MF9a78983d1c not found!"}
```

{% 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-1/campaigns.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.
