# Ask question

To ask a question you need to execute a **POST** request against the **/rooms/:id/questions** endpoint.

You need to specify the participant who is asking the question, the actual question text and if it is an anonymous question. You can either specify an existing live participant id, or a name + external\_id if you are asking a question on behalf of someone not inside the room.

```
--If user is live in the room
"participant": {
   "id": "be50ca88-efca-4a03-aec6-f87ed57d5b16"
}

--If user is not existing in the room (an external one)
"participant": {
   "name": "John Smith",
   "external_id": "ABCDEF123456"
}
```

{% hint style="info" %}
A question can be asked as **anonymous** - that means nobody in the room will be able to see who asked the question. Only the question text will be seen.
{% endhint %}

#### Request

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl --request POST \
  --header "Content-Type: application/json" \
  --url https://api.digitalsamba.com/api/v1/rooms/c39d7c40-7ff7-4faa-b06f-698a639a9523/questions \
  --user YOUR_TEAM_ID:YOUR_DEVELOPER_KEY \
  --data '{"participant": {"id": "be50ca88-efca-4a03-aec6-f87ed57d5b16"}, "question": "When does the meeting start?", "anonymous": false}'
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}

```java
import com.fasterxml.jackson.databind.ObjectMapper;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.util.Base64;
import java.util.Map;

String TEAM_ID = "YOUR_TEAM_ID";
String DEVELOPER_KEY = "YOUR_DEVELOPER_KEY";
String authorizationHeader = "Bearer " + Base64.getEncoder().encodeToString((TEAM_ID + ":" + DEVELOPER_KEY).getBytes());

//Put your room id or friendly_url (name) here - this value is just an example
String roomId = "c39d7c40-7ff7-4faa-b06f-698a639a9523";

Map<String, Object> data = Map.of(
    "participant", Map.of("id", "be50ca88-efca-4a03-aec6-f87ed57d5b16")
    "question", "When does the meeting start?",
    "anonymous", false
);
String jsonData = new ObjectMapper().writeValueAsString(data);

HttpRequest request = HttpRequest.newBuilder()
  .POST(HttpRequest.BodyPublishers.ofString(jsonData))
  .uri(new URI("https://api.digitalsamba.com/api/v1/rooms/" + roomId + "/questions"))
  .header("Authorization", authorizationHeader)
  .header("Content-Type", "application/json")
  .build();

HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());

System.out.println("Status code: " + response.statusCode());
System.out.println("Body: " + response.body());
```

{% endtab %}
{% endtabs %}

**Response (200 -> No Content)**&#x20;

Response is empty because the question was created and there is no content to return.
