---
title: "API reference"
manual: "Laravel-style Notification System - Slack Channel"
version: "1.0"
permalink: "https://docs.typo3.org/permalink/agencelex/notifications-slack:slack-api-reference@1.0"
source: "Reference/Index.rst"
rendered: "2026-10-16T12:40:55+00:00"
---

# API reference {#slack-api-reference}

## Public identifiers {#public-identifiers}

-   **`Lex\\Notifications\\Slack\\Channel\\SlackChannel`**

    Implements the core `ChannelInterface`. The channel name returned by
    `getName()` is `slack`. `send(object, Notification): void`
    resolves the route, calls `toSlack()` and hands the message to the
    transport. It does not return a Slack message timestamp.

-   **`Lex\\Notifications\\Slack\\Configuration\\SlackRoute`**

    Immutable destination value object with public readonly
    `transport` and `destination` properties.

-   **`Lex\\Notifications\\Slack\\Message\\SlackMessage`**

    Immutable message payload with `JsonSerializable` support.

-   **`Lex\\Notifications\\Slack\\Transport\\SlackTransport`**

    Sends an HTTPS request. `send(SlackMessage, SlackRoute): array`
    returns the Slack acknowledgement; when using the API this may
    contain Slack's `ts` and `channel` fields.

-   **`Lex\\Notifications\\Slack\\Configuration\\SlackConfiguration`**

    Reads configuration through TYPO3's extension configuration service.
    Provides `botToken()`, `namedWebhook()`, `apiEndpoint()`,
    `timeout()`, and `connectTimeout()`.

-   **`Lex\\Notifications\\Slack\\Exception\\SlackTransportException`**

    Exception carrying HTTP status, retry delay and retryability.

-   **`Lex\\Notifications\\Slack\\Domain\\Model\\Ability\\CanSendToSlack`**

    Trait declaring `toSlack(object $notifiable): SlackMessage`.

-   **`Lex\\Notifications\\Slack\\Domain\\Model\\Ability\\HasRouteNotificationForSlack`**

    Trait declaring `routeNotificationForSlack(?Notification $notification = null)`.

## SlackRoute factory methods {#slackroute-factory-methods}

| Method | Result |
| --- | --- |
| `webhook(string $url)` | Validate and store a direct webhook URL. |
| `webhookNamed(string $name)` | Store a configuration alias. |
| `api(string $channel, ?string $token = null)` | Validate and store a Slack ID. |
| `fromString(string $value)` | Interpret a direct HTTPS URL, `webhook:name` or API ID. |
| `assertWebhookUrl(string $url)` | Validate the Slack/GovSlack HTTPS URL; throws on failure. |

## SlackMessage factory and modifier methods {#slackmessage-factory-and-modifier-methods}

| Method | Purpose |
| --- | --- |
| `text(string $text)` | Create a plain-text message. |
| `fromArray(array $payload)` | Create from a permitted Slack payload array. |
| `fromJson(string $json)` | Create from Block Kit Builder JSON or a block list. |
| `fromBlockKit(BlockKitMessage $message)` | Validate and serialize a Block Kit PHP surface. |
| `withText(string $text)` | Return a copy with fallback text. |
| `withBlocks(array $blocks)` | Return a copy with blocks. |
| `withAttachments(array $attachments)` | Return a copy with legacy attachments. |
| `inThread(string $timestamp, bool $broadcast = false)` | Return a threaded message. |
| `withoutUnfurling()` | Disable link/media previews. |
| `toArray()` | Get payload array. |
| `toJson()` | Serialize message as JSON. |

Messages may not set `channel` or `token`; these are managed by the
route and transport. Unsupported message keys and structurally invalid
payloads raise `InvalidArgumentException`.

## Service registration {#service-registration}

`SlackChannel` is automatically registered by its
`#[AutoconfigureTag('notifications.channel')]` attribute. TYPO3's
`Configuration/Services.yaml` enables autowiring/autoconfiguration.
No additional manual service tagging is needed.

See [Error handling](https://docs.typo3.org/permalink/agencelex/notifications-slack:slack-errors@1.0) for exception details.
