[{"data":1,"prerenderedAt":424},["ShallowReactive",2],{"content-query-VMSkHQgs1D":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"sidebar_position":10,"body":11,"_type":418,"_id":419,"_source":420,"_file":421,"_stem":422,"_extension":423},"/docs/features/serverless-functions","features",false,"","Serverless Functions & Webhooks","Extend the core capabilities of your database by running custom backend code and responding to system events in real time.",4,{"type":12,"children":13,"toc":408},"root",[14,22,27,34,39,46,51,87,93,98,319,325,330,336,383,389,402],{"type":15,"tag":16,"props":17,"children":19},"element","h1",{"id":18},"serverless-functions-webhooks",[20],{"type":21,"value":8},"text",{"type":15,"tag":23,"props":24,"children":25},"p",{},[26],{"type":21,"value":9},{"type":15,"tag":28,"props":29,"children":31},"h2",{"id":30},"serverless-functions",[32],{"type":21,"value":33},"Serverless Functions",{"type":15,"tag":23,"props":35,"children":36},{},[37],{"type":21,"value":38},"CredVault Functions allow you to deploy JavaScript or Python code directly to the edge, executed via HTTP requests without provisioning servers.",{"type":15,"tag":40,"props":41,"children":43},"h3",{"id":42},"functional-tiering",[44],{"type":21,"value":45},"Functional Tiering",{"type":15,"tag":23,"props":47,"children":48},{},[49],{"type":21,"value":50},"Your ability to execute functions scales with your billing tier:",{"type":15,"tag":52,"props":53,"children":54},"ul",{},[55,67,77],{"type":15,"tag":56,"props":57,"children":58},"li",{},[59,65],{"type":15,"tag":60,"props":61,"children":62},"strong",{},[63],{"type":21,"value":64},"Starter Tier",{"type":21,"value":66},": 100,000 executions/month (128MB Memory).",{"type":15,"tag":56,"props":68,"children":69},{},[70,75],{"type":15,"tag":60,"props":71,"children":72},{},[73],{"type":21,"value":74},"Pro Tier",{"type":21,"value":76},": 5,000,000 executions/month (512MB Memory, longer timeouts).",{"type":15,"tag":56,"props":78,"children":79},{},[80,85],{"type":15,"tag":60,"props":81,"children":82},{},[83],{"type":21,"value":84},"Enterprise",{"type":21,"value":86},": Unlimited executions, Dedicated resources, VPC Peering.",{"type":15,"tag":40,"props":88,"children":90},{"id":89},"creating-a-function",[91],{"type":21,"value":92},"Creating a Function",{"type":15,"tag":23,"props":94,"children":95},{},[96],{"type":21,"value":97},"Write a simple module and deploy it from your Dashboard or via the CLI:",{"type":15,"tag":99,"props":100,"children":104},"pre",{"className":101,"code":102,"language":103,"meta":7,"style":7},"language-javascript shiki shiki-themes github-dark","export default async function(req, res, db) {\n    // You get authenticated, direct access to your database instance in the context\n    const recentSignups = await db.collection('users').find().sort({createdAt: -1}).limit(5);\n    return res.json({ latest: recentSignups });\n}\n","javascript",[105],{"type":15,"tag":106,"props":107,"children":108},"code",{"__ignoreMap":7},[109,172,182,287,310],{"type":15,"tag":110,"props":111,"children":114},"span",{"class":112,"line":113},"line",1,[115,121,126,131,136,142,148,153,158,162,167],{"type":15,"tag":110,"props":116,"children":118},{"style":117},"--shiki-default:#F97583",[119],{"type":21,"value":120},"export",{"type":15,"tag":110,"props":122,"children":123},{"style":117},[124],{"type":21,"value":125}," default",{"type":15,"tag":110,"props":127,"children":128},{"style":117},[129],{"type":21,"value":130}," async",{"type":15,"tag":110,"props":132,"children":133},{"style":117},[134],{"type":21,"value":135}," function",{"type":15,"tag":110,"props":137,"children":139},{"style":138},"--shiki-default:#E1E4E8",[140],{"type":21,"value":141},"(",{"type":15,"tag":110,"props":143,"children":145},{"style":144},"--shiki-default:#FFAB70",[146],{"type":21,"value":147},"req",{"type":15,"tag":110,"props":149,"children":150},{"style":138},[151],{"type":21,"value":152},", ",{"type":15,"tag":110,"props":154,"children":155},{"style":144},[156],{"type":21,"value":157},"res",{"type":15,"tag":110,"props":159,"children":160},{"style":138},[161],{"type":21,"value":152},{"type":15,"tag":110,"props":163,"children":164},{"style":144},[165],{"type":21,"value":166},"db",{"type":15,"tag":110,"props":168,"children":169},{"style":138},[170],{"type":21,"value":171},") {\n",{"type":15,"tag":110,"props":173,"children":175},{"class":112,"line":174},2,[176],{"type":15,"tag":110,"props":177,"children":179},{"style":178},"--shiki-default:#6A737D",[180],{"type":21,"value":181},"    // You get authenticated, direct access to your database instance in the context\n",{"type":15,"tag":110,"props":183,"children":185},{"class":112,"line":184},3,[186,191,197,202,207,212,218,222,228,233,238,243,248,253,258,263,268,273,277,282],{"type":15,"tag":110,"props":187,"children":188},{"style":117},[189],{"type":21,"value":190},"    const",{"type":15,"tag":110,"props":192,"children":194},{"style":193},"--shiki-default:#79B8FF",[195],{"type":21,"value":196}," recentSignups",{"type":15,"tag":110,"props":198,"children":199},{"style":117},[200],{"type":21,"value":201}," =",{"type":15,"tag":110,"props":203,"children":204},{"style":117},[205],{"type":21,"value":206}," await",{"type":15,"tag":110,"props":208,"children":209},{"style":138},[210],{"type":21,"value":211}," db.",{"type":15,"tag":110,"props":213,"children":215},{"style":214},"--shiki-default:#B392F0",[216],{"type":21,"value":217},"collection",{"type":15,"tag":110,"props":219,"children":220},{"style":138},[221],{"type":21,"value":141},{"type":15,"tag":110,"props":223,"children":225},{"style":224},"--shiki-default:#9ECBFF",[226],{"type":21,"value":227},"'users'",{"type":15,"tag":110,"props":229,"children":230},{"style":138},[231],{"type":21,"value":232},").",{"type":15,"tag":110,"props":234,"children":235},{"style":214},[236],{"type":21,"value":237},"find",{"type":15,"tag":110,"props":239,"children":240},{"style":138},[241],{"type":21,"value":242},"().",{"type":15,"tag":110,"props":244,"children":245},{"style":214},[246],{"type":21,"value":247},"sort",{"type":15,"tag":110,"props":249,"children":250},{"style":138},[251],{"type":21,"value":252},"({createdAt: ",{"type":15,"tag":110,"props":254,"children":255},{"style":117},[256],{"type":21,"value":257},"-",{"type":15,"tag":110,"props":259,"children":260},{"style":193},[261],{"type":21,"value":262},"1",{"type":15,"tag":110,"props":264,"children":265},{"style":138},[266],{"type":21,"value":267},"}).",{"type":15,"tag":110,"props":269,"children":270},{"style":214},[271],{"type":21,"value":272},"limit",{"type":15,"tag":110,"props":274,"children":275},{"style":138},[276],{"type":21,"value":141},{"type":15,"tag":110,"props":278,"children":279},{"style":193},[280],{"type":21,"value":281},"5",{"type":15,"tag":110,"props":283,"children":284},{"style":138},[285],{"type":21,"value":286},");\n",{"type":15,"tag":110,"props":288,"children":289},{"class":112,"line":10},[290,295,300,305],{"type":15,"tag":110,"props":291,"children":292},{"style":117},[293],{"type":21,"value":294},"    return",{"type":15,"tag":110,"props":296,"children":297},{"style":138},[298],{"type":21,"value":299}," res.",{"type":15,"tag":110,"props":301,"children":302},{"style":214},[303],{"type":21,"value":304},"json",{"type":15,"tag":110,"props":306,"children":307},{"style":138},[308],{"type":21,"value":309},"({ latest: recentSignups });\n",{"type":15,"tag":110,"props":311,"children":313},{"class":112,"line":312},5,[314],{"type":15,"tag":110,"props":315,"children":316},{"style":138},[317],{"type":21,"value":318},"}\n",{"type":15,"tag":28,"props":320,"children":322},{"id":321},"webhooks",[323],{"type":21,"value":324},"Webhooks",{"type":15,"tag":23,"props":326,"children":327},{},[328],{"type":21,"value":329},"Don't poll the database—let the database notify you. Webhooks allow you to listen for specific events across the platform and trigger external systems.",{"type":15,"tag":40,"props":331,"children":333},{"id":332},"supported-events",[334],{"type":21,"value":335},"Supported Events",{"type":15,"tag":52,"props":337,"children":338},{},[339,350,361,372],{"type":15,"tag":56,"props":340,"children":341},{},[342,348],{"type":15,"tag":106,"props":343,"children":345},{"className":344},[],[346],{"type":21,"value":347},"document.created",{"type":21,"value":349},": Fired when a new record is inserted.",{"type":15,"tag":56,"props":351,"children":352},{},[353,359],{"type":15,"tag":106,"props":354,"children":356},{"className":355},[],[357],{"type":21,"value":358},"user.registered",{"type":21,"value":360},": Fired upon successful user signup.",{"type":15,"tag":56,"props":362,"children":363},{},[364,370],{"type":15,"tag":106,"props":365,"children":367},{"className":366},[],[368],{"type":21,"value":369},"cluster.scaling",{"type":21,"value":371},": Fired when a cluster automatically scales up due to traffic.",{"type":15,"tag":56,"props":373,"children":374},{},[375,381],{"type":15,"tag":106,"props":376,"children":378},{"className":377},[],[379],{"type":21,"value":380},"billing.invoice.paid",{"type":21,"value":382},": Fired for accounting synchronizations.",{"type":15,"tag":40,"props":384,"children":386},{"id":385},"security",[387],{"type":21,"value":388},"Security",{"type":15,"tag":23,"props":390,"children":391},{},[392,394,400],{"type":21,"value":393},"CredVault signs all outbound Webhook payloads using a secret key. You can verify the ",{"type":15,"tag":106,"props":395,"children":397},{"className":396},[],[398],{"type":21,"value":399},"X-CredVault-Signature",{"type":21,"value":401}," header to guarantee that incoming HTTP requests genuinely originated from our servers.",{"type":15,"tag":403,"props":404,"children":405},"style",{},[406],{"type":21,"value":407},"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);}",{"title":7,"searchDepth":174,"depth":174,"links":409},[410,414],{"id":30,"depth":174,"text":33,"children":411},[412,413],{"id":42,"depth":184,"text":45},{"id":89,"depth":184,"text":92},{"id":321,"depth":174,"text":324,"children":415},[416,417],{"id":332,"depth":184,"text":335},{"id":385,"depth":184,"text":388},"markdown","content:docs:features:serverless-functions.md","content","docs/features/serverless-functions.md","docs/features/serverless-functions","md",1777847380901]