The Update Function API allows applications to update a registered function script. This includes updating the executable file or source code and modifying the function name or input schema.
📘 Public Request Parameters
Parameter Type Required Description function_idstring Yes Unique ID of the function to update.
Parameter Type Required Description namespacestring Yes Namespace of the function. namestring Yes Function name. filebinary Yes Updated compiled .wasm file (optional). source_codestring Yes Updated function source code (optional).
curl --location --request POST 'https://partners.shoplazza.com/openapi/2024-07/functions/${function_id}' \
--header 'Content-type:multipart/form-data' \
--header 'x-app-client-id:xxxx' \
--header 'X-Shoplazza-Access-Token:xxxx' \
--form 'namespace="cart-transform"' \
--form 'name="my-cart-transform-demo"' \
--form 'source_code="const input=readInput();const object=discountFunc(input);writeOutput(object);function readInput(){const chunkSize=1024;const inputChunks=[];let totalBytes=0;while(1){const buffer=new Uint8Array(chunkSize);const fd=0;const bytesRead=Javy.IO.readSync(fd,buffer);totalBytes+=bytesRead;if(bytesRead===0){break}inputChunks.push(buffer.subarray(0,bytesRead))}const{finalBuffer}=inputChunks.reduce((context,chunk)=>{context.finalBuffer.set(chunk,context.bufferOffset);context.bufferOffset+=chunk.length;return context},{bufferOffset:0,finalBuffer:new Uint8Array(totalBytes)});return JSON.parse(new TextDecoder().decode(finalBuffer))}function writeOutput(output){const encodedOutput=new TextEncoder().encode(JSON.stringify(output));const buffer=new Uint8Array(encodedOutput);const fd=1;Javy.IO.writeSync(fd,buffer)}function discountFunc(input){let config=input.discountNode?.metafield?.value;config=config?JSON.parse(config):null;let cartLines=input.cart.lines;if(!cartLines.length||!config||config.percentage===0){return{discounts:[],discountApplicationStrategy:'\''First'\''}}let targets=[];for(let line of cartLines){if(line.quantity>=config.quantity){targets.push({id:line.merchandise.id||'\'''\'',quantity:null})}}if(!targets.length){return{discounts:[],discountApplicationStrategy:'\''First'\''}}return{discounts:[{message:null,conditions:null,targets,value:{percentage:config.percentage}}],discountApplicationStrategy:'\''First'\''}}"' \
--form 'file=@"/Users/shoplazza/Desktop/go/functions-api/tests/build/rust_function.wasm"'
📘 Public Response Parameters
Parameter Type Required Description codestring Yes Status code (SUCCESS if successful, otherwise an error code). messagestring Yes Response message. dataobject Yes Contains the updated function details. data.function_idstring Yes The unique identifier of the function. data.versionstring Yes Updated function version.
Field Type Description Example codestring The error code indicating the type of issue. InvalidParametermessagestring A detailed message describing the error. wrong cursor