Log inGet started

http

Updated November 15, 2026

Async HTTP — GET/POST returning JSON or raw bytes.

require("@builtin::modules.api.engine.http") -- http (also available as global 'http')

The http namespace: 24 functions.

globals/http/get_bytes

http.get_bytes(url: string, headers: Headers?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP GET returning raw bytes (binary-safe string). Suitable for piping into vfs.write to download a file.

Parameters

  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local bytes = task.await(http.get_bytes("https://example.com/sound.ogg"))

globals/http/get_json

http.get_json(url: string, headers: Headers?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP GET returning JSON. Returns a future (a PromiseHandle) at once, with the request in flight: keep it, f:await() (or task.await(f)) when the response is needed, and f:state() to see whether it has arrived without waiting.

Parameters

  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local data = task.await(http.get_json("https://api.example.com/info"))
local record = task.await(http.get_json(recordUrl, nil, nil, { 404 })) -- a missing record is an answer

globals/http/post_bytes

http.post_bytes(url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP POST returning raw bytes — use for APIs that accept JSON input but return binary output (audio, images).

Parameters

  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • body JsonBody (optional) — JSON body (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local audio = task.await(http.post_bytes(ttsUrl, nil, { text = "hello" }))

globals/http/post_json

http.post_json(url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP POST returning JSON. Body is a Luau table; the FFI layer JSON-encodes it before the request goes out.

Parameters

  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • body JsonBody (optional) — JSON body (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local r = task.await(http.post_json(url, nil, { name = "Alice" }))

globals/http/progress

http.progress(handle: PromiseId) -> UploadProgress?

How far the upload http.upload returned handle for has got: sent, the bytes of its file sent so far, and total, the bytes the file holds. Nil for a handle that names no upload in flight: one never made, or one whose future has settled.

Parameters

  • handle PromiseId — The future http.upload returned.

Returns UploadProgress? — { sent, total }, or nil.

local p = http.progress(f) if p then print(p.sent, "of", p.total) end

globals/http/request

http.request(method: string, url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP request with an arbitrary verb (GET/POST/PUT/PATCH/ DELETE/…) returning JSON. Body is a Luau table; an empty 2xx response resolves to an empty table.

Parameters

  • method string — HTTP verb (case-insensitive).
  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • body JsonBody (optional) — JSON body (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local w = task.await(http.request("PATCH", url, hdrs, { description = "hi" }))

globals/http/request_raw

http.request_raw(method: string, url: string, headers: Headers?, body: buffer | string | nil?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP request with an arbitrary verb and a RAW binary request body (a binary-safe string), for content-addressed blob uploads. The resolved value is the response body text.

Parameters

  • method string — HTTP verb (case-insensitive).
  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • body buffer | string | nil (optional) — Raw binary request body (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local r = task.await(http.request_raw("POST", blobsUrl, hdrs, pngBytes))

globals/http/upload

http.upload(method: string, url: string, headers: Headers?, path: string, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP request whose body is the file at a VFS path, read a piece at a time from where it lies and sent as it is read, so a file of any size (a recorded film) is never held whole in memory. The request is sent once. The resolved value is the response body text. http.progress(f) reads how much of the file has been sent while it runs.

Parameters

  • method string — HTTP verb (case-insensitive).
  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • path string — VFS path of the file sent as the body; a relative path resolves under /source/. The file is held to what the caller's own vfs.read reaches: a file in a home folder is refused to code a world ships.
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local f = http.upload("PUT", url, { ["Content-Type"] = "video/mp4" }, "/source/local/recordings/take.mp4", 0)

modules/http/get_bytes

get_bytes(url: string, headers: Headers?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId

Async HTTP GET returning raw bytes (binary-safe string). Suitable for piping into vfs.write to download a file.

Parameters

  • url string — Request URL.
  • headers Headers? (optional) — Header key-value pairs (optional).
  • timeoutMs TimeoutMs? (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses? (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local bytes = task.await(http.get_bytes("https://example.com/sound.ogg"))

modules/http/get_json

get_json(url: string, headers: Headers?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId

Async HTTP GET returning JSON. Returns a future (a PromiseHandle) at once, with the request in flight: keep it, f:await() (or task.await(f)) when the response is needed, and f:state() to see whether it has arrived without waiting.

Parameters

  • url string — Request URL.
  • headers Headers? (optional) — Header key-value pairs (optional).
  • timeoutMs TimeoutMs? (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses? (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local data = task.await(http.get_json("https://api.example.com/info"))
local record = task.await(http.get_json(recordUrl, nil, nil, { 404 })) -- a missing record is an answer

modules/http/post_bytes

post_bytes(url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId

Async HTTP POST returning raw bytes — use for APIs that accept JSON input but return binary output (audio, images).

Parameters

  • url string — Request URL.
  • headers Headers? (optional) — Header key-value pairs (optional).
  • body JsonBody? (optional) — JSON body (optional).
  • timeoutMs TimeoutMs? (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses? (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local audio = task.await(http.post_bytes(ttsUrl, nil, { text = "hello" }))

modules/http/post_json

post_json(url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId

Async HTTP POST returning JSON. Body is a Luau table; the FFI layer JSON-encodes it before the request goes out.

Parameters

  • url string — Request URL.
  • headers Headers? (optional) — Header key-value pairs (optional).
  • body JsonBody? (optional) — JSON body (optional).
  • timeoutMs TimeoutMs? (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses? (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local r = task.await(http.post_json(url, nil, { name = "Alice" }))

modules/http/progress

progress(handle: PromiseId): UploadProgress?

How far the upload http.upload returned handle for has got: sent, the bytes of its file sent so far, and total, the bytes the file holds. Nil for a handle that names no upload in flight: one never made, or one whose future has settled.

Parameters

  • handle PromiseId — The future http.upload returned.
local p = http.progress(f) if p then print(p.sent, "of", p.total) end

modules/http/request

request(method: string, url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId

Async HTTP request with an arbitrary verb (GET/POST/PUT/PATCH/ DELETE/…) returning JSON. Body is a Luau table; an empty 2xx response resolves to an empty table.

Parameters

  • method string — HTTP verb (case-insensitive).
  • url string — Request URL.
  • headers Headers? (optional) — Header key-value pairs (optional).
  • body JsonBody? (optional) — JSON body (optional).
  • timeoutMs TimeoutMs? (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses? (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local w = task.await(http.request("PATCH", url, hdrs, { description = "hi" }))

modules/http/request_raw

request_raw(method: string, url: string, headers: Headers?, body: buffer | string | nil, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId

Async HTTP request with an arbitrary verb and a RAW binary request body (a binary-safe string), for content-addressed blob uploads. The resolved value is the response body text.

Parameters

  • method string — HTTP verb (case-insensitive).
  • url string — Request URL.
  • headers Headers? (optional) — Header key-value pairs (optional).
  • body buffer | string | nil (optional) — Raw binary request body (optional).
  • timeoutMs TimeoutMs? (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses? (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local r = task.await(http.request_raw("POST", blobsUrl, hdrs, pngBytes))

modules/http/upload

upload(method: string, url: string, headers: Headers?, path: string, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId

Async HTTP request whose body is the file at a VFS path, read a piece at a time from where it lies and sent as it is read, so a file of any size (a recorded film) is never held whole in memory. The request is sent once. The resolved value is the response body text. http.progress(f) reads how much of the file has been sent while it runs.

Parameters

  • method string — HTTP verb (case-insensitive).
  • url string — Request URL.
  • headers Headers? (optional) — Header key-value pairs (optional).
  • path string — VFS path of the file sent as the body; a relative path resolves under /source/. The file is held to what the caller's own vfs.read reaches: a file in a home folder is refused to code a world ships.
  • timeoutMs TimeoutMs? (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses? (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local f = http.upload("PUT", url, { ["Content-Type"] = "video/mp4" }, "/source/local/recordings/take.mp4", 0)

typed/builtin//modules/api/engine/http/http/get_bytes

http.get_bytes(url: string, headers: Headers?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP GET returning raw bytes (binary-safe string). Suitable for piping into vfs.write to download a file.

Parameters

  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local bytes = task.await(http.get_bytes("https://example.com/sound.ogg"))

typed/builtin//modules/api/engine/http/http/get_json

http.get_json(url: string, headers: Headers?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP GET returning JSON. Returns a future (a PromiseHandle) at once, with the request in flight: keep it, f:await() (or task.await(f)) when the response is needed, and f:state() to see whether it has arrived without waiting.

Parameters

  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local data = task.await(http.get_json("https://api.example.com/info"))
local record = task.await(http.get_json(recordUrl, nil, nil, { 404 })) -- a missing record is an answer

typed/builtin//modules/api/engine/http/http/post_bytes

http.post_bytes(url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP POST returning raw bytes — use for APIs that accept JSON input but return binary output (audio, images).

Parameters

  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • body JsonBody (optional) — JSON body (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local audio = task.await(http.post_bytes(ttsUrl, nil, { text = "hello" }))

typed/builtin//modules/api/engine/http/http/post_json

http.post_json(url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP POST returning JSON. Body is a Luau table; the FFI layer JSON-encodes it before the request goes out.

Parameters

  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • body JsonBody (optional) — JSON body (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local r = task.await(http.post_json(url, nil, { name = "Alice" }))

typed/builtin//modules/api/engine/http/http/progress

http.progress(handle: PromiseId) -> UploadProgress?

How far the upload http.upload returned handle for has got: sent, the bytes of its file sent so far, and total, the bytes the file holds. Nil for a handle that names no upload in flight: one never made, or one whose future has settled.

Parameters

  • handle PromiseId — The future http.upload returned.

Returns UploadProgress? — { sent, total }, or nil.

local p = http.progress(f) if p then print(p.sent, "of", p.total) end

typed/builtin//modules/api/engine/http/http/request

http.request(method: string, url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP request with an arbitrary verb (GET/POST/PUT/PATCH/ DELETE/…) returning JSON. Body is a Luau table; an empty 2xx response resolves to an empty table.

Parameters

  • method string — HTTP verb (case-insensitive).
  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • body JsonBody (optional) — JSON body (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local w = task.await(http.request("PATCH", url, hdrs, { description = "hi" }))

typed/builtin//modules/api/engine/http/http/request_raw

http.request_raw(method: string, url: string, headers: Headers?, body: buffer | string | nil?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP request with an arbitrary verb and a RAW binary request body (a binary-safe string), for content-addressed blob uploads. The resolved value is the response body text.

Parameters

  • method string — HTTP verb (case-insensitive).
  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • body buffer | string | nil (optional) — Raw binary request body (optional).
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local r = task.await(http.request_raw("POST", blobsUrl, hdrs, pngBytes))

typed/builtin//modules/api/engine/http/http/upload

http.upload(method: string, url: string, headers: Headers?, path: string, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?) -> PromiseId

Async HTTP request whose body is the file at a VFS path, read a piece at a time from where it lies and sent as it is read, so a file of any size (a recorded film) is never held whole in memory. The request is sent once. The resolved value is the response body text. http.progress(f) reads how much of the file has been sent while it runs.

Parameters

  • method string — HTTP verb (case-insensitive).
  • url string — Request URL.
  • headers Headers (optional) — Header key-value pairs (optional).
  • path string — VFS path of the file sent as the body; a relative path resolves under /source/. The file is held to what the caller's own vfs.read reaches: a file in a home folder is refused to code a world ships.
  • timeoutMs TimeoutMs (optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).
  • expectedStatuses ExpectedStatuses (optional) — HTTP statuses this caller handles as an answer it expected, e.g. { 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).

Returns PromiseId — A future (PromiseHandle): f:await() or task.await(f) delivers the response, f:state() reads whether it has.

local f = http.upload("PUT", url, { ["Content-Type"] = "video/mp4" }, "/source/local/recordings/take.mp4", 0)
  • api
  • reference