# GET - List campaigns

The list endpoint allows you to get a list of your push campaigns and push automations.

### Request structure

#### Route

The campaigns API exposes a GET endpoint at: `https://api.batch.com/1.1/BATCH_API_KEY/campaigns/list`

Here are examples of valid cURL, PHP or Python requests syntax:

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

```bash
curl -X GET "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/list" \
-H "Content-Type: application/json" \
-H "X-Authorization: BATCH_REST_API_KEY"
```

{% endtab %}

{% tab title="PHP" %}

```php
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/list", [
	"headers" => [
		"Content-Type" => "application/json",
		"X-Authorization" => "BATCH_REST_API_KEY"
	]
]);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests, json
response = requests.request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/campaigns/list",
	headers={
		'Content-Type': 'application/json'
		'X-Authorization': 'BATCH_REST_API_KEY'
	}
)
```

{% endtab %}
{% endtabs %}

The `BATCH_API_KEY` value is your **Live** Batch API key from the settings page of your app within the dashboard *(Settings → General)*.

#### Get parameters

<table><thead><tr><th width="187">Id</th><th>Description</th></tr></thead><tbody><tr><td><code>from</code></td><td><strong>Integer</strong> - <em>Optional, Default : 0</em><br>Value used for pagination : it indicates the offset of the first campaign to be returned. Campaigns are ordered by creation date (from the most recent to the oldest).<br><em>E.g.</em><code>"/campaigns/list?from=10"</code></td></tr><tr><td><code>limit</code></td><td><strong>Integer</strong> - <em>Optional, Default : 10, Max : 100</em><br>Value that indicates the number of campaigns to be returned per API call.<br><em>E.g.</em><code>"/campaigns/list?limit=20"</code></td></tr><tr><td><code>live</code></td><td><strong>Boolean</strong> - <em>Optional</em><br>Allows to filter according to the campaign LIVE state. `true` will only return running or completed campaigns, whereas `false` will only return stopped and draft campaigns.<br><em>E.g.</em><code>"/campaigns/list?live=true"</code></td></tr><tr><td><code>from_api</code></td><td><strong>Boolean</strong> - <em>Optional</em><br>Allows to filter according to the way that campaigns have been created. `true` will only return campaigns created with the API. `false` value will only return campaigns created from the dashboard. If you want all campaigns, omit this parameter.<br><em>E.g.</em><code>"/campaigns/list?from_api=false"</code></td></tr></tbody></table>

Here is an example of a valid cURL CLI request, which would return 5 live (running or completed) campaigns created from the api, starting from the 10th campaign :

```
curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET
"https://api.batch.com/1.1/BATCH_API_KEY/campaigns/list?from=10&limit=5&live=true&from_api=true"
```

#### Headers

In order to authenticate with the API, you need to provide your **company REST API Key** as the value of the `X-Authorization` header. You can find it in ⚙ Settings → General.

### Responses

#### Success

If the GET to the API endpoint is successful you will receive an HTTP 200 confirmation and information on your campaigns. The endpoint only returns basic information about campaigns. If you need more information about a campaign, use the [GET](/developer/api/mep/campaigns/get-campaign.md) endpoint using the `campaign_token`.

```json
[
  {
    "campaign_token": "a0082dc6860938a26280bd3ba927303b",
    "from_api": false,
    "dev_only": false,
    "created_date": "2017-03-02T09:43:17",
    "name": "Test Campaign 1",
    "live": true,
    "push_time": "2017-07-06T14:09:18"
  },
  {
    "campaign_token": "a0082dc6860938a26280bd3ba927303a",
    "from_api": false,
    "dev_only": true,
    "created_date": "2017-03-02T09:43:17",
    "name": "Test Campaign 2",
    "live": false,
    "deeplink": "deeplink",
    "custom_payload": "{\"foo\" : \"bar\"}",
    "local_push_time": "2017-03-03T13:10:19",
    "recurrence": {
      "end_date": "2017-07-22T23:59:59",
      "repeat_unit": "WEEKLY",
      "repeat_frequency": 2
    },
    "query": {
      "$or": [
        {
          "isNear(45.7583907,4.8347867,30km)": true
        },
        {
          "countForLabel(e.label_data, 'example')": 0
        }
      ]
    },
    "capping": 2
  },
  {
    "campaign_token": "a0082dc6860938a26280bd3ba927302f",
    "from_api": false,
    "dev_only": false,
    "created_date": "2020-03-02T09:45:17",
    "name": "Test Trigger Automation 1",
    "live": true,
    "push_time": "2020-07-06T14:09:18",
    "trigger": {}
  }
]
```

#### Failure

If the GET data does not meet the API requirements you will receive an actionable error message. Contact us at <support@batch.com> if you need further support.

* `MALFORMED_PARAMETER` (Http status code: 400, Error code: 31)
* `AUTHENTICATION_INVALID` (Http status code: 401, Error code: 10)
* `API_MISUSE` (Http status code: 403, Error code: 12)
* `ROUTE_NOT_FOUND` (Http status code: 404, Error code: 20)
* `SERVER_ERROR` (Http status code: 500, Error code: 0)
* `TOO_MANY_REQUESTS` (Http status code: 429, Error code: 60) If you get a "too many requests" response, please wait for at least 5 seconds before trying again. Further requests might still return this error.


---

# 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://doc.batch.com/developer/api/mep/campaigns/list.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.
