Frameworks
Frameworks are the best way to build Edge Computing applications without the need to write a single line of code.
The conversation model
The conversation model contains all the information about the conversations between you and your contacts. In addition, conversations can also be group-based with more than one contact, they can have a pinned message, and they can be muted.
Properties
- Name
id
- Type
- string
- Description
Unique identifier for the conversation.
- Name
contact_id
- Type
- string
- Description
Unique identifier for the other contact in the conversation.
- Name
group_id
- Type
- string
- Description
Unique identifier for the group that the conversation belongs to.
- Name
pinned_message_id
- Type
- string
- Description
Unique identifier for the pinned message.
- Name
is_pinned
- Type
- boolean
- Description
Whether or not the conversation has been pinned.
- Name
is_muted
- Type
- boolean
- Description
Whether or not the conversation has been muted.
- Name
last_active_at
- Type
- timestamp
- Description
Timestamp of when the conversation was last active.
- Name
last_opened_at
- Type
- timestamp
- Description
Timestamp of when the conversation was last opened by the authenticated user.
- Name
created_at
- Type
- timestamp
- Description
Timestamp of when the conversation was created.
- Name
archived_at
- Type
- timestamp
- Description
Timestamp of when the conversation was archived.
List all conversations
This endpoint allows you to retrieve a paginated list of all your conversations. By default, a maximum of ten conversations are shown per page.
Optional attributes
- Name
limit
- Type
- integer
- Description
Limit the number of conversations returned.
- Name
muted
- Type
- boolean
- Description
Only show conversations that are muted when set to
true
.
- Name
archived
- Type
- boolean
- Description
Only show conversations that are archived when set to
true
.
- Name
pinned
- Type
- boolean
- Description
Only show conversations that are pinned when set to
true
.
- Name
group_id
- Type
- string
- Description
Only show conversations for the specified group.
Request
curl -G https://api.protocol.chat/v1/conversations \
-H "Authorization: Bearer {token}" \
-d limit=10
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.conversations.list()
from protocol_api import ApiClient
client = ApiClient(token)
client.conversations.list()
$client = new \Protocol\ApiClient($token);
$client->conversations->list();
{
"has_more": false,
"data": [
{
"id": "xgQQXg3hrtjh7AvZ",
"contact_id": "WAz8eIbvDR60rouK",
"group_id": null,
"pinned_message_id": null,
"is_pinned": false,
"is_muted": false,
"last_active_at": 705103200,
"last_opened_at": 705103200,
"created_at": 692233200,
"archived_at": null
},
{
"id": "hSIhXBhNe8X1d8Et"
// ...
}
]
}
Create a conversation
This endpoint allows you to add a new conversation between you and a contact or group. A contact or group id is required to create a conversation.
Required attributes
- Name
contact_id
- Type
- string
- Description
Unique identifier for the other contact in the conversation.
- Name
group_id
- Type
- string
- Description
Unique identifier for the group that the conversation belongs to.
Request
curl https://api.protocol.chat/v1/conversations \
-H "Authorization: Bearer {token}" \
-d 'contact_id'="WAz8eIbvDR60rouK"
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.conversations.create({
contact_id: 'WAz8eIbvDR60rouK',
})
from protocol_api import ApiClient
client = ApiClient(token)
client.conversations.create(contact_id="WAz8eIbvDR60rouK")
$client = new \Protocol\ApiClient($token);
$client->conversations->create([
'contact_id' => 'WAz8eIbvDR60rouK',
]);
{
"id": "xgQQXg3hrtjh7AvZ",
"contact_id": "WAz8eIbvDR60rouK",
"group_id": null,
"pinned_message_id": null,
"is_pinned": false,
"is_muted": false,
"last_active_at": null,
"last_opened_at": null,
"created_at": 692233200,
"archived_at": null
}
Retrieve a conversation
This endpoint allows you to retrieve a conversation by providing the conversation id. Refer to the list at the top of this page to see which properties are included with conversation objects.
Request
curl https://api.protocol.chat/v1/conversations/xgQQXg3hrtjh7AvZ \
-H "Authorization: Bearer {token}"
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.conversations.get('xgQQXg3hrtjh7AvZ')
from protocol_api import ApiClient
client = ApiClient(token)
client.conversations.get("xgQQXg3hrtjh7AvZ")
$client = new \Protocol\ApiClient($token);
$client->conversations->get('xgQQXg3hrtjh7AvZ');
{
"id": "xgQQXg3hrtjh7AvZ",
"contact_id": "WAz8eIbvDR60rouK",
"group_id": null,
"pinned_message_id": null,
"is_pinned": false,
"is_muted": false,
"last_active_at": 705103200,
"last_opened_at": 705103200,
"created_at": 692233200,
"archived_at": null
}
Update a conversation
This endpoint allows you to perform an update on a conversation. Examples of updates are pinning a message, muting or archiving the conversation, or pinning the conversation itself.
Optional attributes
- Name
pinned_message_id
- Type
- string
- Description
Unique identifier for the pinned message.
- Name
is_pinned
- Type
- boolean
- Description
Whether or not the conversation has been pinned.
- Name
is_muted
- Type
- boolean
- Description
Whether or not the conversation has been muted.
- Name
archived_at
- Type
- timestamp
- Description
Timestamp of when the conversation was archived.
Request
curl -X PUT https://api.protocol.chat/v1/conversations/xgQQXg3hrtjh7AvZ \
-H "Authorization: Bearer {token}" \
-d 'is_muted'=true
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.conversations.update('xgQQXg3hrtjh7AvZ', {
is_muted: true,
})
from protocol_api import ApiClient
client = ApiClient(token)
client.conversations.update("xgQQXg3hrtjh7AvZ", is_muted=True)
$client = new \Protocol\ApiClient($token);
$client->conversations->update('xgQQXg3hrtjh7AvZ', [
'is_muted' => true,
]);
{
"id": "xgQQXg3hrtjh7AvZ",
"contact_id": "WAz8eIbvDR60rouK",
"group_id": null,
"pinned_message_id": null,
"is_pinned": false,
"is_muted": true,
"last_active_at": 705103200,
"last_opened_at": 705103200,
"created_at": 692233200,
"archived_at": null
}
Delete a conversation
This endpoint allows you to delete your conversations in Protocol. Note: This will permanently delete the conversation and all its messages — archive it instead if you want to be able to restore it later.
Request
curl -X DELETE https://api.protocol.chat/v1/conversations/xgQQXg3hrtjh7AvZ \
-H "Authorization: Bearer {token}"
import ApiClient from '@example/protocol-api'
const client = new ApiClient(token)
await client.conversations.delete('xgQQXg3hrtjh7AvZ')
from protocol_api import ApiClient
client = ApiClient(token)
client.conversations.delete("xgQQXg3hrtjh7AvZ")
$client = new \Protocol\ApiClient($token);
$client->conversations->delete('xgQQXg3hrtjh7AvZ');