Skip to main content

Creating an instance

Método#

/on-demand#

POST https://api.z-api.io/instances/integrator/on-demand


Concept#

Method used to create an instance linked to your account.

Tip

You don't necessarily need to subscribe to the instance at this point as you have 2 days to use it as a trial.

Attention

Deleting an instance

If you do not subscribe within 2 days, our devops will automatically delete the machine connected to the instance. So in cases of no signatures you don't have to worry :)


Attributes#

Required#

AttributesTypeDescription
namestringName of instance to be created

Optionals#

AttributesTypeDescription
sessionNamestringAttribute to change session name in whatsapp (on connected devices)
deliveryCallbackUrlstringDelivered Messages Webhook EndPoint - delivery
receivedCallbackUrlstringIncoming Messages Webhook EndPoint - receive
disconnectedCallbackUrlstringWebhook EndPoint disconnected or lost communication - disconnected
connectedCallbackUrlstringConnection webhook endpoint - connected
messageStatusCallbackUrlstringStatus webhook endpoint
isDevicebooleanDefines wether the instance will be mobile or web
businessDevicebooleanChoose between business or normal whatsapp version

Request Body#

Method

POST https://api.z-api.io/instances/integrator/on-demand

Example

{
"name": "Instancia Z-API - 9292812",
"sessionName": "Tests tests",
"deliveryCallbackUrl": "https://meuwebhook.com.br/delivery",
"receivedCallbackUrl": "https://meuwebhook.com.br/receive",
"disconnectedCallbackUrl": "https://meuwebhook.com.br/disconnected",
"connectedCallbackUrl": "https://meuwebhook.com.br/connected",
"messageStatusCallbackUrl": "https://meuwebhook.com.br/status",
"isDevice": false,
"businessDevice": true
}

Response#

200#

AttributesTypeDescription
idstringCreated instance ID
tokenstringTOKEN of the created instance
duetimestampInstance expiration date

Example

{
"id": "8823XWIE982KII99012K2L"
"token": "8900LS009W0011OOOPPIPIP00912OOLCKAOOOE009919"
"due": "329000002121"
}

405#

In this case certify that you are sending the correct specification of the method. This means, verify if you sent a POST or GET as specified at the beginning of this topic.

415#

In case you receive 415 error, make sure to add the “Content-Type” of the object you are sending in the request headers, mostly “application/json”


Webhook Response#

Link to webhook response (on receipt)

Webhook


Code#