[{"data":1,"prerenderedAt":1672},["ShallowReactive",2],{"guide-/docs/guides/how-to-create-a-function":3,"guide-create-/docs/guides/how-to-create-a-function-create":34,"guide-code-/docs/guides/how-to-create-a-function-code":942,"guide-observability-overview-null":1671,"guide-observability-using-null":1671},{"id":4,"title":5,"body":6,"description":26,"extension":27,"meta":28,"navigation":29,"path":30,"seo":31,"stem":32,"__hash__":33},"guides/docs/guides/how-to-create-a-function.md","How to create a function",{"type":7,"value":8,"toc":22},"minimark",[9],[10,11,12,13,17,18,21],"p",{},"This guide is split into two sections: ",[14,15,16],"strong",{},"Creating the function"," (API and flow) and ",[14,19,20],{},"Code"," (handler, event shape, and examples). Use the sections below.",{"title":23,"searchDepth":24,"depth":24,"links":25},"",2,[],"Create, deploy, and invoke a serverless function on the Rocketstack control plane. Upload code as a ZIP, choose a runtime, and trigger via API or public URL.","md",{},true,"/docs/guides/how-to-create-a-function",{"title":5,"description":26},"docs/guides/how-to-create-a-function","BaNaY62huRcKp88gEiVpHp96tc2CoFLYmsUCVTFSe8o",{"id":35,"title":16,"body":36,"description":936,"extension":27,"meta":937,"navigation":29,"path":938,"seo":939,"stem":940,"__hash__":941},"guides/docs/guides/how-to-create-a-function-create.md",{"type":7,"value":37,"toc":921},[38,45,50,89,104,107,110,113,201,206,224,228,242,246,288,301,303,306,309,327,334,338,429,433,581,585,688,692,699,797,817,827,829,832,835,889,900,908,917],[10,39,40,41,44],{},"This guide walks you through creating, deploying, and invoking a ",[14,42,43],{},"function"," on the Rocketstack control plane. A function is a serverless unit of compute: you upload your code as a ZIP, choose a runtime, and the platform runs it on each invocation—via the control plane invoke API or a public HTTP URL.",[46,47,49],"h2",{"id":48},"overview","Overview",[51,52,53,65,75],"ol",{},[54,55,56,59,60,64],"li",{},[14,57,58],{},"Create"," the function with a ",[61,62,63],"code",{},"POST"," request (name, runtime, handler, code ZIP).",[54,66,67,70,71,74],{},[14,68,69],{},"Wait"," until the function status is ",[61,72,73],{},"ready"," (creation is asynchronous).",[54,76,77,80,81,84,85,88],{},[14,78,79],{},"Invoke"," via the control plane API with a custom payload, or expose a ",[14,82,83],{},"public URL"," (e.g. ",[61,86,87],{},"https://fn.rocketstack.sh/...",") for HTTP calls.",[10,90,91,92,95,96,99,100,103],{},"You can create a function in three ways: ",[14,93,94],{},"Via Console"," (web UI), ",[14,97,98],{},"Via API"," (HTTP request), or ",[14,101,102],{},"Via MCP"," (from an AI assistant or MCP-enabled editor). Choose one and follow the steps below.",[105,106],"hr",{},[46,108,94],{"id":109},"via-console",[10,111,112],{},"Use the Rocketstack Console when you prefer a UI over the API—ideal for your first function or quick one-off creates.",[51,114,115,134,140,147,161,180,186,197],{},[54,116,117,118,125,126,129,130,133],{},"In the ",[119,120,124],"a",{"href":121,"rel":122},"https://console.rocketstack.sh",[123],"nofollow","Rocketstack Console",", open ",[14,127,128],{},"Primitives"," in the sidebar > ",[14,131,132],{},"Functinos",".",[54,135,136,137,133],{},"Click ",[14,138,139],{},"Create function",[54,141,142,143,146],{},"Enter a ",[14,144,145],{},"Name"," (1–64 characters, start with a letter; only letters, numbers, hyphens, underscores).",[54,148,149,150,84,153,156,157,160],{},"Choose a ",[14,151,152],{},"Runtime",[61,154,155],{},"nodejs20.x"," or ",[61,158,159],{},"python3.12",").",[54,162,163,164,167,168,171,172,175,176,179],{},"Set ",[14,165,166],{},"Handler"," to your entrypoint in the form ",[61,169,170],{},"fileName.exportedFunction","—e.g. ",[61,173,174],{},"index.handler"," for Node or ",[61,177,178],{},"handler.handler"," for Python.",[54,181,182,185],{},[14,183,184],{},"Upload"," your function code as a ZIP file (the entrypoint file must be at the root of the ZIP).",[54,187,188,189,192,193,196],{},"(Optional) To expose a public URL: enable ",[14,190,191],{},"Public"," and choose the ",[14,194,195],{},"Public method"," (GET, POST, PATCH, or DELETE).",[54,198,136,199,133],{},[14,200,139],{},[202,203,205],"h3",{"id":204},"before-you-upload","Before you upload",[10,207,208,209,156,212,215,216,219,220,223],{},"Package your entrypoint (e.g. ",[61,210,211],{},"index.js",[61,213,214],{},"handler.py",") and any dependencies at the ",[14,217,218],{},"root"," of the ZIP. The handler value must match that file and export name exactly (see the ",[119,221,20],{"href":222},"#code"," section for details).",[202,225,227],{"id":226},"after-creation","After creation",[10,229,230,231,234,235,237,238],{},"The function appears in the list with status ",[14,232,233],{},"creating"," until it becomes ",[14,236,73],{},". Open the function to view details; you can trigger a test invocation or check logs from the console. ",[239,240,241],"span",{},"VERIFY: exact labels and availability of test invoke/logs in UI.",[202,243,245],{"id":244},"troubleshooting","Troubleshooting",[247,248,249,255,273,279],"ul",{},[54,250,251,254],{},[14,252,253],{},"Invalid or empty ZIP:"," Ensure the ZIP is a valid archive and contains your entry file at the root (not inside a nested folder).",[54,256,257,260,261,263,264,266,267,156,270,160],{},[14,258,259],{},"Handler mismatch:"," The handler string must match the file name and exported function (e.g. ",[61,262,174],{}," → ",[61,265,211],{}," with ",[61,268,269],{},"export const handler",[61,271,272],{},"exports.handler",[54,274,275,278],{},[14,276,277],{},"Runtime mismatch:"," Confirm the selected runtime matches your code (e.g. Node vs Python).",[54,280,281,284,285],{},[14,282,283],{},"Creation stays in \"creating\":"," Wait a minute and refresh; if it persists, check the console for errors or try a smaller ZIP. ",[239,286,287],{},"VERIFY: actual behavior and support flow.",[10,289,290,293,294,297,298,133],{},[14,291,292],{},"Alternatives:"," To create via HTTP, see ",[119,295,98],{"href":296},"#via-api",". To create from an AI assistant or editor, see ",[119,299,102],{"href":300},"#via-mcp",[105,302],{},[46,304,98],{"id":305},"via-api",[10,307,308],{},"Use the API when you're scripting, integrating with CI/CD, or automating deployments.",[10,310,311,314,315,318,321,314,324],{},[14,312,313],{},"Endpoint:"," ",[61,316,317],{},"POST /v1/functions",[319,320],"br",{},[14,322,323],{},"Content-Type:",[61,325,326],{},"multipart/form-data",[10,328,329,330,333],{},"Use your API base URL (e.g. ",[61,331,332],{},"https://api.rocketstack.sh",") with the path above. Send all parameters as form fields; the function code is the only binary field.",[202,335,337],{"id":336},"required-form-fields","Required form fields",[339,340,341,357],"table",{},[342,343,344],"thead",{},[345,346,347,351,354],"tr",{},[348,349,350],"th",{},"Field",[348,352,353],{},"Type",[348,355,356],{},"Description",[358,359,360,374,391,413],"tbody",{},[345,361,362,368,371],{},[363,364,365],"td",{},[61,366,367],{},"name",[363,369,370],{},"string",[363,372,373],{},"Function name. 1–64 characters, must start with a letter. Only letters, numbers, hyphens, and underscores.",[345,375,376,381,383],{},[363,377,378],{},[61,379,380],{},"runtime",[363,382,370],{},[363,384,385,386,388,389,133],{},"One of: ",[61,387,155],{},", ",[61,390,159],{},[345,392,393,398,400],{},[363,394,395],{},[61,396,397],{},"handler",[363,399,370],{},[363,401,402,403,84,405,407,408,84,411,160],{},"Entrypoint: for Node.js ",[61,404,170],{},[61,406,174],{},"); for Python ",[61,409,410],{},"fileName.functionName",[61,412,178],{},[345,414,415,419,422],{},[363,416,417],{},[61,418,61],{},[363,420,421],{},"file",[363,423,424,425,428],{},"The function code as a ",[14,426,427],{},"ZIP file"," (binary).",[202,430,432],{"id":431},"optional-form-fields","Optional form fields",[339,434,435,445],{},[342,436,437],{},[345,438,439,441,443],{},[348,440,350],{},[348,442,353],{},[348,444,356],{},[358,446,447,463,478,493,520,532,552],{},[345,448,449,454,457],{},[363,450,451],{},[61,452,453],{},"memoryMb",[363,455,456],{},"number",[363,458,459,460,133],{},"128–10240; default ",[61,461,462],{},"256",[345,464,465,470,472],{},[363,466,467],{},[61,468,469],{},"timeoutSeconds",[363,471,456],{},[363,473,474,475,133],{},"1–60; default ",[61,476,477],{},"10",[345,479,480,485,487],{},[363,481,482],{},[61,483,484],{},"env",[363,486,370],{},[363,488,489,490,133],{},"JSON object of environment variables, e.g. ",[61,491,492],{},"{\"KEY\":\"value\"}",[345,494,495,500,502],{},[363,496,497],{},[61,498,499],{},"reservedConcurrency",[363,501,456],{},[363,503,504,507,508,511,512,515,516,519],{},[61,505,506],{},"0"," = paused, ",[61,509,510],{},"1","–",[61,513,514],{},"100"," = concurrency cap, omit or ",[61,517,518],{},"null"," = unreserved.",[345,521,522,527,529],{},[363,523,524],{},[61,525,526],{},"description",[363,528,370],{},[363,530,531],{},"Max 256 characters.",[345,533,534,539,541],{},[363,535,536],{},[61,537,538],{},"isPublic",[363,540,370],{},[363,542,543,544,547,548,551],{},"Set to ",[61,545,546],{},"\"true\""," to make the function invokable via the public base URL (e.g. ",[61,549,550],{},"fn.rocketstack.sh",") without auth.",[345,553,554,559,561],{},[363,555,556],{},[61,557,558],{},"publicMethod",[363,560,370],{},[363,562,563,564,566,567,388,570,388,572,388,575,578,579,133],{},"When ",[61,565,538],{}," is true, the single HTTP method allowed for that public URL: one of ",[61,568,569],{},"GET",[61,571,63],{},[61,573,574],{},"PATCH",[61,576,577],{},"DELETE",". Default when public is true is ",[61,580,63],{},[202,582,584],{"id":583},"example-create-with-curl","Example: create with cURL",[586,587,591],"pre",{"className":588,"code":589,"language":590,"meta":23,"style":23},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","curl -X POST https://api.rocketstack.sh/v1/functions \\\n  -H \"Authorization: Bearer YOUR_API_KEY\" \\\n  -F \"name=my-api\" \\\n  -F \"runtime=nodejs20.x\" \\\n  -F \"handler=index.handler\" \\\n  -F \"code=@dist.zip\"\n","bash",[61,592,593,615,632,647,661,675],{"__ignoreMap":23},[239,594,597,601,605,608,611],{"class":595,"line":596},"line",1,[239,598,600],{"class":599},"sBMFI","curl",[239,602,604],{"class":603},"sfazB"," -X",[239,606,607],{"class":603}," POST",[239,609,610],{"class":603}," https://api.rocketstack.sh/v1/functions",[239,612,614],{"class":613},"sTEyZ"," \\\n",[239,616,617,620,624,627,630],{"class":595,"line":24},[239,618,619],{"class":603},"  -H",[239,621,623],{"class":622},"sMK4o"," \"",[239,625,626],{"class":603},"Authorization: Bearer YOUR_API_KEY",[239,628,629],{"class":622},"\"",[239,631,614],{"class":613},[239,633,635,638,640,643,645],{"class":595,"line":634},3,[239,636,637],{"class":603},"  -F",[239,639,623],{"class":622},[239,641,642],{"class":603},"name=my-api",[239,644,629],{"class":622},[239,646,614],{"class":613},[239,648,650,652,654,657,659],{"class":595,"line":649},4,[239,651,637],{"class":603},[239,653,623],{"class":622},[239,655,656],{"class":603},"runtime=nodejs20.x",[239,658,629],{"class":622},[239,660,614],{"class":613},[239,662,664,666,668,671,673],{"class":595,"line":663},5,[239,665,637],{"class":603},[239,667,623],{"class":622},[239,669,670],{"class":603},"handler=index.handler",[239,672,629],{"class":622},[239,674,614],{"class":613},[239,676,678,680,682,685],{"class":595,"line":677},6,[239,679,637],{"class":603},[239,681,623],{"class":622},[239,683,684],{"class":603},"code=@dist.zip",[239,686,687],{"class":622},"\"\n",[202,689,691],{"id":690},"response","Response",[10,693,694,695,698],{},"The API returns ",[14,696,697],{},"202 Accepted"," with a body like:",[586,700,704],{"className":701,"code":702,"language":703,"meta":23,"style":23},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"requestId\": \"...\",\n  \"data\": {\n    \"resourceId\": \"...\",\n    \"status\": \"creating\"\n  }\n}\n","json",[61,705,706,711,735,749,769,786,791],{"__ignoreMap":23},[239,707,708],{"class":595,"line":596},[239,709,710],{"class":622},"{\n",[239,712,713,716,720,722,725,727,730,732],{"class":595,"line":24},[239,714,715],{"class":622},"  \"",[239,717,719],{"class":718},"spNyl","requestId",[239,721,629],{"class":622},[239,723,724],{"class":622},":",[239,726,623],{"class":622},[239,728,729],{"class":603},"...",[239,731,629],{"class":622},[239,733,734],{"class":622},",\n",[239,736,737,739,742,744,746],{"class":595,"line":634},[239,738,715],{"class":622},[239,740,741],{"class":718},"data",[239,743,629],{"class":622},[239,745,724],{"class":622},[239,747,748],{"class":622}," {\n",[239,750,751,754,757,759,761,763,765,767],{"class":595,"line":649},[239,752,753],{"class":622},"    \"",[239,755,756],{"class":599},"resourceId",[239,758,629],{"class":622},[239,760,724],{"class":622},[239,762,623],{"class":622},[239,764,729],{"class":603},[239,766,629],{"class":622},[239,768,734],{"class":622},[239,770,771,773,776,778,780,782,784],{"class":595,"line":663},[239,772,753],{"class":622},[239,774,775],{"class":599},"status",[239,777,629],{"class":622},[239,779,724],{"class":622},[239,781,623],{"class":622},[239,783,233],{"class":603},[239,785,687],{"class":622},[239,787,788],{"class":595,"line":677},[239,789,790],{"class":622},"  }\n",[239,792,794],{"class":595,"line":793},7,[239,795,796],{"class":622},"}\n",[10,798,799,800,803,804,806,807,810,811,813,814,816],{},"Creation is ",[14,801,802],{},"asynchronous",". Use ",[61,805,756],{}," to poll the function resource (e.g. ",[61,808,809],{},"GET /v1/functions/:id",") until ",[61,812,775],{}," is ",[61,815,73],{}," before invoking or relying on the public URL.",[10,818,819,821,822,297,825,133],{},[14,820,292],{}," To create from the web UI, see ",[119,823,94],{"href":824},"#via-console",[119,826,102],{"href":300},[105,828],{},[46,830,102],{"id":831},"via-mcp",[10,833,834],{},"Use MCP (Model Context Protocol) when you want to create or update a function from an MCP-enabled client such as Claude, Cursor, or Windsurf—without leaving your chat or editor.",[51,836,837,850,861,878],{},[54,838,839,842,843,846,847],{},[14,840,841],{},"Configure the Rocketstack MCP server"," in your client (e.g. add the server with your ",[61,844,845],{},"ROCKETSTACK_API_KEY","). ",[239,848,849],{},"VERIFY: link to full MCP setup if available.",[54,851,852,853,856,857,860],{},"In your client, use the ",[14,854,855],{},"deploy"," flow (e.g. ask to \"deploy my function\" or use a ",[61,858,859],{},"functions.deploy","-style tool if exposed).",[54,862,863,864,388,866,84,868,156,870,872,873,84,875,877],{},"Provide the ",[14,865,367],{},[14,867,380],{},[61,869,155],{},[61,871,159],{},"), and ",[14,874,397],{},[61,876,174],{},"). The client typically bundles your code and uploads it as a ZIP.",[54,879,880,881,884,885,888],{},"(Optional) Specify if the function should be ",[14,882,883],{},"public"," and which ",[14,886,887],{},"public method"," to allow.",[10,890,891,892,156,894,896,897,899],{},"The same packaging rules apply: your entrypoint file (e.g. ",[61,893,211],{},[61,895,214],{},") and dependencies should be at the root of the bundle (see the ",[119,898,20],{"href":222}," section). After creation, the function appears in the Console and can be invoked via API or public URL like any other.",[10,901,902,903,907],{},"For full MCP setup (config, tools, and supported clients), see ",[119,904,906],{"href":905},"/docs/mcp","MCP Integration"," in the docs.",[10,909,910,821,912,914,915,133],{},[14,911,292],{},[119,913,94],{"href":824},". To create via HTTP, see ",[119,916,98],{"href":296},[918,919,920],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}",{"title":23,"searchDepth":24,"depth":24,"links":922},[923,924,929,935],{"id":48,"depth":24,"text":49},{"id":109,"depth":24,"text":94,"children":925},[926,927,928],{"id":204,"depth":634,"text":205},{"id":226,"depth":634,"text":227},{"id":244,"depth":634,"text":245},{"id":305,"depth":24,"text":98,"children":930},[931,932,933,934],{"id":336,"depth":634,"text":337},{"id":431,"depth":634,"text":432},{"id":583,"depth":634,"text":584},{"id":690,"depth":634,"text":691},{"id":831,"depth":24,"text":102},"API and flow for creating a function.",{},"/docs/guides/how-to-create-a-function-create",{"title":16,"description":936},"docs/guides/how-to-create-a-function-create","ijeM1ZKnr97eumWQtbA1DCXfqmb5XJapvaZkdz104Zs",{"id":943,"title":20,"body":944,"description":1665,"extension":27,"meta":1666,"navigation":29,"path":1667,"seo":1668,"stem":1669,"__hash__":1670},"guides/docs/guides/how-to-create-a-function-code.md",{"type":7,"value":945,"toc":1652},[946,950,990,994,1000,1032,1043,1047,1085,1089,1098,1157,1172,1176,1324,1328,1462,1466,1473,1480,1505,1520,1526,1530,1560,1564,1636,1649],[46,947,949],{"id":948},"code-layout-and-zip","Code layout and ZIP",[247,951,952,963,979],{},[54,953,954,955,84,958,156,960,962],{},"The ZIP must contain your ",[14,956,957],{},"entrypoint file at the root",[61,959,211],{},[61,961,214],{},") and any dependencies.",[54,964,965,968,969,972,973,156,976,133],{},[14,966,967],{},"Node.js:"," The file named in the handler (e.g. ",[61,970,971],{},"index",") must export the handler function—e.g. ",[61,974,975],{},"export const handler = async (event) => { ... }",[61,977,978],{},"exports.handler = async (event) => { ... }",[54,980,981,968,984,986,987,133],{},[14,982,983],{},"Python:",[61,985,397],{},") must define the function—e.g. ",[61,988,989],{},"def handler(event, context): ...",[46,991,993],{"id":992},"handler-and-entrypoint","Handler and entrypoint",[10,995,996,997,999],{},"The ",[14,998,397],{}," is the module and function the runtime runs for each invocation.",[247,1001,1002,1020],{},[54,1003,1004,314,1006,1008,1009,1011,1012,266,1014,156,1017,133],{},[14,1005,967],{},[61,1007,170],{}," — e.g. ",[61,1010,174],{}," means ",[61,1013,211],{},[61,1015,1016],{},"export const handler = ...",[61,1018,1019],{},"exports.handler = ...",[54,1021,1022,314,1024,1008,1026,1011,1028,266,1030,133],{},[14,1023,983],{},[61,1025,410],{},[61,1027,178],{},[61,1029,214],{},[61,1031,989],{},[10,1033,1034,1035,1038,1039,1042],{},"The handler receives an ",[14,1036,1037],{},"event"," (and in Python a ",[14,1040,1041],{},"context","). For public HTTP invocations (see below), the event has a fixed shape. For other invocations (e.g. control plane invoke API or queue/cron triggers), the event is the payload sent by the caller.",[202,1044,1046],{"id":1045},"handler-and-methods","Handler and methods",[247,1048,1049,1075],{},[54,1050,1051,1054,1055,1057,1058,1061,1062,1064,1065,388,1067,388,1069,1071,1072,1074],{},[14,1052,1053],{},"Public URL:"," When ",[61,1056,538],{}," is true, you set ",[14,1059,1060],{},"one"," HTTP method per function via ",[61,1063,558],{}," (",[61,1066,569],{},[61,1068,63],{},[61,1070,574],{},", or ",[61,1073,577],{},"). Requests with a different method receive a method-not-allowed response before your handler runs.",[54,1076,1077,1080,1081,1084],{},[14,1078,1079],{},"Invoke API:"," The same function can be invoked with ",[61,1082,1083],{},"POST /v1/functions/:id/invoke"," and a custom JSON payload. In that case the event is that payload, not the HTTP-shaped object below.",[46,1086,1088],{"id":1087},"event-object-public-http","Event object (public HTTP)",[10,1090,1091,1092,84,1094,1097],{},"When the function is invoked via the ",[14,1093,83],{},[61,1095,1096],{},"https://fn.rocketstack.sh/:tenantToken/:functionName","), the platform passes a single event object:",[339,1099,1100,1110],{},[342,1101,1102],{},[345,1103,1104,1106,1108],{},[348,1105,350],{},[348,1107,353],{},[348,1109,356],{},[358,1111,1112,1127,1142],{},[345,1113,1114,1119,1124],{},[363,1115,1116],{},[61,1117,1118],{},"method",[363,1120,1121],{},[61,1122,1123],{},"'GET' | 'POST' | 'PATCH' | 'DELETE'",[363,1125,1126],{},"The HTTP method of the request.",[345,1128,1129,1134,1139],{},[363,1130,1131],{},[61,1132,1133],{},"query",[363,1135,1136],{},[61,1137,1138],{},"Record\u003Cstring, string | string[]>",[363,1140,1141],{},"Query string parameters.",[345,1143,1144,1149,1152],{},[363,1145,1146],{},[61,1147,1148],{},"body",[363,1150,1151],{},"any",[363,1153,1154,1155,133],{},"Request body (parsed JSON or raw). For GET/DELETE it may be ",[61,1156,518],{},[10,1158,1159,1160,1163,1164,1167,1168,1171],{},"Your handler can branch on ",[61,1161,1162],{},"event.method"," and use ",[61,1165,1166],{},"event.query"," and ",[61,1169,1170],{},"event.body"," to implement the response.",[202,1173,1175],{"id":1174},"example-nodejs-handler-public-http","Example: Node.js handler (public HTTP)",[586,1177,1181],{"className":1178,"code":1179,"language":1180,"meta":23,"style":23},"language-javascript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","// index.js\nexport const handler = async (event) => {\n  const { method, query, body } = event;\n\n  if (method === 'GET') {\n    return {\n      statusCode: 200,\n      headers: { 'Content-Type': 'application/json' },\n      body: JSON.stringify({ message: 'Hello', query })\n    };\n  }\n\n  if (method === 'POST') {\n    return {\n      statusCode: 200,\n      headers: { 'Content-Type': 'application/json' },\n      body: JSON.stringify({ received: body })\n    };\n  }\n\n  return {\n    statusCode: 405,\n    headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({ error: 'Method not allowed' })\n  };\n};\n","javascript",[61,1182,1183,1188,1193,1198,1203,1208,1213,1218,1224,1230,1236,1241,1246,1252,1257,1262,1267,1273,1278,1283,1288,1294,1300,1306,1312,1318],{"__ignoreMap":23},[239,1184,1185],{"class":595,"line":596},[239,1186,1187],{},"// index.js\n",[239,1189,1190],{"class":595,"line":24},[239,1191,1192],{},"export const handler = async (event) => {\n",[239,1194,1195],{"class":595,"line":634},[239,1196,1197],{},"  const { method, query, body } = event;\n",[239,1199,1200],{"class":595,"line":649},[239,1201,1202],{"emptyLinePlaceholder":29},"\n",[239,1204,1205],{"class":595,"line":663},[239,1206,1207],{},"  if (method === 'GET') {\n",[239,1209,1210],{"class":595,"line":677},[239,1211,1212],{},"    return {\n",[239,1214,1215],{"class":595,"line":793},[239,1216,1217],{},"      statusCode: 200,\n",[239,1219,1221],{"class":595,"line":1220},8,[239,1222,1223],{},"      headers: { 'Content-Type': 'application/json' },\n",[239,1225,1227],{"class":595,"line":1226},9,[239,1228,1229],{},"      body: JSON.stringify({ message: 'Hello', query })\n",[239,1231,1233],{"class":595,"line":1232},10,[239,1234,1235],{},"    };\n",[239,1237,1239],{"class":595,"line":1238},11,[239,1240,790],{},[239,1242,1244],{"class":595,"line":1243},12,[239,1245,1202],{"emptyLinePlaceholder":29},[239,1247,1249],{"class":595,"line":1248},13,[239,1250,1251],{},"  if (method === 'POST') {\n",[239,1253,1255],{"class":595,"line":1254},14,[239,1256,1212],{},[239,1258,1260],{"class":595,"line":1259},15,[239,1261,1217],{},[239,1263,1265],{"class":595,"line":1264},16,[239,1266,1223],{},[239,1268,1270],{"class":595,"line":1269},17,[239,1271,1272],{},"      body: JSON.stringify({ received: body })\n",[239,1274,1276],{"class":595,"line":1275},18,[239,1277,1235],{},[239,1279,1281],{"class":595,"line":1280},19,[239,1282,790],{},[239,1284,1286],{"class":595,"line":1285},20,[239,1287,1202],{"emptyLinePlaceholder":29},[239,1289,1291],{"class":595,"line":1290},21,[239,1292,1293],{},"  return {\n",[239,1295,1297],{"class":595,"line":1296},22,[239,1298,1299],{},"    statusCode: 405,\n",[239,1301,1303],{"class":595,"line":1302},23,[239,1304,1305],{},"    headers: { 'Content-Type': 'application/json' },\n",[239,1307,1309],{"class":595,"line":1308},24,[239,1310,1311],{},"    body: JSON.stringify({ error: 'Method not allowed' })\n",[239,1313,1315],{"class":595,"line":1314},25,[239,1316,1317],{},"  };\n",[239,1319,1321],{"class":595,"line":1320},26,[239,1322,1323],{},"};\n",[202,1325,1327],{"id":1326},"example-python-handler-public-http","Example: Python handler (public HTTP)",[586,1329,1333],{"className":1330,"code":1331,"language":1332,"meta":23,"style":23},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# handler.py\nimport json\n\ndef handler(event, context):\n    method = event.get('method', 'GET')\n    query = event.get('query') or {}\n    body = event.get('body')\n\n    if method == 'GET':\n        return {\n            'statusCode': 200,\n            'headers': {'Content-Type': 'application/json'},\n            'body': json.dumps({'message': 'Hello', 'query': query})\n        }\n\n    if method == 'POST':\n        return {\n            'statusCode': 200,\n            'headers': {'Content-Type': 'application/json'},\n            'body': json.dumps({'received': body})\n        }\n\n    return {\n        'statusCode': 405,\n        'headers': {'Content-Type': 'application/json'},\n        'body': json.dumps({'error': 'Method not allowed'})\n    }\n","python",[61,1334,1335,1340,1345,1349,1354,1359,1364,1369,1373,1378,1383,1388,1393,1398,1403,1407,1412,1416,1420,1424,1429,1433,1437,1441,1446,1451,1456],{"__ignoreMap":23},[239,1336,1337],{"class":595,"line":596},[239,1338,1339],{},"# handler.py\n",[239,1341,1342],{"class":595,"line":24},[239,1343,1344],{},"import json\n",[239,1346,1347],{"class":595,"line":634},[239,1348,1202],{"emptyLinePlaceholder":29},[239,1350,1351],{"class":595,"line":649},[239,1352,1353],{},"def handler(event, context):\n",[239,1355,1356],{"class":595,"line":663},[239,1357,1358],{},"    method = event.get('method', 'GET')\n",[239,1360,1361],{"class":595,"line":677},[239,1362,1363],{},"    query = event.get('query') or {}\n",[239,1365,1366],{"class":595,"line":793},[239,1367,1368],{},"    body = event.get('body')\n",[239,1370,1371],{"class":595,"line":1220},[239,1372,1202],{"emptyLinePlaceholder":29},[239,1374,1375],{"class":595,"line":1226},[239,1376,1377],{},"    if method == 'GET':\n",[239,1379,1380],{"class":595,"line":1232},[239,1381,1382],{},"        return {\n",[239,1384,1385],{"class":595,"line":1238},[239,1386,1387],{},"            'statusCode': 200,\n",[239,1389,1390],{"class":595,"line":1243},[239,1391,1392],{},"            'headers': {'Content-Type': 'application/json'},\n",[239,1394,1395],{"class":595,"line":1248},[239,1396,1397],{},"            'body': json.dumps({'message': 'Hello', 'query': query})\n",[239,1399,1400],{"class":595,"line":1254},[239,1401,1402],{},"        }\n",[239,1404,1405],{"class":595,"line":1259},[239,1406,1202],{"emptyLinePlaceholder":29},[239,1408,1409],{"class":595,"line":1264},[239,1410,1411],{},"    if method == 'POST':\n",[239,1413,1414],{"class":595,"line":1269},[239,1415,1382],{},[239,1417,1418],{"class":595,"line":1275},[239,1419,1387],{},[239,1421,1422],{"class":595,"line":1280},[239,1423,1392],{},[239,1425,1426],{"class":595,"line":1285},[239,1427,1428],{},"            'body': json.dumps({'received': body})\n",[239,1430,1431],{"class":595,"line":1290},[239,1432,1402],{},[239,1434,1435],{"class":595,"line":1296},[239,1436,1202],{"emptyLinePlaceholder":29},[239,1438,1439],{"class":595,"line":1302},[239,1440,1212],{},[239,1442,1443],{"class":595,"line":1308},[239,1444,1445],{},"        'statusCode': 405,\n",[239,1447,1448],{"class":595,"line":1314},[239,1449,1450],{},"        'headers': {'Content-Type': 'application/json'},\n",[239,1452,1453],{"class":595,"line":1320},[239,1454,1455],{},"        'body': json.dumps({'error': 'Method not allowed'})\n",[239,1457,1459],{"class":595,"line":1458},27,[239,1460,1461],{},"    }\n",[46,1463,1465],{"id":1464},"handler-return-value","Handler return value",[10,1467,1468,1469,1472],{},"The handler can return any ",[14,1470,1471],{},"JSON-serializable"," value.",[10,1474,1475,1476,1479],{},"For ",[14,1477,1478],{},"public HTTP"," use, a common pattern is to return an object with:",[247,1481,1482,1488,1497],{},[54,1483,1484,1487],{},[61,1485,1486],{},"statusCode"," – HTTP status (e.g. 200, 404).",[54,1489,1490,1493,1494,160],{},[61,1491,1492],{},"headers"," – Object of response headers (e.g. ",[61,1495,1496],{},"{ 'Content-Type': 'application/json' }",[54,1498,1499,1501,1502,160],{},[61,1500,1148],{}," – Response body as a string (e.g. ",[61,1503,1504],{},"JSON.stringify(...)",[10,1506,1507,1508,1167,1511,1514,1515,1167,1517,1519],{},"The gateway sends the invoke result back to the client: the HTTP status of the invoke call is typically 200, and the response body is your handler’s return value. If the client expects a normal HTTP response, it may need to read ",[61,1509,1510],{},"response.data.statusCode",[61,1512,1513],{},"response.data.body"," until the gateway maps the handler’s ",[61,1516,1486],{},[61,1518,1148],{}," to the actual HTTP response.",[10,1521,1475,1522,1525],{},[14,1523,1524],{},"invoke API"," calls, the returned value is simply the JSON your handler returns.",[46,1527,1529],{"id":1528},"invoking-your-function","Invoking your function",[247,1531,1532,1540],{},[54,1533,1534,314,1537,1539],{},[14,1535,1536],{},"Control plane:",[61,1538,1083],{}," with an API key and a JSON body. The body is passed as the event to your handler.",[54,1541,1542,1544,1545,813,1547,1549,1550,1552,1553,1555,1556,1559],{},[14,1543,1053],{}," If ",[61,1546,538],{},[61,1548,546],{},", call ",[61,1551,1096],{}," with the method set in ",[61,1554,558],{},". The platform builds the ",[61,1557,1558],{},"{ method, query, body }"," event and passes it to your handler.",[46,1561,1563],{"id":1562},"summary","Summary",[339,1565,1566,1576],{},[342,1567,1568],{},[345,1569,1570,1573],{},[348,1571,1572],{},"Step",[348,1574,1575],{},"Action",[358,1577,1578,1609,1625],{},[345,1579,1580,1582],{},[363,1581,510],{},[363,1583,1584,266,1586,1588,1589,388,1591,388,1593,388,1595,1597,1598,388,1600,388,1602,388,1604,388,1606,1608],{},[61,1585,317],{},[61,1587,326],{},": ",[61,1590,367],{},[61,1592,380],{},[61,1594,397],{},[61,1596,61],{}," (ZIP). Optionally set ",[61,1599,453],{},[61,1601,469],{},[61,1603,484],{},[61,1605,538],{},[61,1607,558],{},", etc.",[345,1610,1611,1614],{},[363,1612,1613],{},"2",[363,1615,1616,1617,1620,1621,813,1623,133],{},"Poll ",[61,1618,1619],{},"GET /v1/functions/:resourceId"," until ",[61,1622,775],{},[61,1624,73],{},[345,1626,1627,1630],{},[363,1628,1629],{},"3",[363,1631,1632,1633,1635],{},"Invoke via ",[61,1634,1083],{}," with a custom payload, or via the public URL with the configured HTTP method.",[10,1637,1638,1639,1641,1642,388,1644,388,1646,1648],{},"Use the handler string and runtime (Node or Python) to match your entrypoint file and export. For public HTTP, handle the ",[61,1640,1558],{}," event and return a value (e.g. ",[61,1643,1486],{},[61,1645,1492],{},[61,1647,1148],{},") that your client or gateway can use.",[918,1650,1651],{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":23,"searchDepth":24,"depth":24,"links":1653},[1654,1655,1658,1662,1663,1664],{"id":948,"depth":24,"text":949},{"id":992,"depth":24,"text":993,"children":1656},[1657],{"id":1045,"depth":634,"text":1046},{"id":1087,"depth":24,"text":1088,"children":1659},[1660,1661],{"id":1174,"depth":634,"text":1175},{"id":1326,"depth":634,"text":1327},{"id":1464,"depth":24,"text":1465},{"id":1528,"depth":24,"text":1529},{"id":1562,"depth":24,"text":1563},"Handler, event shape, and examples.",{},"/docs/guides/how-to-create-a-function-code",{"title":20,"description":1665},"docs/guides/how-to-create-a-function-code","hhKfB8uzuQagBkgq0582SaNFmV7VfPOfIDtmLLX5bT4",null,1783778559611]