« Back to Documentation Overview

add_campaign

Section: Campaigns
Version: 1.5.0


Add campaign to account.

Conditions

  • `name` (mandatory) – Value of name must be composed of lowercase letters, digits and underscores only.
  • `description` (optional) – User friendly name of campaign.
  • `from_field` (mandatory) – `FROM_FIELD_ID` obtained from get_account_from_fields. It is default From header (name and email) in messages sent from this campaign.
  • `reply_to_field` (mandatory) – `FROM_FIELD_ID` obtained from get_account_from_fields.
  • `confirmation_subject` (mandatory) – `CONFIRMATION_SUBJECT_ID` obtained from get_confirmation_subjects. Used in confirmation messages sent from this campaign if double-optin is set for given subscription method.
  • `confirmation_body` (mandatory) – `CONFIRMATION_BODY_ID` obtained from get_confirmation_bodies. Used in confirmation messages sent from this campaign if double-optin is set for given subscription method.
  • `language_code` (optional) – Language of subscription reminder and change details / unsubscribe footer. List of available ISO 639-1 (2-letter) codes is available here: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes. If we don’t have version in requested language then English version will be used.

Warning: Account has limit of 500 campaigns.

Warning: Campaign added through API will be visible on web interface after next log-in.


Parameters
stringAPI_KEY
object
stringnamemy_new_campaign
stringdescriptionMy new campaign
stringfrom_fieldFROM_FIELD_ID
stringreply_to_fieldFROM_FIELD_ID
stringconfirmation_subjectCONFIRMATION_SUBJECT_ID
stringconfirmation_bodyCONFIRMATION_BODY_ID
stringlanguage_codePL
Return Value
stringCAMPAIGN_IDabc123
integeradded1

Example Request JSON

[
    "API_KEY",
    {
        "name": "my_new_campaign",
        "description": "My new campaign",
        "from_field": "FROM_FIELD_ID",
        "reply_to_field": "FROM_FIELD_ID",
        "confirmation_subject": "CONFIRMATION_SUBJECT_ID",
        "confirmation_body": "CONFIRMATION_BODY_ID",
        "language_code": "PL"
    }
]

Example Response JSON

{
    "CAMPAIGN_ID": "abc123",
    "added": 1
}

Example Error Response JSON

{
    "code": -1,
    "message": "Invalid language code"
}
Method-specific Errors
Total limit of campaigns exceeded
Invalid email syntax
Name already taken
Missing From field
Missing Reply-To field
Missing confirmation subject
Missing confirmation body
Invalid language code
API-wide Errors
API key verification failed API key verification failed
API client IP not allowed API client IP not allowed
Invalid params Attribute params must be reference to hash