> For the complete documentation index, see [llms.txt](https://horizon-scripts.gitbook.io/horizon-scripts-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://horizon-scripts.gitbook.io/horizon-scripts-docs/horizonphone/server-exports.md). Agents can also search and read this documentation through its [MCP server](https://horizon-scripts.gitbook.io/horizon-scripts-docs/~gitbook/mcp).

# Server Exports

Call server exports from another server resource with `exports['HorizonPhone']:ExportName(...)`.

## GeneratePhoneNumber

Generates a unique number and passes it to the callback.

```lua
exports['HorizonPhone']:GeneratePhoneNumber(function(number)
    print(number)
end)
```

## SendAutomaticMessage

Sends a message to a player or phone target.

| Argument    | Type          | Description                   |
| ----------- | ------------- | ----------------------------- |
| `target`    | number/string | Player source or phone target |
| `options`   | table         | Message and sender data       |
| `callback?` | function      | Receives an `ok` result       |

Useful options include `text`, `body`, `content`, `attachment`, `location`, `locationRequest`, `cash`, `from` and `sender`.

```lua
exports['HorizonPhone']:SendAutomaticMessage(target, {
    text = 'Your vehicle is ready.',
    from = { name = 'Mechanic', phone = '5550100' }
}, function(result)
    print(result.ok)
end)
```

Alias: `SendAutoMessage`.

## SendServiceMessage

Sends a message with a registered service identity.

```lua
exports['HorizonPhone']:SendServiceMessage(target, {
    service = 'mechanic',
    text = 'Your vehicle is ready.'
}, function(result)
    print(result.ok)
end)
```

Alias: `SendServiceAutoMessage`.

## StartServiceCall

Starts a call with a registered service identity.

```lua
exports['HorizonPhone']:StartServiceCall(target, {
    service = 'mechanic'
}, function(result)
    print(result.ok)
end)
```

Alias: `CallService`.

## RegisterService

Registers a service.

| Argument  | Type  | Description        |
| --------- | ----- | ------------------ |
| `options` | table | Service definition |

The definition may include `id`, `job`, `label`, `avatar`, `phone`, `mode` and receiver settings.

```lua
local result = exports['HorizonPhone']:RegisterService({
    id = 'mechanic',
    job = 'mechanic',
    label = 'Mechanic',
    avatar = './assets/images/services-mechanic.webp'
})
print(result.ok)
```

Alias: `CreateService`.

## UnregisterService

Removes a service by id.

```lua
exports['HorizonPhone']:UnregisterService('mechanic')
```

## SetServiceReceivers

Sets custom receivers for a service.

```lua
exports['HorizonPhone']:SetServiceReceivers('mechanic', {
    { source = 12 },
    { source = 24 }
})
```

## StartAutomaticCall

Starts an automatic call.

| Argument    | Type          | Description                   |
| ----------- | ------------- | ----------------------------- |
| `target`    | number/string | Player source or phone target |
| `options`   | table         | Call and sender data          |
| `callback?` | function      | Receives an `ok` result       |

```lua
exports['HorizonPhone']:StartAutomaticCall(target, {
    from = { name = 'Dispatch', phone = '5550100' }
}, function(result)
    print(result.ok)
end)
```

Aliases: `CreateAutomaticCall`.

## RegisterVirtualNumber

Registers a number owned by the calling resource.

```lua
exports['HorizonPhone']:RegisterVirtualNumber('911', {
    onDialExport = 'OnEmergencyDial',
    onStatusExport = 'OnEmergencyCallStatus'
})
```

## UnregisterVirtualNumber

Removes one virtual number owned by the calling resource.

```lua
exports['HorizonPhone']:UnregisterVirtualNumber('911')
```

## UnregisterVirtualNumbers

Removes all virtual numbers owned by the calling resource.

```lua
exports['HorizonPhone']:UnregisterVirtualNumbers()
```

## NotifyBankPayment

Sends a bank-payment notification.

| Argument          | Type   | Description      |
| ----------------- | ------ | ---------------- |
| `targetSource`    | number | Player source    |
| `amount`          | number | Payment amount   |
| `sender?`         | string | Displayed sender |
| `notificationId?` | string | Deduplication id |

```lua
exports['HorizonPhone']:NotifyBankPayment(source, 2500, 'City Bank', 'invoice-42')
```

## Wallpaper policy exports

```lua
exports['HorizonPhone']:RegisterWallpaperPolicy({
    id = 'event-wallpaper',
    label = 'City Event',
    locked = true,
    gradient = 'linear-gradient(135deg, #073d91 0%, #00aef0 100%)',
    timeColor = '#ffffff',
    timeWeight = 700
})

exports['HorizonPhone']:GetWallpaperPolicy()
exports['HorizonPhone']:UnregisterWallpaperPolicy()
```

A policy is owned by the resource that registered it.
