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_id
string Yes Unique ID of the function to update.
Parameter Type Required Description namespace
string Yes Namespace of the function. name
string Yes Function name. file
binary Yes Updated compiled .wasm
file (optional). source_code
string 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 code
string Yes Status code (SUCCESS
if successful, otherwise an error code). message
string Yes Response message. data
object Yes Contains the updated function details. data.function_id
string Yes The unique identifier of the function. data.version
string Yes Updated function version.
Field Type Description Example code
string The error code indicating the type of issue. InvalidParameter
message
string A detailed message describing the error. wrong cursor