### API Example Payload Source: https://mz-wlpartners.readme.io/reference/criarparawhatsappapi2 An example JSON payload for an API call, demonstrating the structure for specifying an event's name, description, start time, and whether to create a follow-up. This example serves as a template for interacting with the API. ```json { "name": "name", "description": "description", "startAt": "2025-03-15T20:00:00.000Z", "createFollowUp": true } ``` -------------------------------- ### Send WhatsApp Message - Node.js Source: https://mz-wlpartners.readme.io/reference/mensagem Example Node.js code snippet using 'axios' to send a message to WhatsApp. It demonstrates setting up the request with the API endpoint, headers, and the JSON payload containing channel, contact, and message details. Ensure 'axios' is installed (`npm install axios`). ```javascript const axios = require('axios'); const sendMessage = async (token, channelInfo, contactInfo, messageContent) => { try { const response = await axios.post('https://api.mz-wlpartners.com/v2/messages/wa/api', { channel: channelInfo, contact: contactInfo, messages: messageContent }, { headers: { 'client-token': token, 'content-type': 'application/json' } }); return response.data; } catch (error) { console.error('Error sending message:', error.response ? error.response.data : error.message); throw error; } }; // Example usage: // const token = 'YOUR_CLIENT_TOKEN'; // const channel = { name: 'whatsapp', 'config-channel': { ... } }; // const contact = { phone: '1234567890', name: 'Contact Name' }; // const messages = [{ type: 'text', text: { body: 'Hello from API!' } }]; // sendMessage(token, channel, contact, messages).then(data => console.log(data)).catch(err => console.error(err)); ``` -------------------------------- ### Example WhatsApp Template Message with Body and Header Parameters Source: https://mz-wlpartners.readme.io/reference/criarparawhatsappapi This example shows a WhatsApp template message with parameters for the body and header, along with button configurations. It includes details for dynamic content in the message body and header, and a button with parameters. ```json { "channel": { "id": "5513999999999", "type": "WHATSAPP" }, "contact": { "id": "5513888888888", "name": "Nome do Contato" }, "messages": [ { "template": { "body": { "parameters": [ { "index": 1, "value": "body1" }, { "index": 2, "value": "body2" } ] }, "buttons": [ { "index": 1, "parameters": [ { "index": 1, "value": "btn1" } ] } ], "header": { "parameters": [ { "index": 1, "value": "header1" } ] }, "language": "pt_BR", "name": "template_name" }, "type": "TEMPLATE" } ] } ``` -------------------------------- ### Add Note Python Request Example Source: https://mz-wlpartners.readme.io/reference/anota%C3%A7%C3%A3o This example shows how to add a note to a support ticket using Python. It commonly uses the 'requests' library to perform the HTTP POST request with the necessary headers. ```python import requests url = 'https://api.mz-wlpartners.com/v2/tickets/uuid/notes' headers = { 'accept': 'application/json', 'content-type': 'application/json' } response = requests.post(url, headers=headers) print(response.json()) ``` -------------------------------- ### Send WhatsApp Message - Python Source: https://mz-wlpartners.readme.io/reference/mensagem Example Python code snippet using the 'requests' library to send a message to WhatsApp. It shows how to construct the POST request with the API endpoint, headers, and the JSON payload. Make sure the 'requests' library is installed (`pip install requests`). ```python import requests import json def send_whatsapp_message(token, channel_info, contact_info, messages): url = "https://api.mz-wlpartners.com/v2/messages/wa/api" headers = { "client-token": token, "content-type": "application/json" } payload = { "channel": channel_info, "contact": contact_info, "messages": messages } try: response = requests.post(url, headers=headers, data=json.dumps(payload)) response.raise_for_status() # Raise an exception for bad status codes return response.json() except requests.exceptions.RequestException as e: print(f"Error sending message: {e}") return None # Example usage: # client_token = 'YOUR_CLIENT_TOKEN' # channel_data = {'name': 'whatsapp', 'config-channel': {...}} # contact_data = {'phone': '1234567890', 'name': 'Contact Name'} # message_data = [{'type': 'text', 'text': {'body': 'Hello from API!'}}] # result = send_whatsapp_message(client_token, channel_data, contact_data, message_data) # if result: # print(result) ``` -------------------------------- ### Add Note Ruby Request Example Source: https://mz-wlpartners.readme.io/reference/anota%C3%A7%C3%A3o This example illustrates how to add a note to a support ticket using Ruby. It typically involves using the 'Net::HTTP' module or a gem like 'httparty' to construct and send the POST request with required headers. ```ruby # Example using Net::HTTP require 'net/http' require 'uri' uri = URI.parse('https://api.mz-wlpartners.com/v2/tickets/uuid/notes') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request['accept'] = 'application/json' request['content-type'] = 'application/json' response = http.request(request) puts response.body ``` -------------------------------- ### Example WhatsApp Template Message with Buttons Source: https://mz-wlpartners.readme.io/reference/criarparawhatsappapi This example demonstrates how to structure a WhatsApp template message that includes interactive buttons. It specifies the channel, contact, message type, and the template details including language, name, and button configurations with callback URLs. ```json { "channel": { "id": "5513999999999", "type": "WHATSAPP" }, "contact": { "id": "5513888888888", "name": "Nome do Contato" }, "messages": [ { "template": { "buttons": [ { "index": 1, "payload": { "callback": "https://endpoint/webhooks?custom-parameter=true" } }, { "index": 2, "payload": { "callback": "https://endpoint/webhooks?custom-parameter=false" } } ], "language": "pt_BR", "name": "template_name" }, "type": "TEMPLATE" } ] } ``` -------------------------------- ### Add Note cURL Request Example Source: https://mz-wlpartners.readme.io/reference/anota%C3%A7%C3%A3o This example demonstrates how to add a note to a support ticket using a cURL request. It specifies the HTTP POST method, the target URL including the ticket UUID, and necessary headers for content type and acceptance of JSON. ```shell curl --request POST \ --url https://api.mz-wlpartners.com/v2/tickets/uuid/notes \ --header 'accept: application/json' \ --header 'content-type: application/json' ``` -------------------------------- ### Create or Update Contact API Examples (Node.js, Ruby, PHP, Python) Source: https://mz-wlpartners.readme.io/reference/contato Examples for creating or updating contacts using the mz-wlpartners.com API v2.0. These snippets demonstrate how to make a POST request to the /v2/contacts endpoint in Node.js, Ruby, PHP, and Python, including necessary headers and body parameters. ```javascript const url = 'https://api.mz-wlpartners.com/v2/contacts'; const options = { method: 'POST', headers: { 'accept': 'application/json', 'content-type': 'application/json' }, body: JSON.stringify({ channel: {}, contact: {} }) }; fetch(url, options) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` ```ruby require 'uri' require 'net/http' url = URI('https://api.mz-wlpartners.com/v2/contacts') http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request['accept'] = 'application/json' request['content-type'] = 'application/json' request.body = JSON.dump({ channel: {}, contact: {} }) response = http.request(request) puts response.read_body ``` ```php $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => 'https://api.mz-wlpartners.com/v2/contacts', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => [ 'accept: application/json', 'content-type: application/json' ], CURLOPT_POSTFIELDS => json_encode([ 'channel' => new stdClass(), 'contact' => new stdClass() ]) ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #" . $err; } else { echo $response; } ``` ```python import requests import json url = 'https://api.mz-wlpartners.com/v2/contacts' headers = { 'accept': 'application/json', 'content-type': 'application/json' } payload = { 'channel': {}, 'contact': {} } response = requests.post(url, headers=headers, data=json.dumps(payload)) print(response.json()) ``` -------------------------------- ### Message Structure and Examples Source: https://mz-wlpartners.readme.io/reference/criarparawhatsappqrcode1 Defines the structure for various message types (TEXT, IMAGE, VIDEO, AUDIO, FILE, INTEGRATION) and provides an example of a QR code message configuration. It includes parameters for message content, scheduling, recurrence, and reminders. ```json { "name": "name", "description": "description", "startAt": "2025-03-15T15:54:00.000Z", "createFollowUp": false, "messages": [ { "text": "Olá!", "type": "TEXT" }, { "fileName": "image.jpg", "type": "IMAGE", "url": "https:/url.com/image.jpg" }, { "fileName": "video.mp4f", "type": "VIDEO", "url": "https:/url.com/video.mp4" }, { "fileName": "audio.mp3", "type": "AUDIO", "url": "https:/url.com/audio.mp3" }, { "fileName": "pdf_sample_2.pdf", "type": "FILE", "url": "https:/url.com/file.pdf" }, { "type": "INTEGRATION", "uuid": "9bb466e1-2853-4a34-b081-caf887643837" } ], "recurrence": { "custom": { "finishAt": "2025-03-15T20:00:00.000Z", "finishRule": "NEVER, DATE, TIMES", "finishTimes": 10, "monthRule": "INFORMED_DAY, LAST_DAY", "unit": "DAY, WEEK, MONTH, YEAR", "value": 1, "weekdays": [ 0, 1 ] }, "type": "NO_REPEAT, DAILY, WEEKLY, MONTHLY, MONTHLY_LAST_DAY, EVERY_WEEKDAY, CUSTOM" }, "reminder": { "type": "MINUTE, HOUR, DAY, WEEK", "value": 10 } } ``` -------------------------------- ### Add Note PHP Request Example Source: https://mz-wlpartners.readme.io/reference/anota%C3%A7%C3%A3o This snippet provides an example of adding a note to a support ticket using PHP. It typically uses cURL functions to send a POST request with the specified URL and headers. ```php ``` -------------------------------- ### Create Follow-up Python Request Source: https://mz-wlpartners.readme.io/reference/retorno Example Python request for creating a follow-up to a support ticket using the 'requests' library. Requires ticket UUID, follow-up name, description, start date, recurrence information, reminder settings, and a client token. ```python import requests import json def create_follow_up(uuid, name, description, start_at, recurrence, reminder, client_token): url = f"https://api.mz-wlpartners.com/v2/tickets/{uuid}/follow-ups" headers = { 'accept': 'application/json', 'content-type': 'application/json', 'client-token': client_token } payload = { 'name': name, 'description': description, 'startAt': start_at, 'recurrence': recurrence, 'reminder': reminder } try: response = requests.post(url, headers=headers, data=json.dumps(payload)) response.raise_for_status() # Raise an exception for bad status codes return response.json() except requests.exceptions.RequestException as e: print(f"Error creating follow-up: {e}") return None # Example usage: # ticket_uuid = 'your_ticket_uuid' # follow_up_name = 'Follow-up Name' # follow_up_description = 'Follow-up Description' # start_time = '2023-10-27T10:00:00.000Z' # recurrence_info = { ... } # Define recurrence dict # reminder_info = { ... } # Define reminder dict # client_auth_token = 'your_client_token' # # result = create_follow_up(ticket_uuid, follow_up_name, follow_up_description, start_time, recurrence_info, reminder_info, client_auth_token) # if result: # print(result) ``` -------------------------------- ### Create Follow-up Ruby Request Source: https://mz-wlpartners.readme.io/reference/retorno Example Ruby request for creating a follow-up to a support ticket using the 'net/http' library. Requires ticket UUID, follow-up name, description, start date, recurrence information, reminder settings, and a client token. ```ruby require 'net/http' require 'uri' require 'json' def create_follow_up(uuid, name, description, start_at, recurrence, reminder, client_token) uri = URI.parse("https://api.mz-wlpartners.com/v2/tickets/#{uuid}/follow-ups") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.path, { 'accept' => 'application/json', 'content-type' => 'application/json', 'client-token' => client_token }) payload = { 'name' => name, 'description' => description, 'startAt' => start_at, 'recurrence' => recurrence, 'reminder' => reminder } request.body = payload.to_json begin response = http.request(request) return JSON.parse(response.body) rescue StandardError => e puts "Error creating follow-up: #{e.message}" return nil end end # Example usage: # ticket_uuid = 'your_ticket_uuid' # follow_up_name = 'Follow-up Name' # follow_up_description = 'Follow-up Description' # start_time = '2023-10-27T10:00:00.000Z' # recurrence_info = { ... } # Define recurrence hash # reminder_info = { ... } # Define reminder hash # client_auth_token = 'your_client_token' # # result = create_follow_up(ticket_uuid, follow_up_name, follow_up_description, start_time, recurrence_info, reminder_info, client_auth_token) # if result # puts result.inspect # end ``` -------------------------------- ### Create Follow-up cURL Request Source: https://mz-wlpartners.readme.io/reference/retorno Example cURL request for creating a follow-up to a support ticket. Requires ticket UUID, follow-up name, description, start date, recurrence information, reminder settings, and a client token. ```shell curl --request POST \ --url https://api.mz-wlpartners.com/v2/tickets/uuid/follow-ups \ --header 'accept: application/json' \ --header 'content-type: application/json' ``` -------------------------------- ### Create Follow-up Node.js Request Source: https://mz-wlpartners.readme.io/reference/retorno Example Node.js request for creating a follow-up to a support ticket using the 'axios' library. Requires ticket UUID, follow-up name, description, start date, recurrence information, reminder settings, and a client token. ```javascript const axios = require('axios'); const createFollowUp = async (uuid, name, description, startAt, recurrence, reminder, clientToken) => { try { const response = await axios.post(`https://api.mz-wlpartners.com/v2/tickets/${uuid}/follow-ups`, { name: name, description: description, startAt: startAt, recurrence: recurrence, reminder: reminder }, { headers: { 'accept': 'application/json', 'content-type': 'application/json', 'client-token': clientToken } }); return response.data; } catch (error) { console.error('Error creating follow-up:', error); throw error; } }; // Example usage: // const uuid = 'your_ticket_uuid'; // const name = 'Follow-up Name'; // const description = 'Follow-up Description'; // const startAt = '2023-10-27T10:00:00.000Z'; // const recurrence = { ... }; // Define recurrence object // const reminder = { ... }; // Define reminder object // const clientToken = 'your_client_token'; // // createFollowUp(uuid, name, description, startAt, recurrence, reminder, clientToken) // .then(data => console.log(data)) // .catch(err => console.error(err)); ``` -------------------------------- ### Create Follow-up PHP Request Source: https://mz-wlpartners.readme.io/reference/retorno Example PHP request for creating a follow-up to a support ticket using cURL. Requires ticket UUID, follow-up name, description, start date, recurrence information, reminder settings, and a client token. ```php $name, 'description' => $description, 'startAt' => $startAt, 'recurrence' => $recurrence, 'reminder' => $reminder ]); $headers = [ 'accept: application/json', 'content-type: application/json', 'client-token: ' . $clientToken ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if (curl_errno($ch)) { echo 'Curl error: ' . curl_error($ch); } curl_close($ch); return ['http_code' => $httpCode, 'response' => json_decode($response, true)]; } // Example usage: // $uuid = 'your_ticket_uuid'; // $name = 'Follow-up Name'; // $description = 'Follow-up Description'; // $startAt = '2023-10-27T10:00:00.000Z'; // $recurrence = [ ... ]; // Define recurrence array // $reminder = [ ... ]; // Define reminder array // $clientToken = 'your_client_token'; // // $result = createFollowUp($uuid, $name, $description, $startAt, $recurrence, $reminder, $clientToken); // print_r($result); ?> ``` -------------------------------- ### Create Scheduled WhatsApp Message (cURL) Source: https://mz-wlpartners.readme.io/reference/mensagem-programada This cURL example demonstrates how to make a POST request to create a scheduled WhatsApp message. It includes the endpoint URL, required headers, and an example of the request body. ```shell curl --request POST \ --url https://api.mz-wlpartners.com/v2/tickets/uuid/scheduled-messages/wa/api \ --header 'accept: application/json' \ --header 'content-type: application/json' ``` -------------------------------- ### Add Note Node.js Request Example Source: https://mz-wlpartners.readme.io/reference/anota%C3%A7%C3%A3o This snippet shows how to add a note to a support ticket using Node.js. It utilizes a library like 'axios' or 'node-fetch' to send a POST request with the appropriate URL and headers. ```javascript // Example using node-fetch (ensure it's installed: npm install node-fetch) import fetch from 'node-fetch'; const url = 'https://api.mz-wlpartners.com/v2/tickets/uuid/notes'; const options = { method: 'POST', headers: { 'accept': 'application/json', 'content-type': 'application/json' } }; fetch(url, options) .then(res => res.json()) .then(json => console.log(json)) .catch(err => console.error('error:' + err)); ``` -------------------------------- ### Create Scheduled WhatsApp Message (Ruby) Source: https://mz-wlpartners.readme.io/reference/mensagem-programada This Ruby example shows how to create a scheduled WhatsApp message using an HTTP POST request. It uses the built-in 'net/http' library and 'json' for handling the request and response. ```ruby require 'net/http' require 'uri' require 'json' def create_scheduled_message(uuid, message_data) uri = URI.parse("https://api.mz-wlpartners.com/v2/tickets/#{uuid}/scheduled-messages/wa/api") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request['Content-Type'] = 'application/json' request['Accept'] = 'application/json' request.body = message_data.to_json response = http.request(request) if response.is_a?(Net::HTTPSuccess) JSON.parse(response.body) else puts "HTTP Error: #{response.code} - #{response.message}" puts "Response body: #{response.body}" nil end end # Example usage: # message_payload = { # name: 'Meeting Reminder', # description: 'Reminder for the upcoming meeting', # start_at: '2023-10-27T10:00:00', # create_follow_up: true, # messages: [ # { text: 'Hi, just a reminder about our meeting.' } # ], # recurrence: { # frequency: 'daily', # interval: 1 # }, # reminder: { # days_before: 1 # } # } # # ticket_uuid = 'your-ticket-uuid' # created_message = create_scheduled_message(ticket_uuid, message_payload) # # if created_message # puts "Message created: #{JSON.pretty_generate(created_message)}" # else # puts "Failed to create message." # end ``` -------------------------------- ### Create Scheduled WhatsApp Message (Node.js) Source: https://mz-wlpartners.readme.io/reference/mensagem-programada This Node.js example shows how to create a scheduled WhatsApp message using a POST request. It utilizes the 'axios' library for making HTTP requests and includes the necessary request body structure. ```javascript const axios = require('axios'); const createScheduledMessage = async (uuid, messageData) => { try { const response = await axios.post( `https://api.mz-wlpartners.com/v2/tickets/${uuid}/scheduled-messages/wa/api`, messageData, { headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' } } ); return response.data; } catch (error) { console.error('Error creating scheduled message:', error.response ? error.response.data : error.message); throw error; } }; // Example usage: // const messagePayload = { // name: 'Meeting Reminder', // description: 'Reminder for the upcoming meeting', // startAt: '2023-10-27T10:00:00', // createFollowUp: true, // messages: [ // { // text: 'Hi, just a reminder about our meeting.' // } // ], // recurrence: { // frequency: 'daily', // interval: 1 // }, // reminder: { // daysBefore: 1 // } // }; // // createScheduledMessage('your-ticket-uuid', messagePayload) // .then(data => console.log('Message created:', data)) // .catch(err => console.error('Failed to create message')); ``` -------------------------------- ### Create Scheduled WhatsApp Message (PHP) Source: https://mz-wlpartners.readme.io/reference/mensagem-programada This PHP example illustrates how to send a POST request to create a scheduled WhatsApp message. It uses cURL to handle the HTTP request and includes the necessary JSON payload. ```php = 200 && $httpCode < 300) { return json_decode($response, true); } else { echo "HTTP Error: {$httpCode}" . PHP_EOL; echo "Response: " . $response . PHP_EOL; return null; } } // Example usage: // $messagePayload = [ // 'name' => 'Meeting Reminder', // 'description' => 'Reminder for the upcoming meeting', // 'startAt' => '2023-10-27T10:00:00', // 'createFollowUp' => true, // 'messages' => [ // ['text' => 'Hi, just a reminder about our meeting.'] // ], // 'recurrence' => [ // 'frequency' => 'daily', // 'interval' => 1 // ], // 'reminder' => [ // 'daysBefore' => 1 // ] // ]; // // $ticketUuid = 'your-ticket-uuid'; // $createdMessage = createScheduledMessage($ticketUuid, $messagePayload); // // if ($createdMessage) { // echo 'Message created: ' . json_encode($createdMessage, JSON_PRETTY_PRINT); // } else { // echo 'Failed to create message.' . PHP_EOL; // } ?> ``` -------------------------------- ### Send WhatsApp Message - cURL Source: https://mz-wlpartners.readme.io/reference/mensagem Example cURL request to send a message to WhatsApp. It specifies the POST method, the API endpoint, and the 'content-type' header. The body parameters for channel, contact, and messages need to be included in the actual request. ```shell curl --request POST \ --url https://api.mz-wlpartners.com/v2/messages/wa/api \ --header 'content-type: application/json' ``` -------------------------------- ### Node.js Request to Validate Client Token Source: https://mz-wlpartners.readme.io/reference/token Example of validating a client token using Node.js. This code snippet would typically use a library like 'axios' or the built-in 'fetch' to make the GET request to the validation endpoint. ```javascript // Node.js example would go here, likely using fetch or axios // Example using fetch: /* fetch('https://api.mz-wlpartners.com/v2/client-token/validate', { method: 'GET', headers: { 'accept': 'application/json' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); */ ``` -------------------------------- ### Send WhatsApp Message via QRCode (OpenAPI) Source: https://mz-wlpartners.readme.io/reference/criarparawhatsappqrcode Defines the OpenAPI 3.1.0 specification for sending messages to WhatsApp via QRCode-connected bots. It includes the endpoint, required headers (`client-token`), and the structure for the request body, which specifies channel, contact, and message details (text, image, video, audio, file). This functionality is exclusive to the 'API Completa' plan. ```json { "openapi": "3.1.0", "info": { "title": "API", "version": "2.0.0" }, "tags": [ { "name": "Mensagem" } ], "servers": [ { "url": "https://api.mz-wlpartners.com/v2" } ], "paths": { "/messages/wa/qrcode": { "post": { "tags": [ "Mensagem" ], "summary": "Enviar para WhatsApp - QRCode", "description": "Envia mensagens para o WhatsApp do contato. Apenas para bots conectador via QRCode. Disponível apenas para o plano de API Completa.", "operationId": "criarParaWhatsAppQrCode", "parameters": [ { "name": "client-token", "in": "header", "required": true, "schema": { "type": "string" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "channel", "contact", "messages" ], "properties": { "channel": { "type": "object", "required": [ "id", "type" ], "description": "Informações do canal.", "properties": { "id": { "type": "string", "description": "Número do seu bot" }, "type": { "type": "string", "description": "Tipo do bot" } } }, "contact": { "type": "object", "required": [ "id", "name" ], "description": "Informações do contato.", "properties": { "id": { "type": "string", "description": "Número de telefone do contato" }, "name": { "type": "string", "description": "Nome do contato" } } }, "messages": { "type": "array", "items": { "type": "object", "required": [ "type" ], "properties": { "type": { "type": "string", "description": "Tipo de mensagem." }, "text": { "type": "string", "description": "Caso o tipo seja TEXT, deverá informar a mensagem neste campo." }, "url": { "type": "string", "description": "Caso o tipo seja IMAGE, VIDEO, AUDIO ou FILE, deverá informar a url neste campo." }, "fileName": { "type": "string", "description": "Caso o tipo seja IMAGE, VIDEO, AUDIO ou FILE, deverá informar o nome do arquivo neste campo." } } } } } }, "examples": { "qrcode": { "value": { "channel": { "id": "5513999999999", "type": "WHATSAPP" }, "contact": { "id": "5513888888888", "name": "Nome do Contato" }, "messages": [ { "text": "Hello!", "type": "TEXT" }, { "fileName": "image.jpg", "type": "IMAGE", "url": "https:/url.com/image.jpg" }, { "fileName": "file.mp4", "type": "VIDEO", "url": "https:/url.com/video.mp4" }, { "fileName": "audio.mp3", "type": "AUDIO", "url": "https:/url.com/audio.mp3" }, { "fileName": "file.pdf", "type": "FILE", "url": "https:/url.com/file.pdf" } ] } } } } } } } } } } ``` -------------------------------- ### OpenAPI Definition for Recuperar Ativo Source: https://mz-wlpartners.readme.io/reference/recuperarativo This OpenAPI 3.1.0 definition outlines the structure and parameters for the 'Recuperar Ativo' GET endpoint. It specifies the required headers (client-token) and query parameters (channelId, channelType, contactId) needed to retrieve the active ticket's ID and UUID. The response includes a success example. ```json { "openapi": "3.1.0", "info": { "title": "API", "version": "2.0.0" }, "tags": [ { "name": "Atendimento" } ], "servers": [ { "url": "https://api.mz-wlpartners.com/v2" } ], "paths": { "/tickets/active": { "get": { "tags": [ "Atendimento" ], "summary": "Recuperar Ativo", "description": "Recupera o id e uuid do atendimento ativo para o contato e bot informado", "operationId": "recuperarAtivo", "parameters": [ { "name": "client-token", "in": "header", "required": true, "schema": { "type": "string" } }, { "name": "channelId", "in": "query", "required": true, "schema": { "type": "string" } }, { "name": "channelType", "in": "query", "required": true, "description": "WHATSAPP", "schema": { "type": "string" } }, { "name": "contactId", "in": "query", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "success", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "number" }, "uuid": { "type": "string" } } }, "examples": { "success": { "value": { "id": 1, "uuid": "uuid" } } } } } } } } } } } ``` -------------------------------- ### Criar Mensagem Programada para WhatsApp Source: https://mz-wlpartners.readme.io/reference/criarparawhatsappapi2 Endpoint para criar uma nova mensagem programada no WhatsApp. Utiliza um QRCode para facilitar a configuração ou envio. ```APIDOC ## POST /websites/mz-wlpartners_readme_io_reference ### Description Cria uma mensagem programada para WhatsApp, possivelmente utilizando um QRCode para configuração ou envio. ### Method POST ### Endpoint /websites/mz-wlpartners_readme_io_reference ### Parameters #### Request Body - **message** (string) - Required - O conteúdo da mensagem a ser programada. - **schedule_time** (string) - Required - O horário em que a mensagem deve ser enviada (formato ISO 8601). - **qr_code_data** (string) - Optional - Dados relacionados ao QRCode, se aplicável. ### Request Example ```json { "message": "Olá! Esta é uma mensagem programada.", "schedule_time": "2023-10-27T10:00:00Z", "qr_code_data": "some_qr_code_info" } ``` ### Response #### Success Response (201) - **message_id** (string) - Identificador único da mensagem programada. - **status** (string) - Status da mensagem programada (ex: 'scheduled'). #### Response Example ```json { "message_id": "msg_12345abcde", "status": "scheduled" } ``` ``` -------------------------------- ### Send WhatsApp Message - Ruby Source: https://mz-wlpartners.readme.io/reference/mensagem Example Ruby code snippet using the 'net/http' library to send a message to WhatsApp. It demonstrates constructing the HTTP POST request with the API endpoint, headers, and the JSON payload. This code is part of the standard Ruby library. ```ruby require 'net/http' require 'uri' require 'json' def send_whatsapp_message(token, channel_info, contact_info, messages) uri = URI.parse('https://api.mz-wlpartners.com/v2/messages/wa/api') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request['client-token'] = token request['content-type'] = 'application/json' payload = { 'channel' => channel_info, 'contact' => contact_info, 'messages' => messages } request.body = payload.to_json response = http.request(request) return JSON.parse(response.body) if response.is_a?(Net::HTTPSuccess) puts "Error: #{response.code} #{response.message}" puts response.body nil end # Example usage: # client_token = 'YOUR_CLIENT_TOKEN' # channel_data = {'name': 'whatsapp', 'config-channel': {}} # contact_data = {'phone': '1234567890', 'name': 'Contact Name'} # message_data = [{'type': 'text', 'text': {'body': 'Hello from API!'}}] # result = send_whatsapp_message(client_token, channel_data, contact_data, message_data) # if result # puts result # end ``` -------------------------------- ### Create Follow-up Endpoint - OpenAPI Definition Source: https://mz-wlpartners.readme.io/reference/criar2 Defines the 'create' endpoint for follow-ups within the API. It specifies the HTTP method (POST), request parameters (headers and path parameters), and the request body schema. The schema details required fields like 'name', 'recurrence', 'reminder', and 'startAt', along with optional fields and their types. ```json { "openapi": "3.1.0", "info": { "title": "API", "version": "2.0.0" }, "tags": [ { "name": "Retorno" }, { "name": "Retorno" }, { "name": "Retorno" } ], "servers": [ { "url": "https://api.mz-wlpartners.com/v2" } ], "paths": { "/tickets/{uuid}/follow-ups": { "post": { "tags": [ "Retorno" ], "summary": "Criar", "description": "Cria um retorno no atendimento informado.", "operationId": "criar2", "parameters": [ { "name": "client-token", "in": "header", "required": true, "schema": { "type": "string" } }, { "name": "uuid", "in": "path", "description": "UUID do atendimento.", "required": true, "schema": { "type": "string" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "name", "recurrence", "reminder", "startAt" ], "properties": { "name": { "type": "string", "description": "Nome do retorno." }, "description": { "type": "string", "description": "Descrição do retorno." }, "startAt": { "type": "string", "description": "Data que o retorno será criado. Padrão UTC yyyy-MM-ddTHH:mm:ss." }, "recurrence": { "type": "object", "required": [ "type" ], "description": "Informações sobre a recorrência do retorno.", "properties": { "type": { "type": "string", "description": "NO_REPEAT (não se repete), DAILY (diariamente), WEEKLY (semanalmente), MONTHLY (mensalmente), MONTHLY_LAST_DAY (mensalmente, no último dia do mês), EVERY_WEEKDAY (todos os sábados e domingos), CUSTOM (customizado)" }, "custom": { "type": "object", "required": [ "unit", "value", "finishRule" ], "description": "Caso o type seja CUSTOM, deverá definir a regra de repetição.", "properties": { "unit": { "type": "string", "description": "DAY (dia), WEEK (semana), MONTH (mês), YEAR (ano)" }, "value": { "type": "number", "description": "Quantidade a que será aplicada a regra de repetição. Exemplo - A cada 2 dias -> unit (DAY), value (2)." }, "monthRule": { "type": "string", "description": "Caso o unit seja MONTH, definir qual o dia que será considerado - INFORMED_DAY (data informada no startAt) ou LAST_DAY (último dia do mês)." }, "weekdays": { "type": "array", "description": "Caso o unit seja WEEK, informar os dias da semana - 0 (domingo), 1 (segunda), 2 (terça), 3 (quarta), 4 (quinta), 5 (sexta), 6 (sábado)", "items": { "type": "number", "description": "0 (domingo), 1 (segunda), 2 (terça), 3 (quarta), 4 (quinta), 5 (sexta), 6 (sábado)" } }, "finishRule": { "type": "string", "description": "Controle para informar quando o retorno irá terminar - NEVER (nunca), DATE (data informada), TIMES (quantidade de vezes)" }, "finishAt": { "type": "string", "description": "Caso o finishRule seja DATE, deverá informar a data que o retorno irá terminar. Padrão UTC yyyy-MM-ddTHH:mm:ss." }, "finishTimes": { "type": "number", "description": "Caso o finishRule seja TIMES, deverá informar a quantidade de vezes que o retorno irá terminar." } } } } }, "reminder": { "type": "object", "required": [ "count", "unit" ], "description": "Informações sobre o lembrete do retorno.", "properties": { "count": { "type": "number", "description": "Quantidade de vezes que o lembrete irá disparar." }, "unit": { "type": "string", "description": "UNITS_OF_TIME (unidade de tempo - dia, semana, mês, ano) e PERIOD (unidade de tempo - dias, semanas, meses, anos)." } } } } } } } } } } } } ```