instakit / instachat-laravel-sdk
A clean, Laravel-native SDK for the InstaChat service.
1.0.0
2026-07-02 17:55 UTC
Requires
- php: ^8.2
- illuminate/http: ^10.0 || ^11.0 || ^12.0
- illuminate/support: ^10.0 || ^11.0 || ^12.0
Requires (Dev)
- orchestra/testbench: ^8.0 || ^9.0 || ^10.0
- phpunit/phpunit: ^10.0 || ^11.0
This package is auto-updated.
Last update: 2026-07-02 15:04:41 UTC
README
A clean, Laravel-native SDK for integrating with the InstaChat service.
Installation
You can install the package via composer:
composer require instakit/instachat-laravel-sdk
Configuration
Publish the configuration file:
php artisan vendor:publish --tag="instachat-config"
This will create a config/instachat.php file. You can configure it using the following environment variables in your .env:
INSTACHAT_BASE_URL=http://localhost:8005
INSTACHAT_APP_TOKEN=your-s2s-app-token
Basic Usage
User Token Minting (S2S)
Mint a JWT for a specific end-user:
use Instakit\InstachatSdk\Facades\Instachat;
$tokenResponse = Instachat::users()->mintToken(
extUserId: 'user-123',
displayName: 'Alice Smith',
avatarUrl: 'https://avatar.host/alice.jpg' // optional
);
echo $tokenResponse->token; // JWT Token
Room Management
Create direct or group rooms, and manage memberships:
// Create a group room
$room = Instachat::rooms()->create(
type: 'group',
members: ['user-123', 'user-456'],
metadata: ['project_id' => 'abc-789']
);
// Add a member
Instachat::rooms()->addMember($room->roomId, 'user-789');
// Remove a member
Instachat::rooms()->removeMember($room->roomId, 'user-456');
Message History
Retrieve message history with keyset cursor pagination:
$history = Instachat::messages()->list(
roomId: $roomId,
cursor: null, // next_cursor string for pagination
limit: 50
);
foreach ($history->data as $message) {
echo $message->content;
}
Attachment Uploads
Upload files into a room's context:
$attachment = Instachat::attachments()->upload(
roomId: $roomId,
filePath: '/absolute/path/to/document.pdf'
);
echo $attachment->url;
Running Tests
To run the package's integration test suite:
composer install
./vendor/bin/phpunit