Chatbot and AI

Create/Edit API Function

Creates, edits or deletes an API function for integration with external services. Send an empty id to create, filled to edit, delete=true to delete.

POSThttps://api.zapzapapi.com/api/v1/{instanceId}/function/edit

Authentication with the x-api-key and x-api-secret headers.

Parameters

NameTypeInRequiredDescription
idtextbodyYesFunction ID. Empty to create a new one, filled to edit an existing one.
deleteselectbodyYesIf true, deletes the function specified by the ID.
functionjsonbodyYesFunction configuration (JSON)

Request example

curl

curl -X POST "https://api.zapzapapi.com/api/v1/{instanceId}/function/edit" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "x-api-secret: YOUR_API_SECRET" \
  -H "Content-Type: application/json" \
  -d '{"id":"id","delete":true,"function":{"name":"minha_funcao","description":"Descricao da funcao","active":false,"method":"GET","endpoint":"https://api.example.com/endpoint","headers":{},"body":{},"parameters":[]}}'

Node.js

const res = await fetch("https://api.zapzapapi.com/api/v1/{instanceId}/function/edit", {
  method: "POST",
  headers: {
    "x-api-key": "YOUR_API_KEY",
    "x-api-secret": "YOUR_API_SECRET",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "id": "id",
    "delete": true,
    "function": {
      "name": "minha_funcao",
      "description": "Descricao da funcao",
      "active": false,
      "method": "GET",
      "endpoint": "https://api.example.com/endpoint",
      "headers": {},
      "body": {},
      "parameters": []
    }
  }),
});
console.log(await res.json());

Python

import requests

res = requests.post(
    "https://api.zapzapapi.com/api/v1/{instanceId}/function/edit",
    headers={"x-api-key": "YOUR_API_KEY", "x-api-secret": "YOUR_API_SECRET"},
    json={"id":"id","delete":True,"function":{"name":"minha_funcao","description":"Descricao da funcao","active":False,"method":"GET","endpoint":"https://api.example.com/endpoint","headers":{},"body":{},"parameters":[]}},
)
print(res.json())

Response example

JSON

{
  "id": "r72440ced9503e3",
  "name": "minha_funcao",
  "description": "Descricao da funcao",
  "active": false,
  "method": "GET",
  "endpoint": "https://api.example.com/endpoint",
  "headers": "{}",
  "body": "{}",
  "parameters": "[]"
}

Values are illustrative; the fields follow the real response format.

See the full reference

Get your API keys

Create your account, connect a number in minutes and start using the API. R$15 per active number/month, with a welcome credit when you create the account, subject to the current campaign.