fbpx

< / >

APIs WhatsApp

4. Upload file

https://wv{{wolkvox_server}}.wolkvox.com/api/v2/whatsapp.php?api=upload_media

 

Description:

This API allows you to upload a multimedia file (image, video, or document) to Meta Business Suite to serve as a visual or content example when creating a WhatsApp template that requires attachments.

It’s important to understand that the file uploaded through this API is only an example and will not be directly included in the final template. When a Wolkvox Agent (in the web or desktop version) sends a message using a WhatsApp template with a multimedia attachment, they must provide the public URL of the actual file in the ‘WhatsApp file link’ field (web version) or ‘File URL’ field (desktop version).

This API streamlines the template creation process in Meta Business Suite, which requires a sample multimedia file when designing templates that include such content.

The file sent to Meta through this API can be reused to create multiple templates in your operation. You can use the same handle obtained from this API request in several template creation APIs.

Note: The file sent via this API must be hosted in Wolkvox Storage, and its public URL must be used.

 

Benefits:

  • Template Creation Simplification: Speeds up the design process of WhatsApp templates with multimedia files in Meta Business Suite by providing a programmatic method to meet the file sample requirement.
  • Automation: Enables automation in preparing the necessary assets for template creation, reducing manual intervention.
  • Operational Efficiency: Helps companies manage large-scale WhatsApp communications by having multimedia file samples ready to be referenced in templates.
  • Compatibility: Ensures that templates created in Wolkvox Manager comply with Meta Business Suite’s requirements for sending messages with multimedia content.

 

How it works:

  • This API is consumed using the POST method.
  • To use this API, replace {{wolkvox_server}} in the URL with the appropriate server name for your operation.
  • The wolkvox-token header must be used to include the authorization token.
  • Keep in mind that the same token cannot be used simultaneously in multiple requests. You should schedule the next API call only after the previous one has completed successfully.
  • Note that this API can only be used after a conversation has already been initiated with the customer and within the 24-hour window in which the conversation remains open.

 

API Limits:

  • Max records per request (download): 60,000
  • Max records per request (upload): 10,000
  • Date range limit: 31 days
  • Response size limit: 256 MB
  • Timeout limit: 60 seconds
  • Simultaneous requests per token: 2
  • Daily token usage limit: Number of licenses × 1,000 daily tokens

 

Code Examples:

In our Postman workspace ([click here] to access it), you have access to code examples that facilitate integration with our APIs in different programming languages such as cURL, Python, JavaScript, and more.

This feature is ideal for quick integrations and allows you to adapt the API calls to your system’s programming language.

How to Use the Code Examples:

  1. Navigate to our Postman workspace.
  2. Select the API you want to consult.
  3. Edit the necessary API parameters according to your goals.
  4. In the “Code” tab, select your preferred programming language.
  5. You will get an auto-generated code snippet, ready to use with the parameters and authentication previously configured.

 

Request

NAMEDESCRIPTIONTYPE
connector_idUnique identifier of the WhatsApp connector associated with your account.String
file_urlThe public URL of the multimedia file (image, video, or document) you want to upload as an example. This URL must be accessible from the internet so that Meta can download the file.String

Response

NAMEDESCRIPTIONTYPE
codeError code.Int
errorError name.String
msgError explanation.String
dataObject containing relevant upload data.Object
0Internal confirmation message.String
handleThis is the key value. It is a unique identifier generated by Meta for the uploaded multimedia file. This handle must be saved and later used in Meta Business Suite’s WhatsApp template creation APIs when a sample multimedia file is required. It is the reference Meta will use to identify the sample content.String
Possible Response Codes
				
					$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://wv{{wolkvox_server}}.wolkvox.com/api/v2/whatsapp.php?api=upload_media',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "connector_id": "",
    "file_url": ""
}',
  CURLOPT_HTTPHEADER => array(
    'wolkvox-token: {{wolkvox-token}}',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

				
			

RESPONSE

				
					{
    "code": "200",
    "error": null,
    "msg": "Media uploaded successfully",
    "data": {
        "0": "media_uploaded_successfully",
        "handle": ""
    }
}
				
			

Usamos cookies, se continuar a navegar assumimos que concorda. Pode ler mais sobre a utilização de cookies nas nossas políticas de privacidade e tratamento de dados pessoais

We use cookies, if you continue browsing we will assume that you agree. You can read more about the use of cookies in our privacy policies and treatment of personal data