View .md

MuxForms on Swift uses URLSession.shared.data(for:) with a POST request to the submit API, JSONEncoder for the body, and Authorization Bearer ingest secret. Handle HTTP 422 to show validation errors.

Docs

Swift

SwiftUI and UIKit apps submit with URLSession—encode a Codable struct that matches your MuxForms field names.

Swift

APIUsage
URLSessionPOST JSON
CodablePayload struct
KeychainStore ingest secret
CombineOptional async wrapper

Submit.swift

import Foundation

struct ContactPayload: Encodable {
  let email: String
  let message: String
  let platform = "ios"
  let _hp = ""
}

func submitContact(email: String, message: String, secret: String) async throws {
  let url = URL(string: "https://www.muxforms.com/api/v1/forms/FORM_UUID/submit")!
  var request = URLRequest(url: url)
  request.httpMethod = "POST"
  request.setValue("application/json", forHTTPHeaderField: "Content-Type")
  request.setValue("Bearer \(secret)", forHTTPHeaderField: "Authorization")
  request.httpBody = try JSONEncoder().encode(ContactPayload(email: email, message: message))
  let (_, response) = try await URLSession.shared.data(for: request)
  guard let http = response as? HTTPURLResponse, http.statusCode == 200 else {
    throw URLError(.badServerResponse)
  }
}

Common questions

SwiftUI Form?
On submit, call async submit function from .task or Button action.
App Store privacy?
Disclose contact data collection in privacy nutrition labels.
macOS Catalyst?
Same URLSession code.
Widget extension?
Extensions should not embed secrets—open main app contact.

Native Swift, no Mail.compose workaround.

Support reads the same inbox as your marketing site.

Upgrade to Pro