> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fascripts.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API reference

> Call FA Minigames client exports and handle their result tables safely.

All exports run synchronously from the calling client Lua coroutine. Call one export, wait for its returned table, then continue your gameplay flow.

```lua theme={null}
local result = exports.fa_minigames:Skillbar({
    difficulty = 3,
    rounds = 4,
    timeout = 30000
})

if result.success then
    -- Ask your server to validate and complete the action.
else
    print(('Minigame stopped: %s'):format(result.reason))
end
```

## Standard games

`Skillbar`, `Sequence`, `Lockpick`, `Pattern`, `Wires`, `Circuit`, `Fingerprint`, and `Terminal` return:

```lua theme={null}
{
    success = boolean,
    reason = 'completed' | 'failed' | 'cancelled' | 'timeout' | 'busy',
    data = table | nil
}
```

`data` may include game-specific completion details. Treat it as display or diagnostic information, not authoritative state.

## Drill

```lua theme={null}
local result = exports.fa_minigames:Drill('medium')
```

`Drill` returns `success` and `reason`. It accepts a difficulty preset or an options table.

## Keypad

```lua theme={null}
local result = exports.fa_minigames:Keypad({
    title = 'Safe',
    timeout = 30000
})
```

Without a validator, Keypad returns the submitted four-digit `code`. It also returns `submitted`, `success`, `validated`, `reason`, and an optional `message`.

<Warning>
  Do not send a correct or secret code to NUI. Validate the submitted code through your server.
</Warning>

```lua theme={null}
local result = exports.fa_minigames:Keypad({
    title = 'Safe',
    timeout = 30000,
    validate = function(code)
        local response = lib.callback.await('my_resource:validateCode', false, code)

        return {
            success = response.success == true,
            close = response.success == true,
            reason = response.success and 'completed' or 'failed',
            message = response.message
        }
    end
})
```

Return `close = false` after a wrong attempt to clear the entry and keep the keypad open. Your resource and its server still own attempt counts, permissions, rewards, and every authoritative action.

## Cancel an active game

Only one FA Minigames session can run at a time. A second request returns `reason = 'busy'`.

```lua theme={null}
exports.fa_minigames:Cancel()
```

Calling `Cancel()` closes the active session and causes it to return `reason = 'cancelled'`.
