Creating a function with the API

Functions let you interact with your connected tool’s API to retrieve specific information before send a request (webhook) to K inventory. For example, they can retrieve a category or product identifier and include it in your queries.

How do you create a function?

1. Go to Functions

    • In the K inventory main menu, click on the “PARAMETERS” TAB..
    • In the “Automation” sectionsection, click on on “Functions”..

 

api k inventory menu

 

2. Create a new function

    • Click on the “TO CREATE A FUNCTION..
    • Give your function a clear, descriptive name (e.g. “Retrieve product ID”).

 

Tool-based function creation in K inventory

 

3. Configure your function

    • Select connection : Choose the connection you have previously configured with the tool whose information you wish to retrieve.
    • Select the : Select the appropriate HTTP method for your request (GET, POST, etc.). The list of available methods will depend on your tool’s API capabilities.

 

  1. Method api K inventory

 

    • Enter the URL : Specify the complete URL of the API your function should call to retrieve the desired information. This URL must point to the specific resource you are targeting (for example, /products/{product_id}).
    • Request body (optional): If your method requires additional data (e.g. for a POST request), you can enter it here in JSON format.
  1. Save and use your function
    • Click on “Save” button. Votre fonction est maintenant prête à être utilisée dans vos requêtes sortantes (webhooks).

save button K inventoryKey points to remember

  • The functions are executed before the webhook request is sent.
  • They allow you to retrieve dynamic data from your tool and include it in your queries.
  • Make sure you understand your tool’s API documentation to build the URL and request body of your function correctly.