### Background After failed attempt (1) to create a complex API, by nicely linking my `APIFunction` to a cloud based package, I decided to go with the flow and trust that: > `CloudDeploy[expr, ...]` automatically deploys all definitions needed to evaluate expr, much like `CloudSave`. ### Problem but either it can't be trusted or I'm missing the point. It seems that definitions are collected by scanning right-hand-sides of related definitions but not left-hand-sides. ### Example ClearAll[foo, check]; check = IntegerQ; foo[x_?check] := $Failed; foo[x_] := x^2 api = CloudDeploy[ APIFunction[{"x" -> "Number"}, foo[#x] &] , Permissions -> "Public" ] <!--> foo[2] (* -> $Failed*) foo[1.2] (* -> 1.44 *) <!--> URLExecute[api, {"x" -> 2}] (* -> 4*) !!!!!!!!!!! URLExecute[api, {"x" -> 1.2}] (* -> 1.44*) The first `URLExecute` is wrong, it is caused by missing definition of `check`. One can confirm that by Import[api, "Text"] > Language`ExtendedFullDefinition[] = Language`DefinitionList[ HoldForm[foo] -> {..., DownValues -> { HoldPattern[foo[(x_)?check]] :> $Failed, HoldPattern[foo[x_]] :> x^2 }, ... }]; > APIFunction[{"x" -> "Number"}, foo[#x] & ] ### Questions - Is this expected? Are there any new guidelines how to write code so it could be collected well? Or is it a flaw in ``Language` ``? - Is there anything I could read to learn working with the Cloud features in such a way that I won't have to come back here with a question/problem about a basic issue like deployment of dependencies? ### Links 1. https://mathematica.stackexchange.com/q/147330/5478 2. https://mathematica.stackexchange.com/q/104739/5478 3. https://mathematica.stackexchange.com/q/125837/5478