Documentation Index
Fetch the complete documentation index at: https://motiadev-docs-verdict-review-plan.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Goal
Expose a Function as an HTTP endpoint so external clients can call it via REST.
Steps
1. Enable the REST API worker
Make sure iii-config.yaml has the REST API worker enabled:
- name: iii-http
config:
port: 3111
host: 127.0.0.1
default_timeout: 30000
concurrency_request_limit: 1024
cors:
allowed_origins:
# To allow all origins, use '*':
# - '*'
- localhost
allowed_methods:
- GET
- POST
- PUT
- DELETE
- OPTIONS
2. Register the Function
Node / TypeScript
Python
Rust
import {registerWorker, Logger} from 'iii-sdk'
const iii = registerWorker(process.env.III_URL ?? 'ws://localhost:49134')
iii.registerFunction('users::create', async (req) => {
const logger = new Logger()
const { name, email } = req.body
const user = { id: crypto.randomUUID(), name, email }
logger.info('User created', { userId: user.id })
return { status_code: 201, body: user }
})
import os
import uuid
from iii import Logger, register_worker
iii = register_worker(os.environ.get("III_URL", "ws://localhost:49134"))
def create_user(req):
logger = Logger()
name = req["body"]["name"]
email = req["body"]["email"]
user = {"id": str(uuid.uuid4()), "name": name, "email": email}
logger.info("User created", {"userId": user["id"]})
return {"status_code": 201, "body": user}
iii.register_function("users::create", create_user)
use iii_sdk::{register_worker, InitOptions, Logger, RegisterFunction};
use serde_json::{json, Value};
use tokio::signal;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let url = std::env::var("III_URL").unwrap_or_else(|_| "ws://127.0.0.1:49134".to_string());
let iii = register_worker(&url, InitOptions::default());
let reg = RegisterFunction::new_async("users::create", |req: Value| async move {
let logger = Logger::new();
let name = req["body"]["name"].as_str().unwrap_or("");
let email = req["body"]["email"].as_str().unwrap_or("");
let user_id = uuid::Uuid::new_v4().to_string();
logger.info("User created", Some(json!({ "userId": user_id })));
Ok(json!({
"status_code": 201,
"body": { "id": user_id, "name": name, "email": email }
}))
});
iii.register_function(reg);
println!("HTTP endpoint ready on POST /users");
signal::ctrl_c().await?;
Ok(())
}
3. Register the HTTP trigger
Node / TypeScript
Python
Rust
iii.registerTrigger({
type: 'http',
function_id: 'users::create',
config: { api_path: '/users', http_method: 'POST' },
})
iii.register_trigger({
"type": "http",
"function_id": "users::create",
"config": {"api_path": "/users", "http_method": "POST"},
})
iii.register_trigger(RegisterTriggerInput {
trigger_type: "http".into(),
function_id: "users::create".into(),
config: json!({ "api_path": "/users", "http_method": "POST" }),
metadata: None,
})?;
4. Try it
curl -X POST http://127.0.0.1:3111/users \
-H "Content-Type: application/json" \
-d '{"name": "Alice", "email": "alice@example.com"}'
Result
Your Function is now accessible as POST /users on port 3111. The http trigger handles request parsing and response serialization automatically.
HTTP-triggered Functions receive an ApiRequest and should return an ApiResponse. See the SDK Reference for type details.