MuxForms on Kotlin/Android POSTs application/json to the submit endpoint with the ingest secret in Authorization. Use coroutines on Dispatchers.IO for the network call from Compose or XML layouts.
Docs
Android apps use OkHttp (or Ktor client) to POST JSON—mirror the field names from your MuxForms form schema.
| Library | Role |
|---|---|
| OkHttp | POST body |
| kotlinx.serialization | JSON encode |
| BuildConfig | Avoid secret in APK—use backend |
| 422 | Show field errors in UI |
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONObject
private val JSON = "application/json; charset=utf-8".toMediaType()
suspend fun submitContact(email: String, message: String, secret: String) {
val body = JSONObject()
.put("email", email)
.put("message", message)
.put("platform", "android")
.put("_hp", "")
.toString()
.toRequestBody(JSON)
val request = Request.Builder()
.url("https://www.muxforms.com/api/v1/forms/FORM_UUID/submit")
.post(body)
.addHeader("Authorization", "Bearer $secret")
.build()
OkHttpClient().newCall(request).execute().use { response ->
if (!response.isSuccessful) error("Submit failed: ${response.code}")
}
}Pair with website embed for cross-platform support.
Upgrade to Pro