# Sessões abertas via API

### Pedir <a href="#request" id="request"></a>

Para consultar sessões abertas através de nossa API, você precisa fazer a solicitação GET para o seguinte endereço:

`GET http://api-messaging.wavy.global/v1/session?customerId={customerId}&subAccountId={subAccountId}`

Passar o parâmetro ***customerId*** é obrigatório, enquanto ***subAccountId*** é opcional.

Atenção: Tenha cuidado para substituir '{' e '}' também. Por exemplo, "={customerId}" torna-se "=42".

Você também precisará usar os seguintes cabeçalhos:

| Cabeçalho               | Valor                            |
| ----------------------- | -------------------------------- |
| **Tipo de conteúdo**    | aplicação/json                   |
| **authenticationToken** | Token de autenticação Messaging1 |
| **Nome de usuário**     | Nome de usuário Messaging1       |

#### Resposta <a href="#response" id="response"></a>

Em caso de êxito, se houver sessões abertas para customerId e subAccountId especificados, a solicitação retornará um JSON com o atributo:

<table><thead><tr><th width="178">Campo</th><th>Valor</th></tr></thead><tbody><tr><td><strong>file_url</strong></td><td>Link para download de um arquivo do tipo csv contendo os campos "origem" e "session_created_at" de todos os destinos encontrados</td></tr></tbody></table>

Se não houver dados associados a ***customerId*** e ***subAccountId***, o arquivo retornado estará vazio, com apenas o cabeçalho.

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

```
```

{% endtab %}

{% tab title="Ruby" %}

```
{
  "total": 1,
  "data": [
    {
      "id": "ce425ffe-bc62-421f-9261-e6819a5eab43",
      "source": "5519900000000",
      "origin": "5519900000000",
      "userProfile": {
        "name": "name of the user"
      },
      "campaignId": 100,
      "correlationId": "...",
      "campaignAlias": "...",
      "flowId": "....",
      "extraInfo": "...",
      "message": {
        "type": "TEXT",
        "messageText": "Hi, this is a message from the user"
      },
      "receivedAt": 1513616971473,
      "receivedDate": "2017-12-18T17:09:31.473Z"
    }
  ]
}
```

{% endtab %}

{% tab title="Python" %}

```
{
  "total": 1,
  "data": [
    {
      "id": "ce425ffe-bc62-421f-9261-e6819a5eab43",
      "source": "5519900000000",
      "origin": "5519900000000",
      "userProfile": {
        "name": "name of the user"
      },
      "campaignId": 100,
      "correlationId": "...",
      "campaignAlias": "...",
      "flowId": "....",
      "extraInfo": "...",
      "message": {
        "type": "TEXT",
        "messageText": "Hi, this is a message from the user"
      },
      "receivedAt": 1513616971473,
      "receivedDate": "2017-12-18T17:09:31.473Z"
    }
  ]
}
```

{% endtab %}

{% tab title="PHP" %}

```
{
  "total": 1,
  "data": [
    {
      "id": "ce425ffe-bc62-421f-9261-e6819a5eab43",
      "source": "5519900000000",
      "origin": "5519900000000",
      "userProfile": {
        "name": "name of the user"
      },
      "campaignId": 100,
      "correlationId": "...",
      "campaignAlias": "...",
      "flowId": "....",
      "extraInfo": "...",
      "message": {
        "type": "TEXT",
        "messageText": "Hi, this is a message from the user"
      },
      "receivedAt": 1513616971473,
      "receivedDate": "2017-12-18T17:09:31.473Z"
    }
  ]
}
```

{% endtab %}

{% tab title="Java" %}

```
{
  "total": 1,
  "data": [
    {
      "id": "ce425ffe-bc62-421f-9261-e6819a5eab43",
      "source": "5519900000000",
      "origin": "5519900000000",
      "userProfile": {
        "name": "name of the user"
      },
      "campaignId": 100,
      "correlationId": "...",
      "campaignAlias": "...",
      "flowId": "....",
      "extraInfo": "...",
      "message": {
        "type": "TEXT",
        "messageText": "Hi, this is a message from the user"
      },
      "receivedAt": 1513616971473,
      "receivedDate": "2017-12-18T17:09:31.473Z"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

> Exemplo de informações extras

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

```
{
    "file_url": "https://chatclub-cdn.wavy.global/2019/02/13/633e33fc-3a3f-4ca5-a8b0-4b747fb67137/5bd46e2b-5990-4681-9b29-98ab6598960e"
}
```

{% endtab %}

{% tab title="Ruby" %}

```
{
    "file_url": "https://chatclub-cdn.wavy.global/2019/02/13/633e33fc-3a3f-4ca5-a8b0-4b747fb67137/5bd46e2b-5990-4681-9b29-98ab6598960e"
}
```

{% endtab %}

{% tab title="Python" %}

```
{
    "file_url": "https://chatclub-cdn.wavy.global/2019/02/13/633e33fc-3a3f-4ca5-a8b0-4b747fb67137/5bd46e2b-5990-4681-9b29-98ab6598960e"
}
```

{% endtab %}

{% tab title="PHP" %}

```
{
    "file_url": "https://chatclub-cdn.wavy.global/2019/02/13/633e33fc-3a3f-4ca5-a8b0-4b747fb67137/5bd46e2b-5990-4681-9b29-98ab6598960e"
}
```

{% endtab %}

{% tab title="Java" %}

```
{
    "file_url": "https://chatclub-cdn.wavy.global/2019/02/13/633e33fc-3a3f-4ca5-a8b0-4b747fb67137/5bd46e2b-5990-4681-9b29-98ab6598960e"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-pt.sinch.com/documentacao-tecnica-whatsapp/documentacao-tecnica-whatsapp/sessoes-abertas-via-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
