> For the complete documentation index, see [llms.txt](https://docs.cuxial.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cuxial.com/scripts/core/cuxial-license/developers.md).

# Exports & events

Public API of Cuxial License: exports and events to open the panels and manage licences from other resources.

Open the panels from your own targets or items, and read, issue, revoke and restore licences from an MDT or any other resource.

## Client exports

### openGetCard

Opens the licence office store, the same one the NPC opens.

```lua
exports.cuxial_license:openGetCard()
```

### openJobManager

Opens the issuing panel. Cards to issue, issued licences and nearby players are only delivered to staff and to players in `authorizedJobs` or `revokeJobs`; restrict who reaches the export in your own resource.

```lua
exports.cuxial_license:openJobManager(data)
```

| Parameter         | Type   | Description                       |
| ----------------- | ------ | --------------------------------- |
| `data.heading`    | string | Title of the panel.               |
| `data.subHeading` | string | Text under the title.             |
| `data.logo`       | string | Image shown next to the job name. |
| `data.jobName`    | string | Job name shown in the panel.      |

```lua
exports.cuxial_license:openJobManager({
    heading = 'Police Department',
    subHeading = 'Licensing desk',
    logo = 'https://example.com/logo.png',
    jobName = 'police',
})
```

### openIdCheck

Opens the ID check panel. Scanning only returns data to players in `authorizedJobs`.

```lua
exports.cuxial_license:openIdCheck()
```

### openFakeId

Opens the fake ID generator. This export is the only way to open it; restrict access in your own resource.

```lua
exports.cuxial_license:openFakeId(data)
```

| Parameter         | Type   | Description                     |
| ----------------- | ------ | ------------------------------- |
| `data.heading`    | string | Title of the panel. Optional.   |
| `data.subHeading` | string | Text under the title. Optional. |

```lua
exports.ox_target:addBoxZone({
    coords = vec3(0.0, 0.0, 0.0),
    size = vec3(1.0, 1.0, 2.0),
    options = {
        {
            label = 'Forge a document',
            onSelect = function()
                exports.cuxial_license:openFakeId({ heading = 'Forger' })
            end,
        },
    },
})
```

## Item exports

These are the exports the inventory items point to. You do not call them yourself; you reference them in the item definition, as shown in [Installation](/scripts/core/cuxial-license/installation.md#add-the-items).

| Export                          | Item                                                 | Shows                                  |
| ------------------------------- | ---------------------------------------------------- | -------------------------------------- |
| `cuxial_license.useLicenseCard` | `license_card` and any item name set in the designer | A card issued by the script            |
| `cuxial_license.useFakeId`      | `fake_id`                                            | A card made with the fake ID generator |
| `cuxial_license.useJobBadge`    | `job_badge`                                          | A job badge                            |
| `cuxial_license.useWorkerId`    | `worker_id`                                          | A worker ID                            |

### Badge and worker ID items

The script shows `job_badge` and `worker_id`, but does not hand them out. Give the item from your own resource with this metadata:

| Item        | Metadata                                                                                                                                                                                        |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `job_badge` | `layout` (`'portrait'` by default), `heading`, `logo`, `playerPhoto`, `firstname`, `rank`, `issueDate`, `expireDate`, `isRevoked`, `colors` (`body`, `bodyText`, `footer`, `footerText` in hex) |
| `worker_id` | `name`, `sex`, `job`, `rank`, `logo`, `isRevoked`                                                                                                                                               |

```lua
exports.ox_inventory:AddItem(source, 'worker_id', 1, {
    name = 'John Doe',
    sex = 'Male',
    job = 'Mechanic',
    rank = 'Apprentice',
    logo = 'https://example.com/logo.png',
})
```

## Server exports

### GetPlayerLicenses

Returns the licences of a character that are not revoked. Expired ones are included.

```lua
exports.cuxial_license:GetPlayerLicenses(citizenId)
```

| Parameter   | Type   | Description           |
| ----------- | ------ | --------------------- |
| `citizenId` | string | Character identifier. |

**Returns:** `table[]`. Each entry has `id` (licence id), `type` (id of the card design), `label` (title of the card), `issueDate` and `expireDate` (`'YYYY-MM-DD'`, or empty when it has no expiry). An empty table if there are none.

```lua
local licenses = exports.cuxial_license:GetPlayerLicenses(citizenId)
for _, license in ipairs(licenses) do
    print(license.label, license.expireDate)
end
```

### GetAvailableCards

Returns every card design created on the server.

```lua
exports.cuxial_license:GetAvailableCards()
```

**Returns:** `table[]`. Each entry has `type` (id of the card design), `label`, `restrictJob` (boolean) and `restrictJobNames` (list of job names).

### IssueLicense

Issues a card to a character, online or offline. It does not check permissions: do it in your resource before calling.

```lua
exports.cuxial_license:IssueLicense(issuerSrc, cardId, citizenId, opts)
```

| Parameter         | Type          | Description                                                                                           |
| ----------------- | ------------- | ----------------------------------------------------------------------------------------------------- |
| `issuerSrc`       | number \| nil | Server id of the player who issues. `nil` records the issuer as `SYSTEM`.                             |
| `cardId`          | string        | Id of the card design, the `type` from `GetAvailableCards`.                                           |
| `citizenId`       | string        | Character who receives it.                                                                            |
| `opts.expireDate` | string        | Expiry date as `'YYYY-MM-DD'`. Omit for no expiry.                                                    |
| `opts.metadata`   | table         | Extra data stored with the licence. `playerPhoto` (an `https` link) is used as the photo of the card. |

**Returns:** `table`. `{ success = true, id = licenseId }`, or `{ success = false, reason = 'invalid_args' }` / `{ success = false, reason = 'card_not_found' }`.

If the character is online they receive the item and a notification. If they are offline only the record is saved, with no item. If the character already holds that card, the existing record is updated and its id returned.

```lua
local result = exports.cuxial_license:IssueLicense(source, cardId, citizenId, {
    expireDate = '2027-01-01',
})

if result.success then
    print('Issued', result.id)
end
```

### RevokeLicense

```lua
exports.cuxial_license:RevokeLicense(licenseId)
```

| Parameter   | Type   | Description                                          |
| ----------- | ------ | ---------------------------------------------------- |
| `licenseId` | string | The `id` from `GetPlayerLicenses` or `IssueLicense`. |

**Returns:** `boolean`. `true` when the licence was revoked; `false` if it does not exist or was already revoked.

### RestoreLicense

```lua
exports.cuxial_license:RestoreLicense(licenseId)
```

**Returns:** `boolean`. `true` when a revoked licence became active again.

### GetCardTemplate

Returns the design of a card with its fields left blank, for a resource that wants to draw the card and fill it in itself.

```lua
exports.cuxial_license:GetCardTemplate(query)
```

| Parameter    | Type   | Description                                                      |
| ------------ | ------ | ---------------------------------------------------------------- |
| `query.id`   | string | Id of the card design.                                           |
| `query.item` | string | Alternative to `id`: the first card whose item name is this one. |

**Returns:** `table | nil`. `id`, `display` (layout, colours, logo, heading, footer and the list of fields) and `fields` (the keys a card can be filled with: `first_name`, `last_name`, `citizenid`, `birthdate`, `gender`, `nationality`, `issue_date`, `expiry_date`). `nil` when no card matches.

```lua
local template = exports.cuxial_license:GetCardTemplate({ item = 'license_card' })
```

## Events

### cuxial\_license:client:openPanel

Opens a panel on a player from the server.

```lua
TriggerClientEvent('cuxial_license:client:openPanel', source, panel, data)
```

| Parameter | Type   | Description                                                                                                                    |
| --------- | ------ | ------------------------------------------------------------------------------------------------------------------------------ |
| `panel`   | string | `'admin'` (management), `'purchase'` (store), `'manager'` (issuing), `'idcheck'` (ID check) or `'fakeid'` (fake ID generator). |
| `data`    | table  | Same table as the matching client export. For `'idcheck'`, `{ scanId = serverId }` scans that player on open.                  |

```lua
TriggerClientEvent('cuxial_license:client:openPanel', source, 'idcheck', { scanId = targetId })
```

{% hint style="info" %}
Opening a panel gives no extra rights. Every action inside is checked again on the server against `admin.permission` and `authorizedJobs`.
{% endhint %}


---

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.cuxial.com/scripts/core/cuxial-license/developers.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
