> For the complete documentation index, see [llms.txt](https://lakm.gitbook.io/helpdesk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lakm.gitbook.io/helpdesk/sdk/readme.md).

# Overview

Programmatic API of the `lakm/helpdesk-backend` Laravel package. While the [HTTP API reference](https://github.com/Lak-M/helpdesk-docs/tree/main/helpdesk-api/README.md) documents the REST endpoints, this section documents the PHP classes you can use directly from your application:

* **Actions** — single-purpose write operations (`handle(...)` methods).
* **Queries** — read operations and paginated listings (static methods).

All classes live under the `LakM\HelpdeskBackend\` namespace.

## Actions

Actions perform a single mutation, usually inside a DB transaction, and often dispatch an event when done. Instantiate them via the container or `new`:

```php
use LakM\HelpdeskBackend\Actions\Category\StoreCategoryAction;

$category = app(StoreCategoryAction::class)->handle('General');
```

Listed by domain:

* [Category actions](/helpdesk/sdk/actions/category.md)
* [Conversation actions](/helpdesk/sdk/actions/conversation.md)
* [Media actions](/helpdesk/sdk/actions/media.md)
* [Support ticket actions](/helpdesk/sdk/actions/support-ticket.md)
* [Tag actions](/helpdesk/sdk/actions/tag.md)

## Queries

Queries are static helpers that return models, collections or paginators:

```php
use LakM\HelpdeskBackend\Queries\SupportTicketQuery;

$ticket = SupportTicketQuery::findOrFail($id);
$latest = SupportTicketQuery::latest(10);
```

Listed by domain:

* [Support ticket queries](/helpdesk/sdk/queries/support-tickets.md)
* [Conversation queries](/helpdesk/sdk/queries/conversations.md)
* [Agent queries](/helpdesk/sdk/queries/agents.md)
* [Category & tag queries](/helpdesk/sdk/queries/categories-tags.md)
* [Dashboard queries](/helpdesk/sdk/queries/dashboard.md)
* [User queries](/helpdesk/sdk/queries/users.md)
* [Notification queries](/helpdesk/sdk/queries/notifications.md)

## Data objects

Actions that accept payloads use readonly DTOs from `LakM\HelpdeskBackend\Data`:

| DTO                                | Used by                                                 | Shape                                                                             |
| ---------------------------------- | ------------------------------------------------------- | --------------------------------------------------------------------------------- |
| `SupportTicketData`                | `StoreSupportTicketAction`, `UpdateSupportTicketAction` | `title`, `user_id`, `category_id`, `priority?`, `status?`, `attributes?`, `tags?` |
| `ConversationData`                 | `StoreConversationAction`, `UpdateConversationAction`   | `message`, `user_id`, `support_ticket_id?`, `seen_by?`, `is_deleted?`             |
| `DashboardFilters`                 | `DashboardQuery`                                        | dashboard filtering criteria                                                      |
| `AllowedFilterData` / `FilterData` | `Filter`, paginated queries                             | allowed filter definitions                                                        |

Build them with named arguments or `fromArray(...)`:

```php
use LakM\HelpdeskBackend\Data\SupportTicketData;

$data = SupportTicketData::fromArray([
    'title' => 'Cannot login',
    'user_id' => $user->id,
    'category_id' => $category->id,
    'priority' => 2,
    'tags' => [$tag->id],
]);
```

## Filtering, sorting and pagination

Paginated query classes accept a `Request`, a `Filter` instance and the list of allowed filters/sorts, mirroring the HTTP list endpoints:

```php
use LakM\HelpdeskBackend\Filter\Filter;
use LakM\HelpdeskBackend\Queries\SupportTicketQuery;

$paginator = SupportTicketQuery::paginate(
    request: $request,
    filter: app(Filter::class),
    allowedFilters: [],
    allowedSorts: ['title', 'created_at'],
);
```

See the [HTTP API reference](https://github.com/Lak-M/helpdesk-docs/tree/main/helpdesk-api/README.md#pagination-sorting-and-filtering) for the `page`, `rows`, `sortField`, `sortOrder` and `filters` conventions.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://lakm.gitbook.io/helpdesk/sdk/readme.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
