• iOS
  • Android
  • Windows
  • Cordova
  • Web
  • Unity
  • Adobe Air
  • Dashboard
  • API
  • Guides
  • FAQ
  • API > Campaigns API

    GET - View campaign

    The get endpoint allows you to get details about a campaign 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 is an example of a valid CURL CLI request syntax:

    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/CAMPAIGN_TOKEN"
    

    Note: Only LIVE API Keys are supported by this API

    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.

    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, except that the four following fields are added :

    IdDescription
    campaign_tokenString -
    The token number of the campaign.
    from_apiBoolean -
    Value that indicates whether or not the campaign were created with the API. `false` value means the campaign were created with the dashboard.
    dev_onlyBoolean -
    Value that indicates whether or not the campaign only targets developers.
    created_dateString -
    Creation date of the campaign.

    Here is an example of output :

    {
        "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)
    • ROUTE_NOT_FOUND (Http status code: 404, Error code: 20)
    • SERVER_ERROR (Http status code: 500, Error code: 0)