> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: put(request: WixHttpFunctionRequest) # Method package: wixHttpFunctions # Method menu location: wixHttpFunctions --> put # Method Link: https://dev.wix.com/docs/velo/velo-only-apis/wix-http-functions/put.md # Method Description: A function that responds to requests made with the HTTP PUT method. The HTTP PUT method is usually called by consumers to update an existing resource. If defined in this way and the resource is updated, the function should respond with a 200 (OK) status code. If defined in this way and the resource is created because it did not exist, you should respond with a 201 (Created) status code. Respond to the request by returning a [`WixHttpFunctionResponse`](wix-http-functions.WixHttpFunctionResponse.html) object you create using one of the [`response()`](wix-http-functions.html#response), [`ok()`](wix-http-functions.html#ok), [`created()`](wix-http-functions.html#created), [`notFound()`](wix-http-functions.html#notFound), [`serverError()`](wix-http-functions.html#serverError), [`badRequest()`](wix-http-functions.html#badRequest), or [`forbidden()`](wix-http-functions.html#forbidden) functions. The `put()` function is not a function that you call from your code. You define the function in a file named **http-functions.js** in your site's Backend section. The function is called when your users make HTTP requests using the associated URLs as described below. All PUT requests with the following URL will be routed to this function: Premium sites: ``` https://www.{user_domain}/_functions/ ``` Free sites: ``` https://{user_name}.wixsite.com/{site_name}/_functions/ ``` > **Note:** You must publish your site at least once before using both the testing and production endpoints. When you make changes to production endpoints you must publish your site for them to take effect. Testing endpoints will use the latest code in the editor. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Create a PUT HTTP function ```javascript // In http-functions.js import {ok} from 'wix-http-functions'; // URL looks like: // https://www.mysite.com/_functions/myFunction/ // or: // https://user.wixsite.com/mysite/_functions/myFunction/ export function put_myFunction(request) { return request.body.text() .then( (body) => { // update the info from the body somewhere return ok(); } ); } ``` ## Create a PUT HTTP function ```javascript // In http-functions.js import {ok, serverError} from 'wix-http-functions'; import wixData from 'wix-data'; // URL looks like: // https://www.mysite.com/_functions/myFunction/ // or: // https://user.wixsite.com/mysite/_functions/myFunction/ export function put_myFunction(request) { let options = { "headers": { "Content-Type": "application/json" } }; // get the request body return request.body.json() .then( (body) => { // update the item in a collection return wixData.update("myCollection", body); } ) .then( (results) => { options.body = { "inserted": results }; return ok(options); } ) // something went wrong .catch( (error) => { options.body = { "error": error }; return serverError(options); } ); } ``` ---