> For the complete documentation index, see [llms.txt](https://docs.hungquan99.lol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hungquan99.lol/macro-documentation/hq99-macros.md).

# HQ99 Macros

Two build-time macros for startup guards and hidden-URL HTTP requests.

HQ99 macros are markers you write in your Lua source. When you create a build, HQ99 replaces each `HQ99_*` marker with generated code **before** your script is obfuscated, so macros are protected like the rest of your code. Macros follow a few simple rules:

* Write each macro exactly as shown on this page.
* A marker inside a **string or comment** is never expanded.
* Source with **no markers** builds unchanged, so macros are opt-in.

## Quick reference

| Macro                                         | Shape                                      | Purpose                                                 |
| --------------------------------------------- | ------------------------------------------ | ------------------------------------------------------- |
| [`HQ99_INIT`](#hq99_init)                     | `HQ99_INIT(function() ... end)`            | Run checks before your script. Return `false` to abort. |
| [`HQ99_SECURE_REQUEST`](#hq99_secure_request) | `local res = HQ99_SECURE_REQUEST({ ... })` | Send an HTTP request without exposing the real URL.     |

## HQ99\_INIT

Runs a function when the script starts, before the rest of your code. If the function returns `false`, the script **stops**. Anything else (`nil`, `true`, nothing) lets it continue.

```lua
HQ99_INIT(function()
    if game.PlaceId ~= 1234567890 then
        warn("This script is for a different game.")
        return false -- stop the script
    end
end)

-- Your script continues here only if the check passed.
```

* Several `HQ99_INIT` hooks run **in the order you wrote them**.
* It is a statement, so you can't assign its result to a variable.

{% hint style="warning" %}
Put every `HQ99_INIT` at the **top** of your source. Anything written above it has already run.
{% endhint %}

{% hint style="danger" %}
**Don't:**

* use it as a value. `local ok = HQ99_INIT(function() ... end)` or using it inside an expression doesn't work, because it is a statement.
* return `nil`, `true` or nothing and expect the script to stop. Only an explicit `return false` aborts.
* put it below the code you want to guard. It expands in place, so that code has already run.
* expect your hooks to be reordered. There is no hoisting, so they run exactly where you wrote them.
* write the marker inside a string or comment. It is never expanded there.
  {% endhint %}

## HQ99\_SECURE\_REQUEST

Sends an HTTP request where the **real URL and method never exist in the client**. At build time HQ99 moves them to the server. At runtime the client only sends a reference id, and the HQ99 server makes the real request.

{% hint style="success" %}
An executor's HTTP spy only sees a request to the HQ99 proxy, never your real endpoint.
{% endhint %}

```lua
local res = HQ99_SECURE_REQUEST({
    Url     = "https://api.example.com/v1/verify",
    Method  = "POST",
    Headers = { ["Content-Type"] = "application/json" },
    Body    = HttpService:JSONEncode({ userId = game.Players.LocalPlayer.UserId }),
})

if res.Success and res.StatusCode == 200 then
    local data = HttpService:JSONDecode(res.Body)
end
```

### Fields

Only these four fields are allowed.

| Field     | Required | Rule                                                                                |
| --------- | -------- | ----------------------------------------------------------------------------------- |
| `Url`     | Yes      | A **string literal**. Must be `https://` and a public host.                         |
| `Method`  | Yes      | A **string literal**: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD` or `OPTIONS`. |
| `Headers` | No       | Can be dynamic (a variable or table).                                               |
| `Body`    | No       | Can be dynamic.                                                                     |

`Url` and `Method` are fixed at build time because that is what gets hidden. If a request needs to branch, use two `HQ99_SECURE_REQUEST` calls instead of a variable URL.

### Result

The call returns a table shaped like an executor's `request()`:

| Field           | Type    | Meaning                                                                |
| --------------- | ------- | ---------------------------------------------------------------------- |
| `Success`       | boolean | `true` for a 2xx or 3xx status. `false` on a network error or timeout. |
| `StatusCode`    | number  | HTTP status, or `0` if the request never reached the server.           |
| `StatusMessage` | string  | Status text, or `"timeout"` / `"request_failed"` on a transport error. |
| `Headers`       | table   | Response headers, with **lower-case** names.                           |
| `Body`          | string  | Response body, truncated to the proxy's size limit.                    |

{% hint style="danger" %}
**Don't:**

* pass a variable. The argument must be a table written inline.
* use a variable for `Url` or `Method`.
* add keys other than `Url`, `Method`, `Headers` and `Body`.
  {% endhint %}

Each call is single-use, encrypted and authenticated, so the channel can't be replayed or tampered with.

### Build errors

A bad `HQ99_SECURE_REQUEST` **fails the build** and shows the reason in the dashboard.

| Error                                                              | Fix                                          |
| ------------------------------------------------------------------ | -------------------------------------------- |
| `argument must be an inline table literal`                         | Pass a `{ ... }` table, not a variable.      |
| `the argument must be a table of Key = value fields`               | Use only `Key = value` entries.              |
| `unknown field "X"`                                                | Use only `Url`, `Method`, `Headers`, `Body`. |
| `Url is required` / `Method is required`                           | Add the missing field.                       |
| `Url must be a string literal` / `Method must be a string literal` | Write the value directly in quotes.          |
| `Url must use https://`                                            | Use an HTTPS URL.                            |
| `Url may not point to a private/loopback host`                     | Use a public host.                           |
| `Method must be one of ...`                                        | Use a supported HTTP method.                 |


---

# 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.hungquan99.lol/macro-documentation/hq99-macros.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.
