Skip to main content
On Android 16 (API 36) and later, the Figranium Kotlin SDK exposes a single system AppFunction for running an approved deterministic task. You provide the client through a FigraniumAppFunctionClientProvider so your app controls authentication and secrets. AppFunctions never accept credentials as parameters.
AppFunctions support requires Android API 36+ (compileSdk 37). On devices with an older version, FigraniumAppFunctions.setEnabled is a no-op and the base SDK works unchanged.

Install the integration

Add the optional figranium-appfunctions artifact and KSP in your module’s build.gradle.kts.
build.gradle.kts
The KSP compiler generates the service metadata from the @AppFunctionServiceEntryPoint annotation. For more on Android platform setup, see the Android AppFunctions documentation.

Configure the client provider

Before the system can invoke any Figranium AppFunction, call FigraniumAppFunctionConfiguration.configure(_:) once from Application.onCreate with a provider that vends a configured Figranium client.
MyApplication.kt
If an AppFunction is invoked before configuration completes, the SDK throws an IllegalStateException with the message: Configure FigraniumAppFunctionConfiguration before invoking Figranium AppFunctions.

Service and available AppFunction

BaseFigraniumAppFunctionService

Extend this abstract service in your app to host the generated AppFunction entry point. KSP processes the @AppFunctionServiceEntryPoint annotation and generates the corresponding metadata XML. Signature:
  • The @AppFunction method is declared with isEnabled = false. It is disabled by default.
  • The service requires API 36 at runtime.

runFigraniumTask

Runs one explicitly approved deterministic Figranium task. Signature:
  • Parameter: RunFigraniumTaskParameters with a single taskId field, the ID of an app-approved deterministic task.
  • Returns: FigraniumAppFunctionResult containing:
    • outcome (String): the Figranium execution outcome such as success or error. Falls back to unknown when the server omits it.
    • data (String?): JSON output from the approved task.
    • runId (String?): the run ID, if returned by Figranium.
  • HTTP endpoint: POST /tasks/{id}/api (via client.runTask<JsonObject>(taskId))

Data types

Control the task allowlist and availability

FigraniumAppFunctions is an object that manages which tasks assistants are allowed to run.
  • Only task IDs present in the configured set can be executed through AppFunctions.
  • Calling runFigraniumTask with a task ID outside the allowlist throws an IllegalStateException with the message: This task is not approved for AppFunctions execution.

Enable or disable the AppFunction

  • setEnabled is safe to call on devices below API 36 (it returns immediately with no effect).
  • When enabled, the generated AppFunction becomes discoverable by Android assistants and agents.

Security notes

  • Keep API keys in Android Keystore-backed storage or another secure app-owned store. Never pass credentials as AppFunction parameters.
  • The allowlist means an assistant can run only the tasks your app explicitly approves. It cannot create arbitrary browser actions or read Figranium credentials.
  • If the provider throws, the exception propagates through the AppFunction runtime.

Error reference

Tasks

Save, run, and manage deterministic tasks to allowlist for AppFunctions.

Client configuration

Review base URL, timeouts, and custom headers for the Figranium client.

Actions

Build deterministic action sequences for tasks that you expose through AppFunctions.