API Reference
Messaging
Here are examples for working with the Messaging collection through the REST API.
Sending Messages
const sendMessage = async (token, fromUserId, toUserId, subject, body) => {
const response = await fetch('https://api.picoshealth.com/v1/messages', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
subject: subject,
body: body,
from_user: fromUserId,
to_user: toUserId,
read: false,
}),
});
return response.json();
};
Getting Messages
Get User Inbox
const getUserInbox = async (token, userId, limit = 30) => {
const response = await fetch(
`https://api.picoshealth.com/v1/messages?where={"to_user":{"equals":"${userId}"}}&sort=-createdAt&limit=${limit}`,
{
headers: { 'Authorization': `Bearer ${token}` },
}
);
return response.json();
};
Get Unread Messages
const getUnreadMessages = async (token, userId) => {
const response = await fetch(
`https://api.picoshealth.com/v1/messages?where={"and":[{"to_user":{"equals":"${userId}"}},{"read":{"equals":false}}]}`,
{
headers: { 'Authorization': `Bearer ${token}` },
}
);
return response.json();
};
Get Sent Messages
const getSentMessages = async (token, userId, limit = 30) => {
const response = await fetch(
`https://api.picoshealth.com/v1/messages?where={"from_user":{"equals":"${userId}"}}&sort=-createdAt&limit=${limit}`,
{
headers: { 'Authorization': `Bearer ${token}` },
}
);
return response.json();
};
Managing Messages
Mark Message as Read
const markMessageAsRead = async (token, messageId) => {
const response = await fetch(
`https://api.picoshealth.com/v1/messages/${messageId}`,
{
method: 'PATCH',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
read: true,
}),
}
);
return response.json();
};
Mark Multiple Messages as Read
const markMultipleAsRead = async (token, messageIds) => {
const promises = messageIds.map(id =>
fetch(`https://api.picoshealth.com/v1/messages/${id}`, {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ read: true }),
}).then(r => r.json())
);
return Promise.all(promises);
};
Last Updated: June 22, 2026