> For the complete documentation index, see [llms.txt](https://titans-productions.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://titans-productions.gitbook.io/documentation/redm/scripts/mailbox/development-api/client.md).

# Client

#### Exports

API Getter Function

```lua
local MailboxAPI = exports.tp_mailbox:getAPI()
```

1. Get player telegrams.

```lua
--- @param telegrams - returns a table
local telegrams = MailboxAPI.GetPlayerTelegrams()
```

2. Get player telegram id.

```lua
--- @param telegramId - returns a string
local telegramId = MailboxAPI.GetPlayerTelegramId()
```

3. Get player the state if the player has delivery mission active or not.

```lua
--- @param hasMissionActive - returns a boolean
local hasMissionActive = MailboxAPI.HasDeliveryMissionActive()
```

4. Get the Office Index Name if the state of the player has delivery mission active.

```lua
--- @param getOfficeIndex - returns a string
local getOfficeIndex = MailboxAPI.GetDeliveryMissionOfficeIndex()
```

5. Get the entity object if the state of the player has delivery mission active.

```lua
--- @param missionEntityObject - returns a string
local missionEntityObject = MailboxAPI.GetDeliveryMissionAttachedEntityObject()
```

#### Events

* Open Mailbox NUI by a location name as parameter (Location must exist on Config.Locations).

```lua

--- @param locationName - requires the custom location name from Config.Locations.
TriggerEvent("tp_mailbox:client:openMailboxByLocationName", locationName ) -- client to client
TriggerClientEvent("tp_mailbox:client:openMailboxByLocationName", source, locationName ) -- server to client
```

To create a valid custom config location for opening through the event:

```lua
    ['custom'] = { -- Add your custom name
        Name = "Custom Office", -- Add your custom name

        Coords = {x = 0.0, y = 0.0, z = 0.0},

        City = "Your Custom Title",

        Hours = { Enabled = false, Duration = {am = 7, pm = 21} }, -- NO HOURS

        BlipData = { -- NO BLIP
            Enabled = false,
            Sprite = 1861010125,
        },

        NPCData = { -- NO NPC
            Enabled = false,
            Model = "",
            Coords = {x = 0.0, y = 0.0, z = 0.0, h = 0.0},
        },

        -- Set to true if you are using target eye for opening the mailbox office. 
        -- (!) Required an NPC Enabled, otherwise must be set to false.
        TargetEye = { Enabled = false, Script = '', Display = ''}, -- version 3.1.7 (NO TARGET EYE)

        ActionDistance = 0.0,
    },
```
