# GET - View campaign

The get endpoint allows you to get details about a campaign or push automation using its unique token.

### Request structure

#### Route

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

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/CAMPAIGN_TOKEN" \
-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/CAMPAIGN_TOKEN", [
	"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/CAMPAIGN_TOKEN",
	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)*. Only LIVE API Keys are supported by this API.

The `CAMPAIGN_TOKEN` value is the token you receive when you [successfully create](/developer/api/mep/campaigns/create.md) a push campaign using the API.

> Please note Batch manages each platform separately. You will have to call the API twice with a different API key if you want to target iOS and Android.

#### 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 successfull you will receive an HTTP 200 confirmation and details about your campaign.

The output format is the same than the one used to [create a campaign](/developer/api/mep/campaigns/create.md), except that the four following fields are added :

<table><thead><tr><th width="232.5">Id</th><th>Description</th></tr></thead><tbody><tr><td><code>campaign_token</code></td><td><strong>String</strong> -<br>The token number of the campaign or automation.</td></tr><tr><td><code>from_api</code></td><td><strong>Boolean</strong> -<br>Value that indicates whether or not the campaign were created with the API. `false` value means the campaign were created with the dashboard.</td></tr><tr><td><code>dev_only</code></td><td><strong>Boolean</strong> -<br>Value that indicates whether or not the campaign only targets developers.</td></tr><tr><td><code>created_date</code></td><td><strong>String</strong> -<br>Creation date of the campaign.</td></tr><tr><td><code>trigger</code></td><td><strong>Object</strong> - <em>Optional</em><br>On trigger automations, will be an empty object. Use this to identify automations. Getting the detailed trigger information is not supported.</td></tr></tbody></table>

Here is an example of output :

```json
{
  "campaign_token": "a0082dc6860938a26280bd3ba927303b",
  "from_api": false,
  "dev_only": true,
  "created_date": "2017-07-05T15:11:33",
  "name": "Test campaign",
  "live": true,
  "push_time": "2017-07-05T13:32:30",
  "gcm_collapse_key": "default",
  "targeting": {
    "segments": ["NEW", "ENGAGED", "ONE_TIME"]
  },
  "messages": [
    {
      "language": "en",
      "title": "Hello!",
      "body": "How's it going?"
    }
  ]
}
```

#### 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.

* `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/get-campaign.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.
