# Notifications

Send notifications to a player from the server side.

## SendNotify

```lua
KOJA.Server.SendNotify(data)
```

| Field    | Type      | Description                                   |
| -------- | --------- | --------------------------------------------- |
| `source` | `number`  | Player server ID                              |
| `type`   | `string?` | `"success"`, `"error"`, `"info"`, `"warning"` |
| `title`  | `string?` | Notification title                            |
| `desc`   | `string`  | Notification body text                        |
| `time`   | `number?` | Duration in milliseconds                      |
| `icon`   | `string?` | Icon name (backend-specific)                  |
| `color`  | `string?` | Accent colour (backend-specific)              |

The backend used is determined by `Config.Notify` — the same setting as the client.

## Examples

```lua
-- Success
KOJA.Server.SendNotify({
    source = source,
    type   = 'success',
    title  = 'Job Completed',
    desc   = 'You received $500.',
    time   = 5000,
})

-- Error
KOJA.Server.SendNotify({
    source = source,
    type   = 'error',
    desc   = 'You do not have enough money.',
})

-- Info
KOJA.Server.SendNotify({
    source = source,
    type   = 'info',
    title  = 'Server',
    desc   = 'Maintenance in 5 minutes.',
    time   = 10000,
})
```

## Notify all players

koja-lib does not expose a "broadcast" helper. Use a standard server event:

```lua
-- Notify every connected player
for _, playerId in ipairs(KOJA.Server.GetPlayers()) do
    KOJA.Server.SendNotify({
        source = playerId,
        type   = 'warning',
        desc   = 'Server restart in 10 minutes.',
        time   = 8000,
    })
end
```

## Backends

| Config.Notify | Backend                          |
| ------------- | -------------------------------- |
| `"esx"`       | ESX `showNotification`           |
| `"qb"`        | QBCore `QBCore.Functions.Notify` |
| `"ox"`        | `exports.ox_lib:notify`          |
| `"lib"`       | koja-lib built-in notification   |

## Related pages

- [Police](/koja-lib/api-reference/server-api/police) — Functions for checking how many police officers are online.
- [Callbacks](/koja-lib/api-reference/server-api/callbacks) — The callback system allows server scripts to handle requests from clients and vice versa.
- [Licenses](/koja-lib/api-reference/server-api/licenses) — Check whether a player holds a specific driving or skill license.
- [Money](/koja-lib/api-reference/server-api/money) — Functions for reading and modifying a player's money on the server.
- [Inventory](/koja-lib/api-reference/server-api/inventory) — Server-side inventory functions.
- [Player](/koja-lib/api-reference/server-api/player) — Functions for reading player information on the server.
- [Server API](/koja-lib/api-reference/server-api) — back to the section overview
