Email - Listing and Searching Emails

Groundhogg provides direct access to your emails using  /emails/ endpoints. Using Email endpoint you can search string within your email, fetch specific email using email_id or you can get a list of all the emails. To list all the emails, you need to make a GET HTTP request to Groundhoggs email API. The following URL helps you to fetch all the emails from your Groundhogg install.

http://yoursite.com/wp-json/gh/v3/emails<br>

You will receive the following response from the request.

{
    "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"
        }
    ]
}
<br>

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<br>
{
    "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 requests. It will return the select2 format of a list.

http://yoursite.com/wp-json/gh/v3/emails?select2=true<br>
{
    "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
}
<br>

Searching emails

You can search for a specific keyword by adding “search” or “q” arguments while making a request. it returns a list of email which contains keyword from the query string.

http://yoursite.com/wp-json/gh/v3/emails?q=hype<br>
{
    "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"
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us