keepcloud/freshdesk-laravel
Freshdesk for Laravel
Laravel integration for the Freshdesk API v2, built on top of keepcloud/freshdesk-php-sdk.
| Package | Laravel | PHP | SDK |
|---|---|---|---|
| 2.x | 12, 13 | 8.2+ (Laravel 13: 8.3+) | ^2.0 |
| 1.x | 7, 8 | 7.2.5+ | ^1.0 |
Installation
composer require keepcloud/freshdesk-laravel
The service provider and the Freshdesk facade are registered automatically
(package auto-discovery).
Configuration
Add your credentials to .env:
FRESHDESK_API_KEY=your_api_key
FRESHDESK_DOMAIN=acme # for https://acme.freshdesk.com
# Optional (seconds)
FRESHDESK_TIMEOUT=30
FRESHDESK_CONNECT_TIMEOUT=10
To customize the config file, publish it:
php artisan vendor:publish --tag=freshdesk-config
This creates config/freshdesk.php. Any Guzzle option placed under the http
key is passed to the HTTP client (authentication cannot be overridden).
Usage
Every resource method returns the decoded JSON response as an array
(or null for empty responses such as DELETE).
use Freshdesk; // or Keepcloud\Laravel\Freshdesk\FreshdeskFacade
// Tickets
$ticket = Freshdesk::tickets()->create([
'email' => 'customer@example.com',
'subject' => 'Need help',
'description' => 'Details...',
'status' => 2,
'priority' => 1,
]);
$ticket = Freshdesk::tickets()->view($ticketId);
$tickets = Freshdesk::tickets()->all(['updated_since' => '2026-01-01']);
// Conversations
$note = Freshdesk::conversations()->note($ticketId, ['body' => 'Internal note']);
// Contacts, agents, companies, groups
$contact = Freshdesk::contacts()->update($contactId, $data);
$me = Freshdesk::agents()->current();
$company = Freshdesk::companies()->create($data);
Freshdesk::groups()->delete($groupId);
// Time entries
$entries = Freshdesk::timeEntries()->all($ticketId);
// Forums (discussions)
$category = Freshdesk::discussions()->create($data);
$forum = Freshdesk::forums()->create($categoryId, $data);
$comment = Freshdesk::comments()->create($topicId, ['body' => 'Thanks!']);
Freshdesk::topics()->monitor($topicId, $userId);
// Knowledge base (solutions)
$categories = Freshdesk::solutions()->all();
$folder = Freshdesk::folders()->create($categoryId, $data);
$article = Freshdesk::articles()->create($folderId, $data);
// Admin
$configs = Freshdesk::emailConfigs()->all();
$product = Freshdesk::products()->view($productId);
$hours = Freshdesk::businessHours()->all();
$policies = Freshdesk::slaPolicies()->all();
You can also inject the client instead of using the facade:
use Keepcloud\Laravel\Freshdesk\Api;
public function __construct(private Api $freshdesk) {}
Filtering and pagination
All GET requests accept an optional array $query parameter:
$page2 = Freshdesk::forums()->all(['page' => 2, 'per_page' => 50]);
Response headers of the last request (rate limit, Link for pagination):
$headers = Freshdesk::lastResponseHeaders();
$remaining = $headers['X-RateLimit-Remaining'][0] ?? null;
Error handling
Every failure (HTTP or network) throws Freshdesk\Exceptions\ApiException
or one of its subclasses (ValidationException, NotFoundException,
AuthenticationException, RateLimitExceededException...):
use Freshdesk\Exceptions\ApiException;
use Freshdesk\Exceptions\RateLimitExceededException;
try {
Freshdesk::tickets()->create($data);
} catch (RateLimitExceededException $e) {
$retryAfter = $e->getResponse()?->getHeaderLine('Retry-After');
} catch (ApiException $e) {
$status = $e->getStatusCode();
$errors = $e->getErrors(); // Freshdesk validation errors
}
Upgrading from 1.x
- Requires Laravel 12+ and PHP 8.2+.
- Remove the provider and alias from
config/app.php(auto-discovery handles them). - Move your credentials to
.env(FRESHDESK_API_KEY,FRESHDESK_DOMAIN). - The SDK 2.0 returns the decoded response directly; drop any use of
->results. categories()is deprecated in favour ofdiscussions().
See CHANGELOG.md and the SDK changelog.
Testing
composer test
Author
Maintained by Edison Costa (edison@keepcloud.io). Originally created by Matthew Clarkson.
References
Related Packages
Laravel package for the Freshdesk API (v2). Added laravel 8 support
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.1 | >7.2.5 | 7.*| | MIT | |
| 1.0.1 | >=7.0.0 | ^6.0 | MIT | |
| 1.0.0 | >=7.0.0 | ^6.0 | MIT |