# Send File
pay attention
You can use the "Send File" API in one case only:
You reply to a message that the client sent, within 24 hours since the client sent his last message.
If you send a file to a new client, or try to send a file to an old client (old client means that 24 hours since client's last message has passed), you must wait for the client to message you first, or use the "Send Template Message" API instead.
If you send a template message to the client, and the client did not reply yet, and you want to send a file to him, you must wait for a client reply (or send another template). The file API cannot open a new conversation.
# Remarks
- You can use the "Send File" API in one case only - for reply to a message that the client sent, within 24 hours since the client sent his last message. If you send a file to a new client, or try to send a file to an old client (old client means that 24 hours since client's last message has passed), the request will fail with
timingRuleError. - You can only send a file to private people, not groups.
- The file is sent by an HTTPS URL (
link). This endpoint does not accept a multipart file upload. messageis the caption that appears with the file. It is required.- Supported file extensions:
- Image:
jpg,jpeg,png,gif - Video:
mp4,avi,3gpp - Audio:
mp3,ogg,amr,aac - Document:
pdf,doc,docx,xls,xlsx,ppt,ppts,zip,txt,rar
- Image:
- The billing is per "conversation". conversation means a 24 hours session between you and the client (this 24 hours conversation session is unrelated to the 24 hours timer for template message)
- You can send unlimited messages within the 24 hours session time of a conversation.
- 24 hours session conversation starts when you send a message to the client.
- Every time the user replies, the template message session resets. which means that you don't have to use template message during this 24 hours template message session.
# Endpoint
POST https://019sms.co.il/whatsapp-api/send-whatsapp-file
# Header
| Name | Type | Required |
|---|---|---|
| Authorization | Bearer authentication | ✔️ |
| Content-Type | application/json | ✔️ |
# Request parameters
| Name | Type | Description | Required |
|---|---|---|---|
| source | string | Your WhatsApp account. international number without +. for example: 972771234567 | ✔️ |
| destination | string | The number you want to send the file to. for example: 972501234567 | ✔️ |
| message | string | Caption that appears with the file. \n for new line text for bold text for italic ~text~ for strike through | ✔️ |
| link | string | HTTPS URL of the file. The file extension must be one of the supported types listed above. limitation: image (png, jpg, gif, jpeg) - 5 MB document (pdf,doc,docx,xls,xlsx,ppt,ppts,zip,txt,rar) - 100 MB video (mp4, avi, 3gpp) - 16 MB | ✔️ |
| replyTo | string | In case you want to reply to a message that the end user has sent (quoted message), here you can provide the unique ID of that message | ➖ |
# Request example
POST whatsapp-api/send-whatsapp-file HTTPS/1.1
Content-Type: application/json
{
"source": 972555555555,
"destination": 972550000000,
"message": "invoice",
"link": "https://example.com/invoice.pdf",
"replyTo": ""
}
# Response example
Content-Type: application/json
{
"success": true,
"ans": {
"status": "OK",
"unique": "HBgMOTcyNTI2ODkzMjQ1FQIAERgSRdDU4RjIyQjY2MEI5NUVEMUM4AA==",
"timestamp": 1735648695,
"from": 972555555555,
"to": "972550000000",
"body": "https://example.com/invoice.pdf",
"templateTimeLeft": 0,
"conversationTimeLeft": 0,
"reason": 1
}
}
# Response parameters
| Name | Type | Description | Options |
|---|---|---|---|
| success | boolean | The status of request. | true/false |
| ans | object | The response object | |
| ans -> status | string | Status of sending the message | OK / FAIL |
| ans -> unique | string | Unique ID for any message | |
| ans -> timestamp | timestamp | Time stamp | |
| ans -> from | string | Your WhatsApp account | |
| ans -> to | string | The number that the message was sent to | |
| ans -> templateTimeLeft | number | Amount of minutes left since client's last message. if passed, you must use Template Message. This value resets every time the client is sending you a message. | |
| ans -> reason | string | The status explanation in case of FAIL | see the table below |
If the 24-hour session is closed, the API returns { "success": false, "message": "timingRuleError" } without an ans object.
If the file extension is not supported, the API returns { "success": false, "message": "fileTypeError" }.
# Reason explanation
| Reason | Description |
|---|---|
| 1 | Not FAIL. the status is OK |
| 2 | Your "from" number account does not exist, or JSON syntax error |
| 3 | General error |
| 4 | 'to' is either empty or wrong number format or WhatsApp number does not exist |
| 5 | 'body' can't be empty |
| 6 | WhatsApp error |
| 7 | You are trying to send a file but it has been more than 24 hours since client's last message. please use 'Send Template' instead |
| 8 | You are trying to send a file for first time to a contact. please use 'Send Template' message instead |
| 10 | Caption can't be empty |
| 11 | Rate limit error, try again |
| 24 | File error. check that the HTTPS link is reachable and the file type is supported |