Fetch Emails

GET method used to get a list of emails from Groundhogg. Users can retrieve all available emails by making a GET request to the following URL. make sure you added require header parameters before making a request.

http://yoursite.com/wp-json/gh/v3/emails
{
    "emails": [
        {
            "ID": "9",
            "content": "    <div class=\"row\" style=\"\"> HTML CODE  </div>\r\n",
            "subject": "Excitement Generator",
            "pre_header": "",
            "from_user": "1",
            "author": "1",
            "status": "draft",
            "last_updated": "2019-03-22 16:46:34",
            "date_created": "2019-03-22 16:46:34",
            "is_template": "0"
        },
        {
            "ID": "8",
             "content": "    <div class=\"row\" style=\"\"> HTML CODE  </div>\r\n",
            "subject": "Email Preferences Changed",
            "pre_header": "",
            "from_user": "3",
            "author": "1",
            "status": "draft",
            "last_updated": "2019-03-22 15:55:23",
            "date_created": "2019-03-22 10:32:39",
            "is_template": "0"
        }
    ]
}

Searching emails

You can search for a specific keyword by adding “search” or “q” arguments while making a request. it returns an output which contains that query string.

http://yoursite.com/wp-json/gh/v3/emails?q=hype
{
    "emails": [
        {
            "ID": "9",
           "content": "    <div class=\"row\" style=\"\"> HTML CODE with the key word HYPE  </div>\r\n",
            "subject": "Excitement Generator",
            "pre_header": "",
            "from_user": "1",
            "author": "1",
            "status": "draft",
            "last_updated": "2019-03-22 16:46:34",
            "date_created": "2019-03-22 16:46:34",
            "is_template": "0"
        }
    ],
    "status": "success"
}

List of emails for select

Users can easily bound all the available email list in dropdown by setting select parameter true. It will return a list of email id and email subject.

http://yoursite.com/wp-json/gh/v3/emails?select=true
{
    "emails": {
        "1": "Email Preferences Changed",        
        "3": "Build your Dreams With Groundhogg!",       
        "5": "Payment Card Updated",
        "9": "Excitement Generator"
    },
    "status": "success"
}

List of emails for select2

Users can also bound emails list inside a select-2 drop down by setting select2=true while making GET request. It will return the select2 format of a list.

http://yoursite.com/wp-json/gh/v3/emails?select2=true
{
    "results": [
        {
            "id": "9",
            "text": "Excitement Generator (draft)"
        },       
        {
            "id": "5",
            "text": "Payment Card Updated (draft)"
        },       
        {
            "id": "3",
            "text": "Build your Dreams With Groundhogg! (draft)"
        },       
        {
            "id": "1",
            "text": "Email Preferences Changed (draft)"
        }
    ],
    "more": false
}

Was this article helpful to you? Yes No

How can we help?