API Documentation

Integrate SafariChat's AI-powered messaging capabilities into your applications with our comprehensive REST API.

v2.1

Overview

The SafariChat API provides programmatic access to our AI sales automation platform. You can send messages, manage contacts, analyze conversations, and integrate with your existing systems. Our API is RESTful, uses JSON for data exchange, and requires API key authentication.

Base URL: https://api.safarichat.com/v2

Authentication

SafariChat API uses API keys for authentication. You can generate and manage your API keys from your dashboard.

🔑 Authentication Header

Include your API key in the Authorization header of every request:

Request Header
Authorization: Bearer YOUR_API_KEY Content-Type: application/json

Getting Your API Key

  1. Log in to your SafariChat dashboard
  2. Navigate to Settings → API Keys
  3. Click "Generate New API Key"
  4. Copy and securely store your API key
  5. Use the key in your Authorization header

Quick Start

Get started with the SafariChat API in minutes. Here's a simple example to send your first AI-powered message:

Example: Send a Message
curl -X POST "https://api.safarichat.com/v2/messages/send" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "to": "+255123456789", "message": "Hello! This is an AI-powered message from SafariChat.", "ai_enabled": true }'
Response:
{ "success": true, "message_id": "msg_abc123def456", "status": "sent", "ai_processed": true, "timestamp": "2024-12-20T10:30:00Z" }

Core Endpoints

Here are the main API endpoints available in SafariChat API v2.1:

POST /messages/send

Send an AI-powered message to a contact

Parameter Type Required Description
to string Required Recipient phone number (E.164 format)
message string Required Message content
ai_enabled boolean Optional Enable AI processing (default: true)
GET /messages

Retrieve message history and conversation data

Parameter Type Required Description
contact string Optional Filter by contact phone number
limit integer Optional Number of messages (max: 100)
offset integer Optional Pagination offset
POST /contacts

Add a new contact to your address book

Parameter Type Required Description
phone string Required Contact phone number
name string Optional Contact full name
tags array Optional Contact tags for organization
GET /analytics/summary

Get conversation analytics and performance metrics

Parameter Type Required Description
period string Optional Time period (day, week, month)
start_date date Optional Start date (ISO 8601 format)
end_date date Optional End date (ISO 8601 format)

Webhooks

Webhooks allow you to receive real-time notifications about events in your SafariChat account. Configure webhook endpoints to receive instant updates about message deliveries, AI responses, and conversation events.

Webhook Configuration
curl -X POST "https://api.safarichat.com/v2/webhooks" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://yourapp.com/webhook/safarichat", "events": ["message.received", "message.sent", "ai.response"], "active": true }'

Available Events:

  • message.received - New message received from contact
  • message.sent - Message successfully sent
  • ai.response - AI has generated a response
  • contact.created - New contact added
  • conversation.started - New conversation initiated

Error Handling

The SafariChat API uses conventional HTTP response codes to indicate success or failure. Error responses include detailed error messages to help you debug issues.

HTTP Code Error Type Description
200 Success Request completed successfully
400 Bad Request Invalid request parameters
401 Unauthorized Invalid or missing API key
429 Rate Limited Too many requests
500 Server Error Internal server error
Error Response Format:
{ "success": false, "error": { "code": "INVALID_PHONE", "message": "Phone number format is invalid", "details": "Phone number must be in E.164 format (+255xxxxxxxxx)" } }

Rate Limits

To ensure fair usage and optimal performance, the SafariChat API implements rate limiting:

Plan Rate Limit Burst Limit
Starter 100 requests/minute 200 requests/minute
Professional 500 requests/minute 1000 requests/minute
Enterprise 2000 requests/minute 5000 requests/minute

Rate limit headers are included in every response:

X-RateLimit-Limit: 500 X-RateLimit-Remaining: 487 X-RateLimit-Reset: 1609459200

SDKs & Libraries

We provide official SDKs and libraries to make integration easier:

🐘 PHP SDK

Official PHP library for Laravel and other PHP frameworks

composer require safarichat/php-sdk

🟢 Node.js SDK

JavaScript/TypeScript SDK for Node.js applications

npm install safarichat-node

🐍 Python SDK

Python library for Django and Flask applications

pip install safarichat

☕ Java SDK

Java library for Spring Boot and other frameworks

implementation 'com.safarichat:java-sdk:2.1.0'
💡 Need Help?

Check out our GitHub repositories for code examples, tutorials, and community support.