Contacts
Contact is second part of protocol. It will store phone user which have added from user
The contact model
The contact model contains all the information about your contacts, such as their phone number and display name.
Properties
- Name
id- Type
- string
- Description
Unique identifier for the contact.
- Name
phone_number- Type
- string
- Description
The phone number for the contact.
- Name
display_name- Type
- string
- Description
The display name for the contact.
- Name
notes- Type
- string
- Description
The notes for the contact.
- Name
display_name- Type
- string
- Description
The contact display name in the contact list. By default, this is just the username.
- Name
created_at- Type
- timestamp
- Description
Timestamp of when the contact was created.
- Name
updated_at- Type
- timestamp
- Description
Timestamp of when the contact was updated.
List all contacts
This endpoint allows you to retrieve a paginated list of all your contacts. By default, a maximum of ten contacts are shown per page.
Optional attributes
- Name
limit- Type
- integer
- Description
Limit the number of contacts returned.
Request
curl -G https://api.protocol.chat/contacts \
-H "Authorization: Bearer {token}" \
-d limit=10
Response
{
"message": "Contact Data",
"data": [
{
"id": "WAz8eIbvDR60rouK",
"phone_number": "1-800-759-3000",
"display_name": null,
"notes": null,
"created_at": 692233200,
"updated_at" : 561684979
},
{
"id": "hSIhXBhNe8X1d8Et"
// ...
}
]
}
Create a contact
This endpoint allows you to add a new contact to your contact list in Protocol. To add a contact, you must provide their Protocol username and phone number.
Required attributes
- Name
phone_number- Type
- string
- Description
The phone number for the contact.
- Name
display_name- Type
- string
- Description
The contact display name in the contact list.
Optional attributes
- Name
notes- Type
- string
- Description
The notes for the contact.
Request
curl https://api.protocol.chat/contacts \
-H "Authorization: Bearer {token}" \
-d phone_number="1-800-759-3000" \
-d display_name="Jhon Doe"
Response
{
"id": "WAz8eIbvDR60rouK",
"phone_number": "1-800-759-3000",
"display_name": "Jhon Doe",
"notes": "Family",
"created_at": 692233200,
"updated_at": 792233200,
}
Retrieve a contact
This endpoint allows you to retrieve a contact by providing their Protocol id. Refer to the list at the top of this page to see which properties are included with contact objects.
Request
curl https://api.protocol.chat/contacts/WAz8eIbvDR60rouK \
-H "Authorization: Bearer {token}"
Response
{
"id": "WAz8eIbvDR60rouK",
"phone_number": "1-800-759-3000",
"display_name": "Jhon Doe",
"notes": "Family",
"created_at": 692233200,
"created_at": 788233200,
}
Update a contact
This endpoint allows you to perform an update on a contact. Currently, the only attribute that can be updated on contacts is the display_name attribute which controls how a contact appears in your contact list in Protocol.
Optional attributes
- Name
display_name- Type
- string
- Description
The contact display name in the contact list.
- Name
notes- Type
- string
- Description
The contact note in the contact list. By default
Request
curl -X PUT https://api.protocol.chat/contacts/WAz8eIbvDR60rouK \
-H "Authorization: Bearer {token}" \
-d display_name="Jhon Brick"
-d notes="My brother"
Response
{
"message" : "Update successfully",
"data" : {
"id": "WAz8eIbvDR60rouK",
"display_name": "Jhon Brick",
"notes": "My brother",
"updated_at" : 656464822
}
}
Delete a contact
This endpoint allows you to delete contacts from your contact list in Protocol. Note: This will also delete your conversation with the given contact.
Request
curl -X DELETE https://api.protocol.chat/contacts/WAz8eIbvDR60rouK \
-H "Authorization: Bearer {token}"