Upload a file, such as a photo, a signed form or a PDF, and attach it to a lead. The file shows up in the attachments of that lead in the software.
| Method | URL | API key permission | Package |
|---|---|---|---|
| POST | https://rental.software/api6/attach/{lead_id} | Leads: Full Access | WP/API |
Request
Put the Lead ID in the URL. You can send the file in one of two ways.
Option 1: Upload the File as a Form (Multipart)
Send a multipart/form-data request with the file in a field named photo. This is the easiest way when you have the file on disk.
curl -X POST "https://rental.software/api6/attach/520247?apiKey=YOUR_API_KEY" \ -F "photo=@/path/to/site-plan.pdf" \ -F "title=Site plan"
Option 2: Send the File as Base64 Text
Send the file name in image_name and the contents of the file, base64 encoded, in image_data. Use this when your file is already in memory.
curl -X POST "https://rental.software/api6/attach/520247?apiKey=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image_name": "site-plan.pdf", "image_data": "JVBERi0xLjQK..."}'Parameters
| Parameter | Required | Description |
|---|---|---|
| lead_id | Yes | In the URL path. The lead to attach the file to |
| apiKey | Yes | Your API key |
| photo | Option 1 | The file, as a multipart form field |
| image_name | Option 2 | The file name, including its extension. The extension decides the file type |
| image_data | Option 2 | The contents of the file, base64 encoded |
| title | No | A title for the attachment |
Despite the parameter names, the file does not have to be an image.
Allowed File Types
bmp, csv, doc, docm, docx, eml, gif, htm, html, ico, jpeg, jpg, mov, mp3, mp4, odf, pdf, png, pptx, tif, tiff, txt, vcf, vsd, xls, xlsx, zip
Response
A successful upload returns HTTP 200 with the ID and URL of the new attachment, plus the list of all attachments now on the lead:
{
"id": "88231",
"url": "https://rental.software/users/youraccount/images/3f1c9a7e5b2d4c6e8a0b1c2d3e4f5a6b.pdf",
"attachments": [
{
"attachment_quoteid": "520247",
"attachment_filename": "https://rental.software/users/youraccount/images/3f1c9a7e5b2d4c6e8a0b1c2d3e4f5a6b.pdf",
"attachment_title": "Site plan",
"attachment_receivetime": "1760000000"
}
],
"request_time": 1760000000
}The example is shortened. The file is stored under a new, random file name, so use the returned url to link to it.
PHP Example
<?php
$lead_id = 520247;
$file = '/path/to/site-plan.pdf';
$post_data = array(
'apiKey' => 'YOUR_API_KEY',
'title' => 'Site plan',
'image_name' => basename($file),
'image_data' => base64_encode(file_get_contents($file)),
);
$ch = curl_init('https://rental.software/api6/attach/' . $lead_id);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$output = json_decode(curl_exec($ch));
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode == 200) {
$attachment_url = $output->url;
}Errors
| Status | Message | What to do |
|---|---|---|
| 403 | This filetype is not allowed to be uploaded. | Check that the file name has one of the allowed extensions |
| 403 | Incorrect Lead ID? | The lead ID in the URL does not exist in your account |
| 404 | Lead ID not found | The URL has no lead ID. Use /api6/attach/{lead_id} |
| 405 | Only accepts POST requests | Use POST. To read the attachments of a lead, retrieve the lead with _body=true |
| 500 | Unable to save file. Please contact support. | The file was empty or could not be stored. Check that the file data is being sent, then try again |
See API - Errors and Rate Limits for errors that apply to every call.