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 the session name on WhatsApp (on connected devices)
deliveryCallbackUrlstringWebhook endpoint for delivered messages - delivery
receivedCallbackUrlstringWebhook endpoint for received messages - receive
receivedAndDeliveryCallbackUrlstringWebhook endpoint for received and sent messages - receive
presenceChatCallbackUrlstringWebhook endpoint for chat status updates - presenceChat
disconnectedCallbackUrlstringWebhook endpoint for disconnection or communication loss - disconnected
connectedCallbackUrlstringWebhook endpoint for connection events - connected
messageStatusCallbackUrlstringWebhook endpoint for message status updates - messageStatus
callRejectAutobooleanAutomatically reject incoming calls - "true" or "false"
callRejectMessagestringMessage sent after automatically rejecting a call
autoReadMessagebooleanAutomatically mark messages as read - "true" or "false"
autoReadStatusbooleanAutomatically mark status as read - "true" or "false"
isDevicebooleanDefines whether the instance is mobile or web; if "true", it will be mobile
businessDevicebooleanChoose between WhatsApp Business or regular WhatsApp
disableEnqueueWhenDisconnectedbooleanEnable/disable message queueing when creating the instance

Request Body#

Method

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

Example

{
"name": "Instancia Z-API - 9292812",
"sessionName": "Testes testes",
"deliveryCallbackUrl": "https://mywebhook.com/delivery",
"receivedCallbackUrl": "https://mywebhook.com/receive",
"receivedAndDeliveryCallbackUrl": "https://mywebhook.com/receivedanddelivery",
"disconnectedCallbackUrl": "https://mywebhook.com/disconnected",
"connectedCallbackUrl": "https://mywebhook.com/receive",
"presenceChatCallbackUrl": "https://mywebhook.com/presencechat",
"messageStatusCallbackUrl": "https://mywebhook.com/status",
"callRejectAuto": false,
"callRejectMessage": "Test message for rejected calls",
"autoReadMessage": false,
"autoReadStatus": false,
"isDevice": false,
"businessDevice": false,
"disableEnqueueWhenDisconnected": 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#