All examples use the Application API with user access token.
---
1. Create a Contact
Create a new contact in your account:
Write to /tmp/chatwoot_request.json:
```json
{
"inbox_id": 1,
"name": "John Doe",
"email": "john@example.com",
"phone_number": "+1234567890",
"identifier": "customer_123",
"additional_attributes": {
"company": "Acme Inc",
"plan": "premium"
}
}
```
Then run:
```bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/contacts" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'
```
---
2. Search Contacts
Search contacts by email, phone, or name:
```bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/contacts/search?q=john@example.com" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.payload[] | {id, name, email}'
```
---
3. Get Contact Details
Get a specific contact by ID. Replace with the actual contact ID from the "Search Contacts" or "Create a Contact" response:
```bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/contacts/" -H "api_access_token: ${CHATWOOT_API_TOKEN}"'
```
---
4. Create a Conversation
Create a new conversation with a contact:
Write to /tmp/chatwoot_request.json:
```json
{
"source_id": "api_conversation_123",
"inbox_id": 1,
"contact_id": 123,
"status": "open",
"message": {
"content": "Hello! How can I help you today?"
}
}
```
Then run:
```bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'
```
---
5. List Conversations
Get all conversations with optional filters:
```bash
# List open conversations
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations?status=open" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.data.payload[] | {id, status, contact: .meta.sender.name}'
```
---
6. Get Conversation Details
Get details of a specific conversation. Replace with the actual conversation ID from the "List Conversations" or "Create a Conversation" response:
```bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/" -H "api_access_token: ${CHATWOOT_API_TOKEN}"'
```
---
7. Send a Message
Send a message in a conversation. Replace with the actual conversation ID from the "List Conversations" response:
Write to /tmp/chatwoot_request.json:
```json
{
"content": "Thank you for contacting us! Let me help you with that.",
"message_type": "outgoing",
"private": false
}
```
Then run:
```bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations//messages" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'
```
---
8. Add Private Note
Add an internal note (not visible to customer). Replace with the actual conversation ID from the "List Conversations" response:
Write to /tmp/chatwoot_request.json:
```json
{
"content": "Customer is a VIP - handle with priority",
"message_type": "outgoing",
"private": true
}
```
Then run:
```bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations//messages" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'
```
---
9. Assign Conversation
Assign a conversation to an agent. Replace with the actual conversation ID and with the agent ID from the "List Agents" response:
Write to /tmp/chatwoot_request.json:
```json
{
"assignee_id": 1
}
```
Then run:
```bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations//assignments" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'
```
---
10. Update Conversation Status
Change conversation status (open, resolved, pending). Replace with the actual conversation ID from the "List Conversations" response:
Write to /tmp/chatwoot_request.json:
```json
{
"status": "resolved"
}
```
Then run:
```bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations//toggle_status" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'
```
---
11. List Agents
Get all agents in the account:
```bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/agents" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.[] | {id, name, email, role, availability_status}'
```
---
12. List Inboxes
Get all inboxes (channels) in the account:
```bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/inboxes" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.payload[] | {id, name, channel_type}'
```
---
13. Get Conversation Counts
Get counts by status for dashboard:
```bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/meta" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.meta.all_count, .meta.mine_count'
```
---