# Get Surveys Submissions

GET https://services.leadconnectorhq.com/surveys/submissions

Get Surveys Submissions

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `surveys.readonly`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes |  |
| `page` | number | No | Page No. By default it will be 1 |
| `limit` | number | No | Limit Per Page records count. will allow maximum up to 100 and default will be 20 |
| `surveyId` | string | No | Filter submission by survey id |
| `q` | string | No | Filter by contactId, name, email or phone no. |
| `startAt` | string | No | Get submission by starting of this date. By default it will be same date of last month(YYYY-MM-DD). |
| `endAt` | string | No | Get submission by ending of this date. By default it will be current date(YYYY-MM-DD). |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/surveys/submissions": {
      "get": {
        "summary": "Get Surveys Submissions",
        "operationId": "getSurveysSubmissions",
        "description": "Get Surveys Submissions",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "example": "ve9EPM428h8vShlRW1KT",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "example": 1,
            "description": "Page No. By default it will be 1",
            "schema": {
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "example": 20,
            "description": "Limit Per Page records count. will allow maximum up to 100 and default will be 20",
            "schema": {
              "default": 20,
              "type": "number"
            }
          },
          {
            "name": "surveyId",
            "required": false,
            "in": "query",
            "example": "jjusM6EOngDExnbo2DbU",
            "description": "Filter submission by survey id",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "required": false,
            "in": "query",
            "example": "john@deo.com",
            "description": "Filter by contactId, name, email or phone no.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "startAt",
            "required": false,
            "in": "query",
            "example": "2020-11-14",
            "description": "Get submission by starting of this date. By default it will be same date of last month(YYYY-MM-DD).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endAt",
            "required": false,
            "in": "query",
            "example": "2020-12-14",
            "description": "Get submission by ending of this date. By default it will be current date(YYYY-MM-DD).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetSurveysSubmissionSuccessfulResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "surveys.readonly"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "GetSurveysSubmissionSuccessfulResponseDto": {
        "type": "object",
        "properties": {
          "submissions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "be759b9a-c3ec-4b29-ba07-fc3c89c77673"
                },
                "contactId": {
                  "type": "string",
                  "example": "9NkT25Vor1v4aQatFsv2"
                },
                "createdAt": {
                  "type": "string",
                  "example": "2020-11-01T18:02:21.000Z"
                },
                "surveyId": {
                  "type": "string",
                  "example": "jjusM6EOngDExnbo2DbU"
                },
                "name": {
                  "type": "string",
                  "example": "test"
                },
                "email": {
                  "type": "string",
                  "example": "test@test.com"
                },
                "others": {
                  "type": "object",
                  "properties": {
                    "__submissions_other_field__": {
                      "type": "string",
                      "example": "john@deo.com"
                    },
                    "__custom_field_id__": {
                      "type": "string",
                      "example": "20"
                    },
                    "eventData": {
                      "type": "object",
                      "properties": {
                        "fbc": {
                          "type": "string",
                          "example": "fb.1.123456789.987654321"
                        },
                        "fbp": {
                          "type": "string",
                          "example": "fbp.1.987654321.123456789"
                        },
                        "page": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "example": "https://example.com"
                            },
                            "title": {
                              "type": "string",
                              "example": "Example Page"
                            }
                          },
                          "title": "PageDetailsSchema"
                        },
                        "type": {
                          "type": "string",
                          "example": "page-visit"
                        },
                        "domain": {
                          "type": "string",
                          "example": "example.com"
                        },
                        "medium": {
                          "type": "string",
                          "example": "survey"
                        },
                        "source": {
                          "type": "string",
                          "example": "Direct traffic"
                        },
                        "version": {
                          "type": "string",
                          "example": "v3"
                        },
                        "adSource": {
                          "type": "string",
                          "example": "example-ad-source"
                        },
                        "mediumId": {
                          "type": "string",
                          "example": "medium-id-123"
                        },
                        "parentId": {
                          "type": "string",
                          "example": "parent-id-456"
                        },
                        "referrer": {
                          "type": "string",
                          "example": "https://staging.gohighlevel.com"
                        },
                        "fbEventId": {
                          "type": "string",
                          "example": "event-id-789"
                        },
                        "timestamp": {
                          "type": "number",
                          "example": 1234567890
                        },
                        "parentName": {
                          "type": "string",
                          "example": "Parent Survey"
                        },
                        "fingerprint": {
                          "type": "string",
                          "example": "example-fingerprint"
                        },
                        "pageVisitType": {
                          "type": "string",
                          "example": "survey"
                        },
                        "contactSessionIds": {
                          "nullable": true,
                          "allOf": [
                            {
                              "type": "object",
                              "properties": {
                                "ids": {
                                  "example": [
                                    "session1",
                                    "session2"
                                  ],
                                  "nullable": true,
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "title": "ContactSessionIds"
                            }
                          ]
                        }
                      },
                      "title": "EventDataSchema"
                    },
                    "fieldsOriSequance": {
                      "example": [
                        "full_name",
                        "first_name",
                        "last_name",
                        "phone",
                        "email"
                      ],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "title": "othersSchema"
                }
              },
              "title": "SubmissionSchema"
            }
          },
          "meta": {
            "type": "object",
            "properties": {
              "total": {
                "type": "number",
                "example": 1
              },
              "currentPage": {
                "type": "number",
                "example": 1
              },
              "nextPage": {
                "type": "number",
                "example": null,
                "nullable": true
              },
              "prevPage": {
                "type": "number",
                "example": null,
                "nullable": true
              }
            },
            "title": "metaSchema"
          }
        },
        "title": "GetSurveysSubmissionSuccessfulResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## HighLevel SDK Examples

**Node.js** (`@gohighlevel/api-client`)

```javascript
import HighLevel from '@gohighlevel/api-client';

const ghl = new HighLevel({
  privateIntegrationToken: '<PRIVATE_INTEGRATION_TOKEN>'
});

const response = await ghl.surveys.getSurveysSubmissions({ locationId: '<LOCATIONID>' });
console.log(response);
```

**Python** (`gohighlevel-api-client`)

```python
from highlevel import HighLevel

client = HighLevel(
    private_integration_token='<PRIVATE_INTEGRATION_TOKEN>'
)

response = await client.surveys.get_surveys_submissions(locationId='<LOCATIONID>')
print(response)
```

**PHP** (`gohighlevel/api-client`)

```php
<?php
require_once 'vendor/autoload.php';

use HighLevel\HighLevel;
use HighLevel\HighLevelConfig;

$config = new HighLevelConfig([
    'privateIntegrationToken' => '<PRIVATE_INTEGRATION_TOKEN>'
]);
$ghl = new HighLevel($config);

$response = $ghl->surveys->getSurveysSubmissions(['locationId' => '<LOCATIONID>']);
echo json_encode($response, JSON_PRETTY_PRINT);
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/surveys/submissions?locationId=<LOCATIONID>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/surveys/submissions?locationId=<LOCATIONID>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/surveys/submissions"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

params = {
    "locationId": "<LOCATIONID>"
}

response = requests.get(url, params=params, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/surveys/submissions?locationId=<LOCATIONID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/surveys/submissions?locationId=<LOCATIONID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {
  url := "https://services.leadconnectorhq.com/surveys/submissions?locationId=<LOCATIONID>"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/surveys/submissions?locationId=<LOCATIONID>")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/surveys/submissions?locationId=<LOCATIONID>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
