Skip to main content
Version: 4.2.0

Return Methods

There are multiple return methods that help you determine the status of your request.

Common Methods​

note

These methods are supported across all methods

These methods are available in the base response class and commonly used across all response types.

  • isSuccess(): Checks if the operation was successful. This method should be implemented by subclasses to define what constitutes success for their specific response type.

  • getFullResponse(): Returns the complete, raw JSON response from the API. Useful for debugging or accessing other data not directly exposed by this class's properties.

  • getErrorMessage(): Retrieves a descriptive error message if the operation failed. It parses the error field from the full response to return a human-readable message, or a generic message if no error is found.

  • getErrorCode(): Gets the numeric error code from a failed operation. Returns the code field from the error object in the API response, or 0 if the operation was successful.

  • getErrorType(): Gets the type of error from a failed operation. Returns the type field from the error object in the API response, or an empty string if the operation was successful.

  • getErrorSubcode(): Returns the Graph API error subcode, or null when the API did not include one.

  • getFbtraceId(): Returns Meta's fbtrace_id for support requests, or null.

Messages Methods​

These methods are specific to other response types such as messaging, templates, etc.

  • getMessageId(): Returns the unique ID of the sent message.

  • getContactId(): Returns the WhatsApp ID of the recipient contact.

Media Methods​

These methods are specific to media-related operations such as uploading, getting, or deleting media.

  • getMediaId(): Returns the WhatsApp ID of the uploaded or retrieved media.

  • getMediaUrl(): Returns the full URL of the media.

  • getMediaMimeType(): Returns the MIME type of the media.

  • getMediaSha256(): Returns the SHA-256 hash of the media.

  • getMediaFileSize(): Returns the file size of the media.

  • isDeleted(): Checks if the media was deleted successfully. This method is deprecated and should be replaced with isSuccess(). It returns the result of calling isSuccess().

  • isUploaded(): Deprecated. Calls isSuccess() and returns the result.

Media download methods​

Available on the response from downloadMedia and downloadMediaById.

  • getBytes(): Returns the downloaded bytes as Uint8List.

  • getBytesCopy(): Returns a defensive copy of the downloaded bytes.

  • getMimeType(): Returns the MIME type reported by the server.

  • getFileName(): Returns the file name inferred from the media URL.

  • getLength(): Returns the number of downloaded bytes.

  • getStatusCode(): Returns the HTTP status code of the download.

Business Account Methods​

These methods are specific to other response types such as messaging, business accounts, and user management.

  • getAbout(): Returns the about field value or an empty string.

  • getAddress(): Returns the address field value or an empty string.

  • getDescription(): Returns the description field value or an empty string.

  • getEmail(): Returns the email field value or an empty string.

  • getProfilePictureUrl(): Returns the profilePictureUrl field value or an empty string.

  • getVertical(): Returns the vertical field value or an empty string.

  • getWebsites(): Returns the list of websites, or an empty list.

Phone Number Methods​

Available on the response from getPhoneNumber().

  • getId(): Returns the phone number ID.

  • getDisplayPhoneNumber(): Returns the display phone number.

  • getVerifiedName(): Returns the verified business name.

  • getQualityRating(): Returns the quality rating (GREEN, YELLOW, RED).

  • getPlatformType(): Returns the platform type.

  • getCodeVerificationStatus(): Returns the code verification status.

  • getNameStatus(): Returns the display-name status.

  • isOfficialBusinessAccount(): Returns whether the number is an official business account.

  • getThroughput(): Returns throughput details.

  • getWebhookConfiguration(): Returns webhook configuration details.

Users Block/Unblock Methods​

  • isSomeSuccess(): Returns true when at least one user in the batch failed, indicating a partial result.

  • getUsersList(): Returns the list of blocked users.

  • getCursorBefore(): Returns the cursor for pagination to get the previous page of results.

  • getCursorAfter(): Returns the cursor for pagination to get the next page of results.

Resumable Methods​

  • getId(): Returns the id of created resumable upload session.

  • getH(): Returns the h id of uploaded image.

  • getFileOffset(): Returns the file size in bytes of created resumable upload session.

Exceptions​

Non-2xx responses throw typed exceptions instead of returning an error response:

  • WhatsAppAuthenticationException: HTTP 401/403 or Graph error code 190.
  • WhatsAppValidationException: Invalid request parameters.
  • WhatsAppRateLimitException: HTTP 429 or rate-limit error codes.
  • WhatsAppServerException: HTTP 5xx responses.
  • WhatsAppException: Any other API error. Exposes statusCode, errorCode, errorSubcode, fbtraceId and details.
  • NetworkException: DNS, socket, TLS, timeout or browser CORS failures.
  • JsonFormatException: The API returned an unexpected body.