Skip to content

Latest commit

 

History

History
1320 lines (1044 loc) · 44.3 KB

MessageSendingApi.md

File metadata and controls

1320 lines (1044 loc) · 44.3 KB

MessageSendingApi

All URIs are relative to /api

Method HTTP request Description
sendAudio POST /instances/{instance_key}/send/audio Send raw audio.
sendButtonMessage POST /instances/{instance_key}/send/buttons Send a button message.
sendButtonWithMedia POST /instances/{instance_key}/send/button-media Send a button message with a media header.
sendContact POST /instances/{instance_key}/send/contact Send a contact message.
sendDocument POST /instances/{instance_key}/send/document Send raw document.
sendGroupInvite POST /instances/{instance_key}/send/group-invite Send a group invite message
sendImage POST /instances/{instance_key}/send/image Send raw image.
sendListMessage POST /instances/{instance_key}/send/list Send a List message.
sendLocation POST /instances/{instance_key}/send/location Send a location message.
sendMediaMessage POST /instances/{instance_key}/send/media Send a media message.
sendPollMessage POST /instances/{instance_key}/send/poll Send a Poll message.
sendTemplate POST /instances/{instance_key}/send/template Send a template message.
sendTemplateWithMedia POST /instances/{instance_key}/send/template-media Send a template message with media.
sendTextMessage POST /instances/{instance_key}/send/text Send a text message.
sendVideo POST /instances/{instance_key}/send/video Send raw video.
uploadMedia POST /instances/{instance_key}/send/upload Upload media.
uploadMediaFromUrl POST /instances/{instance_key}/send/upload-url Upload media from url.

sendAudio

ModelAPIResponse sendAudio(instanceKey, to, sendAudioRequest, caption)

Send raw audio.

Sends a audio message by uploading to the WhatsApp servers every time. This is not recommended for bulk sending.

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    String to = "to_example"; // String | The recipient's number
    SendAudioRequest sendAudioRequest = new SendAudioRequest(); // SendAudioRequest | 
    String caption = "caption_example"; // String | Attached caption
    try {
      ModelAPIResponse result = apiInstance.sendAudio(instanceKey, to, sendAudioRequest, caption);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendAudio");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
to String The recipient's number
sendAudioRequest SendAudioRequest
caption String Attached caption [optional]

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendButtonMessage

ModelAPIResponse sendButtonMessage(instanceKey, data)

Send a button message.

Sends an interactive button message to the given user. Make sure that all the button ids are unique

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    ButtonMessagePayload data = new ButtonMessagePayload(); // ButtonMessagePayload | Message data
    try {
      ModelAPIResponse result = apiInstance.sendButtonMessage(instanceKey, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendButtonMessage");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
data ButtonMessagePayload Message data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendButtonWithMedia

ModelAPIResponse sendButtonWithMedia(instanceKey, data)

Send a button message with a media header.

Sends an interactive button message to the given user. This message also has media header with it. Make sure that all the button ids are unique

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    ButtonMessageWithMediaPayload data = new ButtonMessageWithMediaPayload(); // ButtonMessageWithMediaPayload | Message data
    try {
      ModelAPIResponse result = apiInstance.sendButtonWithMedia(instanceKey, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendButtonWithMedia");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
data ButtonMessageWithMediaPayload Message data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendContact

ModelAPIResponse sendContact(instanceKey, data)

Send a contact message.

Sends a contact (vcard) message to the given user.

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    ContactMessagePayload data = new ContactMessagePayload(); // ContactMessagePayload | Message data
    try {
      ModelAPIResponse result = apiInstance.sendContact(instanceKey, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendContact");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
data ContactMessagePayload Message data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendDocument

ModelAPIResponse sendDocument(instanceKey, to, sendDocumentRequest, caption)

Send raw document.

Sends a document message by uploading to the WhatsApp servers every time. This is not recommended for bulk sending.

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    String to = "to_example"; // String | The recipient's number
    SendDocumentRequest sendDocumentRequest = new SendDocumentRequest(); // SendDocumentRequest | 
    String caption = "caption_example"; // String | Attached caption
    try {
      ModelAPIResponse result = apiInstance.sendDocument(instanceKey, to, sendDocumentRequest, caption);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendDocument");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
to String The recipient's number
sendDocumentRequest SendDocumentRequest
caption String Attached caption [optional]

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendGroupInvite

ModelAPIResponse sendGroupInvite(instanceKey, data)

Send a group invite message

Sends a group invite message to the specified number. Don't include "https://chat.whatsapp.com/\" in the invite code.

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    GroupInviteMessagePayload data = new GroupInviteMessagePayload(); // GroupInviteMessagePayload | Message data
    try {
      ModelAPIResponse result = apiInstance.sendGroupInvite(instanceKey, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendGroupInvite");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
data GroupInviteMessagePayload Message data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendImage

ModelAPIResponse sendImage(instanceKey, to, updateProfilePicRequest, caption)

Send raw image.

Sends a image message by uploading to the WhatsApp servers every time. This is not recommended for bulk sending.

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    String to = "to_example"; // String | The recipient's number
    UpdateProfilePicRequest updateProfilePicRequest = new UpdateProfilePicRequest(); // UpdateProfilePicRequest | 
    String caption = "caption_example"; // String | Attached caption
    try {
      ModelAPIResponse result = apiInstance.sendImage(instanceKey, to, updateProfilePicRequest, caption);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendImage");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
to String The recipient's number
updateProfilePicRequest UpdateProfilePicRequest
caption String Attached caption [optional]

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendListMessage

ModelAPIResponse sendListMessage(instanceKey, data)

Send a List message.

Sends an interactive List message to the given user.

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    ListMessagePayload data = new ListMessagePayload(); // ListMessagePayload | Message data
    try {
      ModelAPIResponse result = apiInstance.sendListMessage(instanceKey, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendListMessage");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
data ListMessagePayload Message data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendLocation

ModelAPIResponse sendLocation(instanceKey, data)

Send a location message.

Sends a location message to the given user. This is static location and does not update Note: The Address and Url fields are optional

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    LocationMessagePayload data = new LocationMessagePayload(); // LocationMessagePayload | Message data
    try {
      ModelAPIResponse result = apiInstance.sendLocation(instanceKey, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendLocation");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
data LocationMessagePayload Message data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendMediaMessage

ModelAPIResponse sendMediaMessage(instanceKey, data)

Send a media message.

Sends a media message to the given user.

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    SendMediaPayload data = new SendMediaPayload(); // SendMediaPayload | Message data
    try {
      ModelAPIResponse result = apiInstance.sendMediaMessage(instanceKey, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendMediaMessage");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
data SendMediaPayload Message data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendPollMessage

ModelAPIResponse sendPollMessage(instanceKey, data)

Send a Poll message.

Sends an interactive poll message to the given user. The poll message is a new feature that is currently in beta.

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    PollMessagePayload data = new PollMessagePayload(); // PollMessagePayload | Message data
    try {
      ModelAPIResponse result = apiInstance.sendPollMessage(instanceKey, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendPollMessage");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
data PollMessagePayload Message data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendTemplate

ModelAPIResponse sendTemplate(instanceKey, data)

Send a template message.

Sends an interactive template message to the given user. Note: The valid button types are "replyButton", "urlButton", "callButton"

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    TemplateButtonPayload data = new TemplateButtonPayload(); // TemplateButtonPayload | Message data
    try {
      ModelAPIResponse result = apiInstance.sendTemplate(instanceKey, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendTemplate");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
data TemplateButtonPayload Message data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendTemplateWithMedia

ModelAPIResponse sendTemplateWithMedia(instanceKey, data)

Send a template message with media.

Sends an interactive template message with a media header to the given user. Note: The valid button types are "replyButton", "urlButton", "callButton"

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    TemplateButtonWithMediaPayload data = new TemplateButtonWithMediaPayload(); // TemplateButtonWithMediaPayload | Message data
    try {
      ModelAPIResponse result = apiInstance.sendTemplateWithMedia(instanceKey, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendTemplateWithMedia");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
data TemplateButtonWithMediaPayload Message data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendTextMessage

ModelAPIResponse sendTextMessage(instanceKey, data)

Send a text message.

Sends a text message to the given user.

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    TextMessage data = new TextMessage(); // TextMessage | Message data
    try {
      ModelAPIResponse result = apiInstance.sendTextMessage(instanceKey, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendTextMessage");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
data TextMessage Message data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

sendVideo

ModelAPIResponse sendVideo(instanceKey, to, sendVideoRequest, caption)

Send raw video.

Sends a video message by uploading to the WhatsApp servers every time. This is not recommended for bulk sending.

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    String to = "to_example"; // String | The recipient's number
    SendVideoRequest sendVideoRequest = new SendVideoRequest(); // SendVideoRequest | 
    String caption = "caption_example"; // String | Attached caption
    try {
      ModelAPIResponse result = apiInstance.sendVideo(instanceKey, to, sendVideoRequest, caption);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#sendVideo");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
to String The recipient's number
sendVideoRequest SendVideoRequest
caption String Attached caption [optional]

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

uploadMedia

ModelAPIResponse uploadMedia(instanceKey, type, uploadMediaRequest)

Upload media.

Uploads media to WhatsApp servers and returns the media keys. Store the returned media keys, as you will need them to send media messages

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    String type = "image"; // String | Media type
    UploadMediaRequest uploadMediaRequest = new UploadMediaRequest(); // UploadMediaRequest | 
    try {
      ModelAPIResponse result = apiInstance.uploadMedia(instanceKey, type, uploadMediaRequest);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#uploadMedia");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
type String Media type [enum: image, video, audio, document]
uploadMediaRequest UploadMediaRequest

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -

uploadMediaFromUrl

ModelAPIResponse uploadMediaFromUrl(instanceKey, type, data)

Upload media from url.

Uploads media from a url to WhatsApp servers and returns the media keys. Store the returned media keys, as you will need them to send media messages

Example

// Import classes:
import WhatsAPI.ApiClient;
import WhatsAPI.ApiException;
import WhatsAPI.Configuration;
import WhatsAPI.auth.*;
import WhatsAPI.models.*;
import whatsapi.MessageSendingApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("/api");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    MessageSendingApi apiInstance = new MessageSendingApi(defaultClient);
    String instanceKey = "instanceKey_example"; // String | Instance key
    String type = "image"; // String | Media type
    UrlMediaUploadPayload data = new UrlMediaUploadPayload(); // UrlMediaUploadPayload | Media data
    try {
      ModelAPIResponse result = apiInstance.uploadMediaFromUrl(instanceKey, type, data);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling MessageSendingApi#uploadMediaFromUrl");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
instanceKey String Instance key
type String Media type [enum: image, video, audio, document]
data UrlMediaUploadPayload Media data

Return type

ModelAPIResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: /

HTTP response details

Status code Description Response headers
200 Success -
400 Bad Request -
401 Unauthorized -
404 Instance not found -
500 Internal Server Error -