Download the PHP package sashalenz/chatwoot-api without Composer

On this page you can find all versions of the php package sashalenz/chatwoot-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package chatwoot-api

Chatwoot API for Laravel

Latest Version on Packagist Total Downloads

A thin, fluent Laravel SDK for the Chatwoot Application API. It wraps contacts, conversations and messages behind a small, expressive API so you can integrate Chatwoot into any Laravel application without hand-rolling HTTP calls.

Authentication. Chatwoot's Application API authenticates with the api_access_token header — a user/agent token or an agent-bot token — not Authorization: Bearer. This package handles that for you.

Requirements

Installation

Install the package via Composer:

Optionally publish the config file:

Configuration

Set the following variables in your .env:

Key Env Description
base_url CHATWOOT_BASE_URL Base URL of your Chatwoot installation. Do not include the /api/v1 prefix — the transport adds it.
account_id CHATWOOT_ACCOUNT_ID Default account id for the Application API path. Can be overridden per call.
token CHATWOOT_API_TOKEN Application API access token sent in the api_access_token header. Can be overridden per call.
identifier CHATWOOT_INBOX_IDENTIFIER Client API inbox identifier (from the API-channel inbox settings). Auth for the public bridge surface — no agent token needed.
hmac_key CHATWOOT_HMAC_KEY Optional HMAC key for Client API identity validation.
platform_token CHATWOOT_PLATFORM_TOKEN Platform API app token. Sent in the same api_access_token header, but a different token than the Application one. Can be overridden per call.

Three API families

Usage

The package exposes a static entrypoint, ChatwootApi, with one method per resource. Entity methods return typed spatie/laravel-data DTOs (see Typed responses below).

Typed responses

Entity methods return DTOs under Sashalenz\ChatwootApi\Data\* (e.g. ContactData, ConversationData, MessageData, InboxData, …) with idiomatic camelCase properties mapped from Chatwoot's snake_case payloads. Unknown fields are ignored, so the DTOs tolerate Chatwoot adding keys.

Client API (API-channel inbound bridge)

Push a customer's messages into an API-channel inbox using only the inbox identifier — no agent token. Messages are created as incoming.

Agent replies flow back to you via the inbox Webhook URL (a message_created event with message_type: outgoing) — handle that in your app and deliver to the transport (see Handling webhooks).

Handling webhooks

Chatwoot POSTs events to your configured Webhook URL. WebhookEvent parses the body and exposes the event plus typed accessors for the subject entity:

message(), conversation() and contact() return the relevant DTO (or null) regardless of which event family arrived; raw() exposes the full payload for anything not modelled. isIncoming()/isOutgoing() normalise the message type across the webhook (string) and REST (integer) forms.

Per-call account & token overrides

Useful for multi-account or multi-token setups. Any override wins over the config value:

API surface

Resource Method Description
contacts() create(array $attributes) Create a contact.
list(array $query = []) List contacts.
get(int $contactId) Fetch a single contact.
update(int $contactId, array $attributes) Update a contact.
delete(int $contactId) Delete a contact.
search(string $q, array $query = []) Free-text search (name/email/phone/identifier).
filter(array $payload) Advanced contact filtering (query-builder payload).
createInbox(int $contactId, int $inboxId, ?string $sourceId = null) Associate an existing contact with an inbox and get a source_id.
contactableInboxes(int $contactId) Inboxes the contact can be reached on.
conversations(int $contactId) List the contact's conversations.
labels(int $contactId) / addLabels(int $contactId, array $labels) List / set the contact's labels.
conversations() create(string $sourceId, int $inboxId, array $extra = []) Create a conversation for a contact-inbox.
list(array $filters = []) List conversations (filters: status, assignee_type, inbox_id, team_id, labels, q, page).
show(int $conversationId) Fetch a single conversation.
update(int $conversationId, array $attributes) Update a conversation (priority, additional_attributes, …).
meta(array $query = []) Conversation counts (mine / unassigned / assigned / all).
filter(array $payload) Advanced conversation filtering (query-builder payload).
toggleStatus(int $conversationId, string $status) Set status: open, pending, resolved or snoozed.
togglePriority(int $conversationId, string $priority) Set priority: urgent/high/medium/low/none.
assign(int $conversationId, ?int $assigneeId, ?int $teamId) Assign to an agent and/or team.
setCustomAttributes(int $conversationId, array $customAttributes) Set conversation custom attributes.
labels(int $conversationId) / addLabels(int $conversationId, array $labels) List / set conversation labels.
toggleTyping(int $conversationId, string $typingStatus) Toggle agent typing indicator (on/off).
inboxes() list() / get(int $inboxId) List inboxes / fetch one.
create(array $attributes) / update(int $inboxId, array $attributes) Create / update an inbox.
agentBot(int $inboxId) / setAgentBot(int $inboxId, ?int $agentBotId) Show / assign (or detach) the inbox agent-bot.
members(int $inboxId) List inbox agent members.
addMembers / updateMembers / removeMembers (int $inboxId, array $userIds) Manage inbox agent members.
messages() create(int $conversationId, string $content, string $messageType = 'incoming', array $extra = []) Post a message (incoming or outgoing).
list(int $conversationId, array $query = []) List messages of a conversation.
delete(int $conversationId, int $messageId) Delete a message.
agents() list / create / update / delete Manage account agents.
agentBots() list / get / create / update / delete Manage agent bots.
teams() list / get / create / update / delete Manage teams.
members / addMembers / updateMembers / removeMembers Manage team agents.
labels() list / get / create / update / delete Manage the label catalogue.
cannedResponses() list / create / update / delete Manage canned responses.
customAttributeDefinitions() list / get / create / update / delete Manage custom attribute definitions.
customFilters() list / get / create / update / delete Manage saved custom filters.
account() get() / update(array $attributes) Read / update the current account.
profile() get() / update(array $profile) Read / update the token owner's profile.
automationRules() list / get / create / update / delete Manage automation rules.
webhooks() list / create / update / delete Manage account webhooks.
integrations() apps() / createHook / updateHook / deleteHook List integration apps and manage hooks.
reports() account / summary / conversations / firstResponseTimeDistribution / inboxLabelMatrix / outgoingMessagesCount Metrics & reports (v2 endpoints).
helpCenter() listPortals / createPortal / updatePortal / createCategory / createArticle Manage Help Center portals, categories & articles.
platformAccounts() create / get / update / delete / users / createUser / deleteUser Platform API — provision accounts and account-user links.
platformAgentBots() list / get / create / update / delete Platform API — installation-wide agent bots.
platformUsers() create / get / update / delete / login Platform API — provision users; login returns an SSO link.
client() inbox() Read inbox info (health check).
createContact(array $attributes) Upsert a contact → returns source_id.
getContact(string $sourceId) Fetch a contact by source_id.
updateContact(string $sourceId, array $attributes) Update a contact (name / custom attributes).
createConversation(string $sourceId, array $extra = []) Open a conversation for the contact.
listConversations(string $sourceId) List the contact's conversations.
getConversation(string $sourceId, int $conversationId) Fetch one conversation of the contact.
createMessage(string $sourceId, int $conversationId, string $content, array $extra = []) Push an incoming message.
createMessageWithAttachments(string $sourceId, int $conversationId, ?string $content, array $attachments) Push an incoming message with file attachments (multipart).
listMessages(string $sourceId, int $conversationId) List the messages of a conversation.
updateMessage(string $sourceId, int $conversationId, int $messageId, array $attributes) Update a message (e.g. CSAT response).
identifierHash(string $contactIdentifier) HMAC hash for identity validation.

See the Chatwoot Application API reference for the full set of accepted attributes.

Error handling

Non-2xx responses and transport failures are wrapped in Sashalenz\ChatwootApi\Exceptions\ChatwootApiException. Requests automatically retry transient failures (2 retries, 200 ms apart) with a 15 s timeout.

Testing

Changelog

Please see the commit history for changes.

Contributing

Pull requests are welcome. Please make sure composer test, composer analyse and composer format-test pass before submitting.

Security

If you discover a security issue, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see the License File for more information.


All versions of chatwoot-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/config Version ^11.0||^12.0||^13.0
illuminate/contracts Version ^11.0||^12.0||^13.0
illuminate/http Version ^11.0||^12.0||^13.0
illuminate/support Version ^11.0||^12.0||^13.0
spatie/laravel-data Version ^4.4
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sashalenz/chatwoot-api contains the following files

Loading the files please wait ...