---
title: "Query events"
method: POST
path: "/events/query"
tags: ["Events"]
---

# Query events

`POST /events/query`

## Request

- Base URL: `https://api.loopify.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.loopify.com/events/query`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://auth.loopify.com/connect/authorize`, token URL `https://auth.loopify.com/token`, scopes: `ContactDataManagement`, `ReadContacts`)

#### Auth policies: ContactDataManagement,ReadContacts 

  ### Request
 Uses the Search API (https://www.elastic.co/guide/en/elasticsearch/reference/5.5/search.html)
 
 Request playload must be in Elasticsearch Query DSL (https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl.html)
 
 At minimum it must include a query.bool.must array clause:
 
     {
         "query": {
             "bool": {
                 "must": [{
                     "match": { 
                         "type": "11"
                     }
                 }]
             }
         }
     }
 
 ### EventTypes
 
| EventType                   | type     | EventType                 | type     | EventType              | type     | EventType              | type     |
| --------------------------- |:--------:| ------------------------  |:--------:| ---------------------- |:--------:| ---------------------- |:--------:|
| EmailSent                   | 5        | SMSSent                   | 13       | PageClick              | 25       | FlowBlockExecuted      | 18       |
| EmailSoftBounced            | 6        | SMSFailed                 | 14       | SMSIncoming            | 12       | FlowBlockExecutedTrue  | 19       |
| EmailHardBounced            | 7        | SMSUnsubscribed           | 15       | ReportSent             | 32       | FlowBlockExecutedFalse | 20       |
| EmailComplained             | 8        | SMSLinkClicked            | 16       | ContactImportStarted   | 1        | FlowBlockExecutedDone  | 21       |
| EmailUnsubscribed           | 9        | SMSPreviouslyUnsubscribed | 34       | ContactImportInProgress| 2        | FlowBlockExecutedError | 22       |
| EmailOpened                 | 10       | PrintSent                 | 31       | ContactImportFinalized | 3        | SplitBlockExecuted     | 26       |
| EmailLinkClicked            | 11       | PageFormSubmit            | 23       | ContactImportCanceled  | 4        | FlowJobCreated         | 27       |
| EmailFailed                 | 28       | PageVisit                 | 24       | SMSIncoming            | 12       | SplitTestBlockExecuted | 29       |
| EmailPreviouslyUnsubscribed | 33       | PrintQRCodeScanned        | 17       | PrintFailed            | 35       | FlowActivated          | 30       |
| EmailSuppressed             | 36       | SMSSuppressed             | 37       | CouponRedeemed         | 38       | FlowTestActivated      | 39       |
| FlowFrozen                  | 40       | FlowUnfrozen              | 41       | FlowStopped            | 42       | WebhookSucceeded       | 43       |
| PopupFormSubmit             | 44       |                           |          |                        |          |                        |          |
 ### Response example
 
     {
         "took": 26,
         "timed_out": false,
         "_shards": {
             "total": 1,
             "successful": 1,
             "failed": 0
          },
          "hits": {
               "total": 1,
                "max_score": 3.57346,
                "hits": [
                {
                    "_index": "events",
                    "_type": "eventelastic",
                    "_id": "AWC3DTu8Ebxu-FvCbf8Y",
                    "_score": 3.57346,
                    "_source": {
                        "accountId": 2,
                        "userId": 0,
                        "source": "mailgun-click",
                        "stamp": "2018-01-02T13:26:25.9740794Z",
                        "type": 11,
                        "data": {
                            "campaignId": "5a4b8848a122e5000516dbb0",
                            "externalMessageId": "20180102132544.1.E4E7834568022EA5BD@loopify.com",
                            "contactId": "59e49f7c5234534673746789584466d",
                            "email": "some@email.com",
                            "recipientData": {
                                "country": "MK",
                                "region": "38",
                                "city": "Skopje",
                                "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36",
                                "deviceType": "desktop",
                                "clientType": "browser",
                                "clientName": "Chrome",
                                "clientOS": "Windows"
                            }
                         }
                    }
                }]
          }
     }

## Query parameters

- `collectionName` string

## Request body

- unknown

## Response `200`

Success

- unknown

## Other responses

- `400`: 0: Query is missing a query.bool.must array
- `401`: Unauthorized
- `403`: Forbidden

---

[API](https://skmtc.dev/loopify/apis/web-api-loopify.md) · [All operations](https://skmtc.dev/loopify/apis/web-api-loopify/llms.txt) · [OpenAPI document](https://skmtc.dev/loopify/apis/web-api-loopify/revisions/68c51b11a24b?raw)
