> For the complete documentation index, see [llms.txt](https://doc.var-fivem.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.var-fivem.com/coins-shop/configuration/export.md).

# Export

## Public exports

All exports are server-side and live in `server/exports.lua`. They can be called from any other resource on your server.

### AddCoins

Add coins to a player's account.

```lua
exports['Var-Coins-Shop']:AddCoins(identifier, 500, {
  actor = "admin",
  reason = "event_reward"
})
```

| Argument     | Type   | Description                                          |
| ------------ | ------ | ---------------------------------------------------- |
| `identifier` | string | Any accepted identifier (see below)                  |
| `amount`     | number | Amount of coins to add                               |
| `context`    | table? | Optional metadata logged in `coins_shop_balance_log` |

**Returns:** new balance (number).

### RemoveCoins

```lua
exports['Var-Coins-Shop']:RemoveCoins(identifier, 100, { reason = "penalty" })
```

Same signature as `AddCoins`. Returns the new balance.

### GetCoins

```lua
local coins = exports['Var-Coins-Shop']:GetCoins(identifier)
```

**Returns:** current balance (number).

### GetAccount

Returns the full account row: balance, locale, total spent, loyalty tier, etc.

```lua
local account = exports['Var-Coins-Shop']:GetAccount(identifier)
-- { coins, locale, total_spent, tier, created_at, ... }
```

### RefreshPlayer

Force the UI of a connected player to resync. Useful after an external `AddCoins` call when you want the in-game shop to update immediately.

```lua
exports['Var-Coins-Shop']:RefreshPlayer(playerSourceId)
```

| Argument         | Type   | Description                           |
| ---------------- | ------ | ------------------------------------- |
| `playerSourceId` | number | The server ID of the connected player |

### RegisterSubscriptionPlans

Register subscription plans dynamically (useful if you generate them from another data source).

```lua
exports['Var-Coins-Shop']:RegisterSubscriptionPlans({
  {
    id = "sub_vip",
    name = "VIP",
    price = 1000,
    billing = "monthly",
    durationDays = 30,
    perks = { "Priority queue", "5% discount" }
  }
})
```

### GetSubscriptionState

Read a player's current subscription state.

```lua
local state = exports['Var-Coins-Shop']:GetSubscriptionState(identifier)
-- { active = true, planId = "sub_vip", expiresAt = ..., ... }
```

### Accepted identifier formats

`identifier` arguments accept any of the following formats. They are normalized internally by `Accounts.resolveIdentifierInput`:

* Online server ID: `42`
* Cfx.re identifiers: `steam:110000xxxx`, `license:xxx`, `license2:xxx`, `fivem:xxx`, `discord:xxx`
* Any registered alias for an offline player
* Raw string fallback (treated as the canonical identifier)

The default lookup priority is configurable in `shared/config.lua`:

```lua
Framework = {
  IdentifierPriority = { "license2", "license", "fivem", "discord", "steam" }
}
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://doc.var-fivem.com/coins-shop/configuration/export.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
