The Crisp API PHP wrapper. Authenticate, send messages, fetch conversations, access your agent accounts from your PHP code.
Copyright 2023 Crisp IM SAS. See LICENSE for copying information.
composer require crispchat/php-crisp-api
To authenticate against the API, obtain your authentication token keypair by following the REST API Authentication guide. You'll get a token keypair made of 2 values.
Keep your token keypair values private, and store them safely for long-term use.
Then, add authentication parameters to your client
instance right after you create it:
require __DIR__ . '/vendor/autoload.php';
$CrispClient = new \Crisp\CrispClient;
// Authenticate to API with your plugin token (identifier, key)
// eg. $CrispClient->authenticate("7c3ef21c-1e04-41ce-8c06-5605c346f73e", "cc29e1a5086e428fcc6a697d5837a66d82808e65c5cce006fbf2191ceea80a0a");
$CrispClient->setTier("plugin");
$CrispClient->authenticate(identifier, key);
// Now, you can use authenticated API sections.
You may follow the REST API Quickstart guide, which will get you running with the REST API in minutes.
require __DIR__ . '/vendor/autoload.php';
$CrispClient = new \Crisp\CrispClient;
$CrispClient->setTier("plugin");
$CrispClient->authenticate(identifier, key);
$conversations = $CrispClient->websiteConversations->getList(websiteId, 1);
echo $conversations;
All the available Crisp API resources are fully implemented. Programmatic methods names are named after their label name in the REST API Reference.
All methods that you will most likely need when building a Crisp integration are prefixed with a star symbol (⭐).
Where you see params
it is a plain Array object, e.g. [email => 'foo@example.com' ]
⚠️ Note that, depending on your authentication token tier, which is either user
or plugin
, you may not be allowed to use all methods from the library. When in doubt, refer to the library method descriptions below. Most likely, you are using a plugin
token.
Website Conversations
⭐ List Conversations [user
, plugin
]: Reference
CrispClient->websiteConversations->getList(websiteId, pageNumber)
⭐ Create a Conversation [user
, plugin
]: Reference
CrispClient->websiteConversations->create(websiteId)
Initiate a Conversation [user
, plugin
]: Reference
CrispClient->websiteConversations->initiateOne(websiteId, sessionId)
Find Conversations With Search [user
, plugin
]: Reference
CrispClient->websiteConversations->findWithSearch(websiteId, pageNumber, searchQuery, searchType, searchOperator, includeEmpty, filterUnread, filterResolved, filterNotResolved, filterMention, filterAssigned, filterUnassigned, filterDateStart, filterDateEnd, orderDateCreated, orderDateUpdated)
⭐ Get A Conversation [user
, plugin
]: Reference
CrispClient->websiteConversations->getOne(websiteId, sessionId)
⭐ Send a Message in Conversation [user
, plugin
]: Reference
CrispClient->websiteConversations->sendMessage(websiteId, sessionId, message)
⭐ Get Conversation Metas [user
, plugin
]: Reference
CrispClient->websiteConversations->getMeta(websiteId, sessionId)
⭐ Update Conversation Metas [user
, plugin
]: Reference
CrispClient->websiteConversations->updateMeta(websiteId, sessionId, params)
⭐ Get Messages in Conversation [user
, plugin
]: Reference
CrispClient->websiteConversations->getMessages(websiteId, sessionId, timestampBefore)
Get Conversation Original Message [user
, plugin
]: Reference
CrispClient->websiteConversations->getOriginalMessage(websiteId, sessionId, originalId)
⭐ Change Conversation State [user
, plugin
]: Reference
CrispClient->websiteConversations->setState(websiteId, sessionId, state)
Get Conversation Routing [user
, plugin
]: Reference
CrispClient->websiteConversations->getRouting(websiteId, sessionId)
Assign Conversation Routing [user
, plugin
]: Reference
CrispClient->websiteConversations->assignRouting(websiteId, sessionId, params)
Block Conversation: [user
, plugin
]: Reference
CrispClient->websiteConversations->setBlock(websiteId, sessionId, blocked)
Delete Conversation: [user
, plugin
]: Reference
CrispClient->websiteConversations->deleteOne(websiteId, sessionId)
Acknowledge Messages as Read: [user
, plugin
]: Reference
CrispClient->websiteConversations->acknowledgeMessages(websiteId, sessionId, fingerprints)
Schedule a Reminder in a Conversation: [user
, plugin
]: Reference
CrispClient->websiteConversations->scheduleReminder(websiteId, sessionId, params)
Website People (these are your end-users)
Find By Email [user
, plugin
]: Reference
CrispClient->websitePeople->findByEmail(websiteId, email)
Find With Search Text (Name, Email, Segments) [user
, plugin
]: Reference
CrispClient->websitePeople->findWithSearchText(websiteId, searchText)
Create A New Profile [user
, plugin
]: Reference
CrispClient->websitePeople->createNewPeopleProfile(websiteId, params)
⭐ Check If Exists [user
, plugin
]: Reference
CrispClient->websitePeople->checkPeopleProfileExists(websiteId, peopleId)
⭐ Get People Profile [user
, plugin
]: Reference
CrispClient->websitePeople->getPeopleProfile(websiteId, peopleId)
⭐ List People Profiles [user
, plugin
]: Reference
CrispClient->websitePeople->listPeopleProfiles(websiteId, pageNumber)
⭐ Remove A Profile [user
, plugin
]: Reference
CrispClient->websitePeople->removePeopleProfile(websiteId, peopleId)
⭐ Save A Profile [user
, plugin
]: Reference
CrispClient->websitePeople->savePeopleProfile(websiteId, peopleId, params)
⭐ Update A Profile [user
, plugin
]: Reference
CrispClient->websitePeople->updatePeopleProfile(websiteId, peopleId, params)
List Conversations [user
, plugin
] Reference
CrispClient->websitePeople->listPeopleConversations(websiteId, peopleId, pageNumber)
List Segments [user
, plugin
]: Reference
CrispClient->websitePeople->listPeopleSegments(websiteId, peopleId, pageNumber)
List Events [user
, plugin
]: Reference
CrispClient->websitePeople->listPeopleEvent(websiteId, peopleId, pageNumber)
Add Event [user
, plugin
]: Reference
CrispClient->websitePeople->addPeopleEvent(websiteId, peopleId, event)
Get Data [user
, plugin
]: Reference
CrispClient->websitePeople->getPeopleData(websiteId, peopleId)
Save Data [user
, plugin
]: Reference
CrispClient->websitePeople->savePeopleData(websiteId, peopleId, params)
Update Data [user
, plugin
]: Reference
CrispClient->websitePeople->updatePeopleData(websiteId, peopleId, params)
Get Subscription Status [user
, plugin
]: Reference
CrispClient->websitePeople->getPeopleSubscriptionStatus(websiteId, peopleId)
Update Subscription Status [user
, plugin
]: Reference
CrispClient->websitePeople->updatePeopleSubscriptionStatus(websiteId, peopleId, params)
👉 Notice: The peopleID
argument can be an email or the peopleID
.
Website Base
Create A Website [user
, plugin
]: Reference
CrispClient->website->create(params)
Delete A Website [user
]: Reference
CrispClient->website->delete(websiteId)
Website Settings
Get Website Settings [user
, plugin
]: Reference
CrispClient->websiteSettings->get(websiteId)
Update Website Settings [user
, plugin
]Reference:
CrispClient->websiteSettings->get(params)
Website Verify
Get Verify Settings [user
, plugin
]: Reference
CrispClient->websiteVerify->getSettings(websiteId)
Update Verify Settings [user
, plugin
]: Reference
CrispClient->websiteVerify->updateSettings(websiteId, params)
Get Verify Key [user
, plugin
]: Reference
CrispClient->websiteVerify->getKey(websiteId)
Roll Key [user
, plugin
]: Reference
CrispClient->websiteVerify->rollKey(websiteId)
Website Operators
Get All Operators [user
, plugin
]: Reference
CrispClient->websiteOperators->getList(websiteId)
Get One Operators [user
, plugin
]: Reference
CrispClient->websiteOperators->getOne(websiteId, operatorId)
Delete One Operators [user
, plugin
]: Reference
CrispClient->websiteOperators->deleteOne(websiteId, operatorId)
Update An Operator [user
, plugin
]: Reference
CrispClient->websiteOperators->updateOne(websiteId, operatorId, parameters)
Website Visitors
user
, plugin
]: ReferenceCrispClient->websiteVisitors->listVisitors(websiteId, pageNumber)
Website Availability
Get Availability Status [user
, plugin
]: Reference
CrispClient->websiteAvailability->getAvailabilityStatus(websiteId)
List Operator Availabilities [user
, plugin
]: Reference
CrispClient->websiteAvailability->listOperatorAvailabilities(websiteId)
Plugin Subscriptions
List All Active Subsciptions [user
]: Reference
CrispClient->pluginSubscriptions->listAllActiveSubscriptions()
Get All Subscriptions For Website [user
]: Reference
CrispClient->pluginSubscriptions->listSubscriptionsForWebsite(websiteId)
Get Subscription Details [user
, plugin
]: Reference
CrispClient->pluginSubscriptions->getSubscriptionDetails(websiteId)
Subscribe Website To Plugin [user
]: Reference
CrispClient->pluginSubscriptions->subscribeWebsiteToPlugin(websiteId, pluginId)
Unsubscribe Plugin From Website [user
]: Reference
CrispClient->pluginSubscriptions->unsubscribePluginFromWebsite(websiteId, pluginId)
Get Subscription Settings [user
, plugin
]: Reference
CrispClient->pluginSubscriptions->getSubscriptionSettings(websiteId, pluginId)
Save Subscription Settings [user
, plugin
]: Reference
CrispClient->pluginSubscriptions->saveSubscriptionSettings(websiteId, pluginId, settings)