# Get Survey Result

`GET /api/surveys/:id/result`

Retrieve the results of a voice survey campaign. The response includes survey metadata, call status distribution, and detailed results for each phone number including the keys pressed by recipients during the survey.

## Path Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| id | integer | Yes | The survey ID returned from survey creation. |

## Request Example

```bash
curl -X GET https://api.awajdigital.com/api/surveys/456/result \
  -H "Authorization: Bearer your_api_token_here" \
  -H "Accept: application/json"
```

```javascript
// Browser JavaScript (Fetch API)
const surveyId = 456;
const response = await fetch(`https://api.awajdigital.com/api/surveys/${surveyId}/result`, {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer your_api_token_here',
    'Accept': 'application/json'
  }
});

const data = await response.json();
console.log(data);
```

```javascript
// Node.js with axios
const axios = require('axios');

async function getSurveyResult(surveyId) {
  try {
    const response = await axios.get(
      `https://api.awajdigital.com/api/surveys/${surveyId}/result`,
      {
        headers: {
          'Authorization': 'Bearer your_api_token_here',
          'Accept': 'application/json'
        }
      }
    );

    console.log(response.data);
  } catch (error) {
    console.error('Error:', error.response?.data || error.message);
  }
}

getSurveyResult(456);
```

```python
# Python with requests
import requests

def get_survey_result(survey_id):
    url = f'https://api.awajdigital.com/api/surveys/{survey_id}/result'
    headers = {
        'Authorization': 'Bearer your_api_token_here',
        'Accept': 'application/json'
    }

    try:
        response = requests.get(url, headers=headers)
        print(response.json())
    except requests.exceptions.RequestException as e:
        print(f'Error: {e}')

get_survey_result(456)
```

```php
<?php
// PHP with cURL
$surveyId = 456;
$url = "https://api.awajdigital.com/api/surveys/{$surveyId}/result";
$token = 'your_api_token_here';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
print_r($result);
?>
```

## In-Progress Survey Response

```json
{
  "success": true,
  "survey": {
    "id": 456,
    "name": "api_survey_1_customer_satisfaction_survey_3",
    "status": "broadcasting",
    "totalCount": 3,
    "completeCount": 1,
    "createdAt": "2025-12-30T10:00:00.000Z",
    "metadata": { "campaign_id": "summer2025", "customer_segment": "premium" }
  },
  "isComplete": false,
  "statusDistribution": {
    "pending": 2,
    "answered": 1,
    "not_answered": 0,
    "failed": 0
  },
  "numbers": [
    {
      "number": "019XXXXXXXX",
      "status": "pending",
      "duration": null,
      "pressedKeys": []
    },
    {
      "number": "018XXXXXXXX",
      "status": "answered",
      "duration": 45,
      "pressedKeys": ["1", "5"]
    },
    {
      "number": "017XXXXXXXX",
      "status": "pending",
      "duration": null,
      "pressedKeys": []
    }
  ]
}
```

## Completed Survey Response

```json
{
  "success": true,
  "survey": {
    "id": 456,
    "name": "api_survey_1_customer_satisfaction_survey_3",
    "status": "completed",
    "totalCount": 3,
    "completeCount": 3,
    "createdAt": "2025-12-30T10:00:00.000Z",
    "metadata": { "campaign_id": "summer2025", "customer_segment": "premium" }
  },
  "isComplete": true,
  "statusDistribution": {
    "pending": 0,
    "answered": 2,
    "not_answered": 1,
    "failed": 0
  },
  "numbers": [
    {
      "number": "019XXXXXXXX",
      "status": "answered",
      "duration": 52,
      "pressedKeys": ["2", "4", "1"]
    },
    {
      "number": "018XXXXXXXX",
      "status": "answered",
      "duration": 45,
      "pressedKeys": ["1", "5"]
    },
    {
      "number": "017XXXXXXXX",
      "status": "not_answered",
      "duration": null,
      "pressedKeys": []
    }
  ]
}
```

:::note
The `isComplete` field indicates whether the survey has finished (status is "completed" or "cancelled"). The `pressedKeys` array contains the digits pressed by the recipient in response to survey questions. The `statusDistribution` shows the count of calls in each status: pending, answered, not_answered, or failed.
:::

:::note[Survey Response Data]
Each number in the results includes the call status, duration (in seconds), and the keys pressed by the recipient. Use this data to analyze survey responses and calculate metrics like response rates, average call duration, and answer distributions.
:::