> For the complete documentation index, see [llms.txt](https://docs.api.intratool.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.api.intratool.de/api-reference/surveys/survey-votes.md).

# SurveyVotes

## Introduction

`SurveyVotes` represent the votes cast by [Users](/api-reference/users.md) for a specific [Survey](/api-reference/surveys/surveys.md).

Each `SurveyVote` is associated with a [User](/api-reference/users.md), the [Department](/api-reference/departments.md) and one or more [SurveyVoteSelectedAnswerOptions](https://github.com/intratool/intratool-api-docs/blob/gitbook-en/api-reference/surveys/survey-vote-selected-answer-options.md). Survey are subject to [Survey](/api-reference/surveys/surveys.md)-specific rules such as "one vote per department" or user confirmation requirements.

## Model Definition

### Alias

`surveyVote`

### Relations

| Key                     | Relation                                                                                                                                                       | Type       | Relation Field(s)                                    |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------------------------------------------- |
| `user`                  | [User](/api-reference/users.md)                                                                                                                                | Belongs to | `user_id`                                            |
| `groupAccountUser`      | [User](/api-reference/users.md)                                                                                                                                | Belongs to | `group_account_user_id`                              |
| `department`            | [Department](/api-reference/departments.md)                                                                                                                    | Belongs to | `department_id`                                      |
| `survey`                | [Survey](/api-reference/surveys/surveys.md)                                                                                                                    | Belongs to | `survey_id`                                          |
| `selectedAnswerOptions` | [SurveyVoteSelectedAnswerOption](https://github.com/intratool/intratool-api-docs/blob/gitbook-en/api-reference/surveys/survey-vote-selected-answer-options.md) | Has many   | `survey_vote_selected_answer_options.survey_vote_id` |

## List by Survey

Get a list of all `SurveyVotes` for a given [Survey](/api-reference/surveys/surveys.md) and authenticated user.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/surveys/{survey}/votes`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/surveys/1/votes', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 1,
    "user_id": 2,
    "group_account_user_id": null,
    "department_id": 1,
    "survey_id": 1,
    "created_at": "2024-07-15 12:00:00",
    "updated_at": "2024-07-15 12:00:00",
    "deleted_at": null
  },
  {
    "id": 2,
    "user_id": 3,
    "group_account_user_id": null,
    "department_id": 2,
    "survey_id": 1,
    "created_at": "2024-07-15 13:00:00",
    "updated_at": "2024-07-15 13:00:00",
    "deleted_at": null
  }
]
```

## Show

Show a single `SurveyVote` by `id`.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/surveys/{survey}/votes/{id}`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/surveys/1/votes/1', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "id": 1,
  "user_id": 2,
  "group_account_user_id": null,
  "department_id": 1,
  "survey_id": 1,
  "created_at": "2024-07-15 12:00:00",
  "updated_at": "2024-07-15 12:00:00",
  "deleted_at": null
}
```

## Show Current

Show the current `SurveyVote` for a given survey and authenticated user.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/surveys/{survey}/votes/current`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/surveys/1/votes/current', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "id": 1,
  "user_id": 2,
  "group_account_user_id": null,
  "department_id": 1,
  "survey_id": 1,
  "created_at": "2024-07-15 12:00:00",
  "updated_at": "2024-07-15 12:00:00",
  "deleted_at": null
}
```

## \[Adm.] List

Get a list of all `SurveyVotes` for a given survey (administration).

**Definition**

<mark style="color:green;">`GET`</mark> `/api/administration/surveys/{survey}/votes`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/administration/surveys/1/votes', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 1,
    "user_id": 2,
    "group_account_user_id": null,
    "department_id": 1,
    "survey_id": 1,
    "created_at": "2024-07-15 12:00:00",
    "updated_at": "2024-07-15 12:00:00",
    "deleted_at": null
  },
  {
    "id": 2,
    "user_id": 3,
    "group_account_user_id": null,
    "department_id": 2,
    "survey_id": 1,
    "created_at": "2024-07-15 13:00:00",
    "updated_at": "2024-07-15 13:00:00",
    "deleted_at": null
  }
]
```

## \[Adm.] Show

Show a single `SurveyVote` by `id` (administration).

**Definition**

<mark style="color:green;">`GET`</mark> `/api/administration/surveys/{survey}/votes/{id}`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/administration/surveys/1/votes/1', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "id": 1,
  "user_id": 2,
  "group_account_user_id": null,
  "department_id": 1,
  "survey_id": 1,
  "created_at": "2024-07-15 12:00:00",
  "updated_at": "2024-07-15 12:00:00",
  "deleted_at": null
}
```

## Create

Create a new `SurveyVote` for a survey.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/surveys/{survey}/votes`

**Request Keys**

| Key                           | Type  | Default | Description                                                                                  |
| ----------------------------- | ----- | ------- | -------------------------------------------------------------------------------------------- |
| `survey_answer_option_ids` \* | array | -       | Array of [SurveyAnswerOption](/api-reference/surveys/survey-answer-options.md) IDs selected. |

Keys with `*` are required.

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/surveys/1/votes', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'survey_answer_option_ids' => [1]
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 3,
    "user_id": 4,
    "group_account_user_id": null,
    "department_id": 2,
    "survey_id": 1,
    "created_at": "2024-07-15 14:00:00",
    "updated_at": "2024-07-15 14:00:00",
    "deleted_at": null
  }
}
```

## Delete

Delete an existing `SurveyVote` by `id`.

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/surveys/{survey}/votes/{id}`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/surveys/1/votes/1', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": null
}
```
