A Callable is a reference to a particular Callable HTTPS trigger in Cloud Functions.
Note
If the Callable HTTPS trigger accepts no parameters, Never can be used for
iOS 17.0+. Otherwise, a simple encodable placeholder type (e.g.,
struct EmptyRequest: Encodable {}) can be used.
Executes this Callable HTTPS trigger asynchronously.
The data passed into the trigger must be of the generic Request type:
The request to the Cloud Functions backend made by this method automatically includes a
FCM token to identify the app instance. If a user is logged in with Firebase
Auth, an auth ID token for the user is also automatically included.
Firebase Cloud Messaging sends data to the Firebase backend periodically to collect
information
regarding the app instance. To stop this, see Messaging.deleteData(). It
resumes with a new FCM Token the next time you call this method.
Executes this Callable HTTPS trigger asynchronously.
The data passed into the trigger must be of the generic Request type:
The request to the Cloud Functions backend made by this method automatically includes a
FCM token to identify the app instance. If a user is logged in with Firebase
Auth, an auth ID token for the user is also automatically included.
Firebase Cloud Messaging sends data to the Firebase backend periodically to collect
information
regarding the app instance. To stop this, see Messaging.deleteData(). It
resumes with a new FCM Token the next time you call this method.
Throws
An error if any value throws an error during encoding or decoding.
Creates a stream that yields responses from the streaming callable function.
The request to the Cloud Functions backend made by this method automatically includes a FCM
token to identify the app instance. If a user is logged in with Firebase Auth, an auth ID
token for the user is included. If App Check is integrated, an app check token is included.
Firebase Cloud Messaging sends data to the Firebase backend periodically to collect
information regarding the app instance. To stop this, see Messaging.deleteData(). It
resumes with a new FCM Token the next time you call this method.
Important
The final result returned by the callable function is only accessible when
using StreamResponse as the Response generic type.
letcallable:Callable<MyRequest,MyResponse>=// ...letrequest:MyRequest=// ...letstream=trycallable.stream(request)fortryawaitresponseinstream{// Process each `MyResponse` messageprint(response)}
letcallable:Callable<MyRequest,StreamResponse<MyMessage,MyResult>>=// ...letrequest:MyRequest=// ...letstream=trycallable.stream(request)fortryawaitresponseinstream{switchresponse{case.message(letmessage):// Process each `MyMessage`print(message)case.result(letresult):// Process the final `MyResult`print(result)}}
Throws
A FunctionsError if the parameter data cannot be encoded.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-15 UTC."],[],[],null,["# FirebaseFunctions Framework Reference\n\nCallable\n========\n\n public struct Callable\u003cRequest, Response\u003e : Sendable where Request : Encodable, Response : Decodable\n\nA `Callable` is a reference to a particular Callable HTTPS trigger in Cloud Functions. \nNote\nIf the Callable HTTPS trigger accepts no parameters, `Never` can be used for iOS 17.0+. Otherwise, a simple encodable placeholder type (e.g., `struct EmptyRequest: Encodable {}`) can be used.\n- `\n ``\n ``\n `\n\n ### [timeoutInterval](#/s:17FirebaseFunctions8CallableV15timeoutIntervalSdvp)\n\n `\n ` \n The timeout to use when calling the function. Defaults to 70 seconds. \n\n #### Declaration\n\n Swift \n\n public var timeoutInterval: TimeInterval { get set }\n\n- `\n ``\n ``\n `\n\n ### [call(_:completion:)](#/s:17FirebaseFunctions8CallableV4call_10completionyx_ys6ResultOyq_s5Error_pGScMYcctF)\n\n `\n ` \n Executes this Callable HTTPS trigger asynchronously.\n\n The data passed into the trigger must be of the generic `Request` type:\n\n The request to the Cloud Functions backend made by this method automatically includes a\n FCM token to identify the app instance. If a user is logged in with Firebase\n Auth, an auth ID token for the user is also automatically included.\n\n Firebase Cloud Messaging sends data to the Firebase backend periodically to collect\n information\n regarding the app instance. To stop this, see `Messaging.deleteData()`. It\n resumes with a new FCM Token the next time you call this method. \n\n #### Declaration\n\n Swift \n\n public func call(_ data: Request,\n completion: @escaping @MainActor (Result\u003cResponse, Error\u003e)\n -\u003e Void)\n\n #### Parameters\n\n |--------------------|---------------------------------------------------------|\n | ` `*data*` ` | Parameters to pass to the trigger. |\n | ` `*completion*` ` | The block to call when the HTTPS request has completed. |\n\n- `\n ``\n ``\n `\n\n ### [callAsFunction(_:completion:)](#/s:17FirebaseFunctions8CallableV14callAsFunction_10completionyx_ys6ResultOyq_s5Error_pGScMYcctF)\n\n `\n ` \n Creates a directly callable function.\n\n This allows users to call a HTTPS Callable Function like a normal Swift function: \n\n let greeter = functions.httpsCallable(\"greeter\",\n requestType: GreetingRequest.self,\n responseType: GreetingResponse.self)\n greeter(data) { result in\n print(result.greeting)\n }\n\n You can also call a HTTPS Callable function using the following syntax: \n\n let greeter: Callable\u003cGreetingRequest, GreetingResponse\u003e =\n functions.httpsCallable(\"greeter\")\n greeter(data) { result in\n print(result.greeting)\n }\n\n #### Declaration\n\n Swift \n\n public func callAsFunction(_ data: Request,\n completion: @escaping @MainActor (Result\u003cResponse, Error\u003e)\n -\u003e Void)\n\n #### Parameters\n\n |--------------------|---------------------------------------------------------|\n | ` `*data*` ` | Parameters to pass to the trigger. |\n | ` `*completion*` ` | The block to call when the HTTPS request has completed. |\n\n- `\n ``\n ``\n `\n\n ### [call(_:)](#/s:17FirebaseFunctions8CallableV4callyq_xYaKF)\n\n `\n ` \n Executes this Callable HTTPS trigger asynchronously.\n\n The data passed into the trigger must be of the generic `Request` type:\n\n The request to the Cloud Functions backend made by this method automatically includes a\n FCM token to identify the app instance. If a user is logged in with Firebase\n Auth, an auth ID token for the user is also automatically included.\n\n Firebase Cloud Messaging sends data to the Firebase backend periodically to collect\n information\n regarding the app instance. To stop this, see `Messaging.deleteData()`. It\n resumes with a new FCM Token the next time you call this method. \n Throws\n\n An error if any value throws an error during encoding or decoding. \n Throws\n\n An error if the callable fails to complete \n\n #### Declaration\n\n Swift \n\n @available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *)\n public func call(_ data: Request) async throws -\u003e Response\n\n #### Parameters\n\n |--------------|-------------------------------------------------------------|\n | ` `*data*` ` | The `Request` representing the data to pass to the trigger. |\n\n #### Return Value\n\n The decoded `Response` value\n- `\n ``\n ``\n `\n\n ### [callAsFunction(_:)](#/s:17FirebaseFunctions8CallableV14callAsFunctionyq_xYaKF)\n\n `\n ` \n Creates a directly callable function.\n\n This allows users to call a HTTPS Callable Function like a normal Swift function: \n\n let greeter = functions.httpsCallable(\"greeter\",\n requestType: GreetingRequest.self,\n responseType: GreetingResponse.self)\n let result = try await greeter(data)\n print(result.greeting)\n\n You can also call a HTTPS Callable function using the following syntax: \n\n let greeter: Callable\u003cGreetingRequest, GreetingResponse\u003e =\n functions.httpsCallable(\"greeter\")\n let result = try await greeter(data)\n print(result.greeting)\n\n #### Declaration\n\n Swift \n\n @available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *)\n public func callAsFunction(_ data: Request) async throws -\u003e Response\n\n #### Parameters\n\n |--------------|------------------------------------|\n | ` `*data*` ` | Parameters to pass to the trigger. |\n\n #### Return Value\n\nThe decoded `Response` value \n[Available where \\`Request\\`: \\`Sendable\\`, \\`Response\\`: \\`Sendable\\`\n---------------------------------------------------------------------](#/Available-where-%60Request%60%3A-%60Sendable%60%2C-%60Response%60%3A-%60Sendable%60)\n\n- `\n ``\n ``\n `\n\n ### [stream(_:)](#/s:17FirebaseFunctions8CallableVAAs8SendableRzsADR_rlE6streamyScsyq_s5Error_pGxSgKF)\n\n `\n ` \n Creates a stream that yields responses from the streaming callable function.\n\n The request to the Cloud Functions backend made by this method automatically includes a FCM\n token to identify the app instance. If a user is logged in with Firebase Auth, an auth ID\n token for the user is included. If App Check is integrated, an app check token is included.\n\n Firebase Cloud Messaging sends data to the Firebase backend periodically to collect\n information regarding the app instance. To stop this, see `Messaging.deleteData()`. It\n resumes with a new FCM Token the next time you call this method. \n Important\n The final result returned by the callable function is only accessible when using [StreamResponse](../Enums/StreamResponse.html) as the `Response` generic type.\n\n Example of using `stream` *without* [StreamResponse](../Enums/StreamResponse.html): \n\n let callable: Callable\u003cMyRequest, MyResponse\u003e = // ...\n let request: MyRequest = // ...\n let stream = try callable.stream(request)\n for try await response in stream {\n // Process each `MyResponse` message\n print(response)\n }\n\n Example of using `stream` *with* [StreamResponse](../Enums/StreamResponse.html): \n\n let callable: Callable\u003cMyRequest, StreamResponse\u003cMyMessage, MyResult\u003e\u003e = // ...\n let request: MyRequest = // ...\n let stream = try callable.stream(request)\n for try await response in stream {\n switch response {\n case .message(let message):\n // Process each `MyMessage`\n print(message)\n case .result(let result):\n // Process the final `MyResult`\n print(result)\n }\n }\n\n Throws\n A `FunctionsError` if the parameter `data` cannot be encoded. \n\n #### Declaration\n\n Swift \n\n func stream(_ data: Request? = nil) throws -\u003e AsyncThrowingStream\u003cResponse, Error\u003e\n\n #### Parameters\n\n |--------------|------------------------------------------------------|\n | ` `*data*` ` | The `Request` data to pass to the callable function. |\n\n #### Return Value\n\n A stream wrapping responses yielded by the streaming callable function or\n a `FunctionsError` if an error occurred."]]