# Tekton Nakama Lua Server API Reference > Auto-generated from source code. For AI agents -- call these RPCs without reading Lua. ## Table of Contents 1. [Authentication & Core (core.lua)](#1-authentication--core-coreluau) 2. [Utilities (utils.lua)](#2-utilities-utilsluau) 3. [User Module (user.lua)](#3-user-module-userluau) 4. [Economy Module (economy.lua)](#4-economy-module-economyluau) 5. [Gacha Module (gacha.lua)](#5-gacha-module-gachaluau) 6. [Leaderboard Module (leaderboard.lua)](#6-leaderboard-module-leaderboardluau) 7. [Inbox/Mail Module (inbox.lua)](#7-inboxmail-module-inboxluau) 8. [Daily Rewards Module (daily_rewards.lua)](#8-daily-rewards-module-daily_rewardsluau) 9. [Admin Module (admin.lua)](#9-admin-module-adminluau) 10. [Storage Collections Reference](#10-storage-collections-reference) 11. [Leaderboard Config](#11-leaderboard-config) 12. [Error Strings Reference](#12-error-strings-reference) 13. [Permission Levels](#13-permission-levels) --- ## 1. Authentication & Core (`core.lua`) ### After-Hook: `after_authenticate_steam` | Field | Value | |---|---| | **Trigger** | `AuthenticateSteam` | | **Purpose** | On first Steam login: sets display_name from Steam username, default role to `"player"` | | **Auth** | None (internal hook) | **Behavior:** - If user has no `display_name`, sets it from `input.username` (fallback: `"SteamPlayer"`) - If user metadata has no `role`, sets `metadata.role = "player"` ### Startup (not an RPC) ``` nk.leaderboard_create("global_high_score", true, "desc", "best", nil, {}) ``` Creates native leaderboard `"global_high_score"` on module load (also created in `leaderboard.lua` -- pcall wraps both so duplicate is safe). --- ## 2. Utilities (`utils.lua`) Shared helpers used by other modules. ### Constants | Constant | Value | Purpose | |---|---|---| | `ADMIN_ROLES` | `{admin=true, moderator=true, owner=true}` | Roles with admin privileges | | `SYSTEM_USER_ID` | `"00000000-0000-0000-0000-000000000000"` | System/nil user for global storage | | `CHANNEL_TYPE_ROOM` | `1` | Nakama channel type for rooms | | `CHANNEL_TYPE_DIRECT` | `2` | Nakama channel type for DMs | | `CHANNEL_TYPE_GROUP` | `3` | Nakama channel type for groups | ### `utils.is_admin(context)` Checks if caller has admin/moderator/owner role. | Param | Type | Description | |---|---|---| | `context` | table | Nakama RPC context | **Returns:** `boolean` ### `utils.is_match_host(context, match_id)` Checks if caller is the host of a match. | Param | Type | Description | |---|---|---| | `context` | table | Nakama RPC context | | `match_id` | string | Match ID to check | **Returns:** `boolean` **Note:** Reads `match.state` and checks `state.hostUserId` against `context.user_id`. ### `utils.require_admin(context)` Errors with `"Admin privileges required"` if caller is not admin/moderator/owner. ### `utils.require_admin_or_host(context, match_id)` Errors with `"Admin or host privileges required"` if caller is neither admin nor match host. ### `utils.resolve_channel_id(channel_id)` Resolves a friendly room name (e.g. `"social_global"`) to a hashed Nakama channel ID. | Param | Type | Description | |---|---|---| | `channel_id` | string | Raw channel ID or friendly room name | **Returns:** `string` -- resolved channel ID (passes through if already hashed, i.e. contains `"."`) **Logic:** If no `"."` in value, calls `nk.channel_id_build("", name, CHANNEL_TYPE_ROOM)`. --- ## 3. User Module (`user.lua`) ### RPC: `get_user_profile` | Field | Value | |---|---| | **Function** | `user.rpc_get_user_profile` | | **Auth** | None required (can view any profile) | | **Purpose** | Get a user's public profile | **Params (JSON):** | Field | Type | Required | Default | Description | |---|---|---|---|---| | `user_id` | string | No | `context.user_id` | Target user ID | **Returns (JSON):** | Field | Type | Description | |---|---|---| | `user_id` | string | User ID | | `username` | string | Username | | `display_name` | string | Display name | | `avatar_url` | string | Avatar URL | | `create_time` | string | Account creation time | | `role` | string | Role from metadata (`"player"` default) | **Errors:** - `"Account not found"` -- user doesn't exist - `"Account banned until