# Participant Conversation Resource

The ParticipantConversation resource lists all the Conversations for a specific participant. It performs the lookup using an exact match to the participant identifier.\
This resource supports the lookup of conversations for a specific participant based on two types of query parameters:

* Identity: for Chat users,
* Address: for non-Chat members, e.g., SMS or WhatsApp addresses.

Users can provide only one parameter at a time, i.e. either `identity` or `address`. The returned data will be sorted by the `conversationSid` alphabetically.

## ParticipantConversation Properties

Each Participant Conversation resource contains these properties.

```json
{"type":"object","refName":"conversations.v1.participant_conversation","modelName":"conversations_v1_participant_conversation","properties":{"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The unique ID of the [Account](/docs/iam/api/account) responsible for this conversation."},"chat_service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^IS[0-9a-fA-F]{32}$","nullable":true,"description":"The unique ID of the [Conversation Service](/docs/conversations/api/service-resource) this conversation belongs to."},"participant_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^MB[0-9a-fA-F]{32}$","nullable":true,"description":"The unique ID of the [Participant](/docs/conversations/api/conversation-participant-resource)."},"participant_user_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^US[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that identifies the conversation participant as [Conversation User](/docs/conversations/api/user-resource)."},"participant_identity":{"type":"string","nullable":true,"description":"A unique string identifier for the conversation participant as [Conversation User](/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"participant_messaging_binding":{"nullable":true,"description":"Information about how this participant exchanges messages with the conversation. A JSON parameter consisting of type and address fields of the participant.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"conversation_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^CH[0-9a-fA-F]{32}$","nullable":true,"description":"The unique ID of the [Conversation](/docs/conversations/api/conversation-resource) this Participant belongs to."},"conversation_unique_name":{"type":"string","nullable":true,"description":"An application-defined string that uniquely identifies the Conversation resource.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"conversation_friendly_name":{"type":"string","nullable":true,"description":"The human-readable name of this conversation, limited to 256 characters. Optional.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"conversation_attributes":{"type":"string","nullable":true,"description":"An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified.  **Note** that if the attributes are not set \"{}\" will be returned.","x-twilio":{"pii":{"handling":"sensitive","deleteSla":30}}},"conversation_date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date that this conversation was created, given in ISO 8601 format."},"conversation_date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date that this conversation was last updated, given in ISO 8601 format."},"conversation_created_by":{"type":"string","nullable":true,"description":"Identity of the creator of this Conversation."},"conversation_state":{"type":"string","enum":["inactive","active","closed"],"description":"The current state of this User Conversation. One of `inactive`, `active` or `closed`.","refName":"participant_conversation_enum_state","modelName":"participant_conversation_enum_state"},"conversation_timers":{"nullable":true,"description":"Timer date values representing state update for this conversation."},"links":{"type":"object","format":"uri-map","nullable":true,"description":"Contains absolute URLs to access the [participant](/docs/conversations/api/conversation-participant-resource) and [conversation](/docs/conversations/api/conversation-resource) of this conversation."}}}
```

## List All of a Participant's Conversations

`GET https://conversations.twilio.com/v1/ParticipantConversations`

The ParticipantConversation resource also supports pagination via additional parameters like: `PageSize` and `PageToken`.

> \[!NOTE]
>
> It's expected that you will encode the url for the ParticipantConversations endpoint, for example, if a phone number is passed as an address parameter the `+` character should be encoded as `%2B`.

> \[!WARNING]
>
> In the [Group MMS](/docs/conversations/group-texting#what-is-group-texting) use case, it may happen that the participant might not have an identifier (no `address` and no `identity`). So, this endpoint will not return conversations for this participant. Similarly if the identity of this participant with [Projected Address](/docs/conversations/group-texting#projected-addresses-vs-proxy-addresses) is created later then this endpoint will not return conversations to which this participant was added when it was without identity.

### Query parameters

```json
[{"name":"Identity","in":"query","description":"A unique string identifier for the conversation participant as [Conversation User](/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters.","schema":{"type":"string"},"examples":{"readEmpty":{"value":"identity"},"readFullByIdentity":{"value":"identity"}}},{"name":"Address","in":"query","description":"A unique string identifier for the conversation participant who's not a Conversation User. This parameter could be found in messaging_binding.address field of Participant resource. It should be url-encoded.","schema":{"type":"string"},"examples":{"readFullByAddress":{"value":"+375255555555"}}},{"name":"PageSize","in":"query","description":"How many resources to return in each list page. The default is 50, and the maximum is 50.","schema":{"type":"integer","format":"int64","minimum":1,"maximum":50}},{"name":"Page","in":"query","description":"The page index. This value is simply for client state.","schema":{"type":"integer","minimum":0}},{"name":"PageToken","in":"query","description":"The page token. This is provided by the API.","schema":{"type":"string"}}]
```

List All of a Participant's Conversations

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function listParticipantConversation() {
  const participantConversations =
    await client.conversations.v1.participantConversations.list({
      address: "+375255555555",
      limit: 20,
    });

  participantConversations.forEach((p) => console.log(p.accountSid));
}

listParticipantConversation();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

participant_conversations = (
    client.conversations.v1.participant_conversations.list(
        address="+375255555555", limit=20
    )
)

for record in participant_conversations:
    print(record.account_sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Conversations.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var participantConversations =
            await ParticipantConversationResource.ReadAsync(address: "+375255555555", limit: 20);

        foreach (var record in participantConversations) {
            Console.WriteLine(record.AccountSid);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.conversations.v1.ParticipantConversation;
import com.twilio.base.ResourceSet;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<ParticipantConversation> participantConversations =
            ParticipantConversation.reader().setAddress("+375255555555").limit(20).read();

        for (ParticipantConversation record : participantConversations) {
            System.out.println(record.getAccountSid());
        }
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	conversations "github.com/twilio/twilio-go/rest/conversations/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &conversations.ListParticipantConversationParams{}
	params.SetAddress("+375255555555")
	params.SetLimit(20)

	resp, err := client.ConversationsV1.ListParticipantConversation(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			if resp[record].AccountSid != nil {
				fmt.Println(*resp[record].AccountSid)
			} else {
				fmt.Println(resp[record].AccountSid)
			}
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$participantConversations = $twilio->conversations->v1->participantConversations->read(
    ["address" => "+375255555555"],
    20
);

foreach ($participantConversations as $record) {
    print $record->accountSid;
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

participant_conversations = @client
                            .conversations
                            .v1
                            .participant_conversations
                            .list(
                              address: '+375255555555',
                              limit: 20
                            )

participant_conversations.each do |record|
   puts record.account_sid
end
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:conversations:v1:participant-conversations:list \
   --address +375255555555
```

```bash
curl -X GET "https://conversations.twilio.com/v1/ParticipantConversations?Address=%2B375255555555&PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "conversations": [
    {
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "conversation_friendly_name": "friendly_name",
      "conversation_state": "inactive",
      "conversation_timers": {
        "date_inactive": "2015-12-16T22:19:38Z",
        "date_closed": "2015-12-16T22:28:38Z"
      },
      "conversation_attributes": "{}",
      "conversation_date_created": "2015-07-30T20:00:00Z",
      "conversation_date_updated": "2015-07-30T20:00:00Z",
      "conversation_created_by": "created_by",
      "conversation_unique_name": "unique_name",
      "participant_user_sid": null,
      "participant_identity": null,
      "participant_messaging_binding": {
        "address": "+375255555555",
        "proxy_address": "+12345678910",
        "type": "sms",
        "level": null,
        "name": null,
        "projected_address": null
      },
      "links": {
        "participant": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        "conversation": "https://conversations.twilio.com/v1/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
      }
    }
  ],
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://conversations.twilio.com/v1/ParticipantConversations?Address=%2B375255555555&PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://conversations.twilio.com/v1/ParticipantConversations?Address=%2B375255555555&PageSize=50&Page=0",
    "next_page_url": null,
    "key": "conversations"
  }
}
```
