Media
Manage Files
How to retrieve, delete, and link media files with external IDs
After uploading media files, you can retrieve their information, delete them, and manage external IDs.
Get File Information
By ID
const response = await fetch('https://crm.rentix.md/api/v1/media/123', {
headers: {
'Authorization': 'ApiKey YOUR_API_KEY'
}
});
const media = await response.json();
console.log(media);
curl https://crm.rentix.md/api/v1/media/123 \
-H "Authorization: ApiKey YOUR_API_KEY"
$ch = curl_init('https://crm.rentix.md/api/v1/media/123');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: ApiKey YOUR_API_KEY'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$media = json_decode($response, true);
By External ID
const response = await fetch('https://crm.rentix.md/api/v1/media/external/apt-001-photo-1', {
headers: {
'Authorization': 'ApiKey YOUR_API_KEY'
}
});
const media = await response.json();
console.log(media);
curl https://crm.rentix.md/api/v1/media/external/apt-001-photo-1 \
-H "Authorization: ApiKey YOUR_API_KEY"
$ch = curl_init('https://crm.rentix.md/api/v1/media/external/apt-001-photo-1');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: ApiKey YOUR_API_KEY'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$media = json_decode($response, true);
Response
{
"id": 123,
"externalId": "apt-001-photo-1",
"size": 245000,
"contentType": "image/jpeg",
"optimization": "success",
"blurhash": "L7HuX^zY1z-6ADx?0z2@1Io#{yV_",
"originalUrl": "https://storage.../original.jpg",
"variants": [
{ "url": "https://storage.../128.webp", "variantSize": "128", "size": 4074 },
{ "url": "https://storage.../512.webp", "variantSize": "512", "size": 32850 },
{ "url": "https://storage.../1024.webp", "variantSize": "1024", "size": 98500 }
]
}
| Field | Description |
|---|---|
id | Internal file ID |
externalId | Your CRM ID (if provided) |
size | Original size in bytes |
contentType | File MIME type |
optimization | Optimization status |
blurhash | String for generating placeholder |
originalUrl | URL of original file |
variants | Optimized versions of different sizes |
Delete File
Deletion frees up space and removes the file from all listings where it was used.
By ID
const response = await fetch('https://crm.rentix.md/api/v1/media/123', {
method: 'DELETE',
headers: {
'Authorization': 'ApiKey YOUR_API_KEY'
}
});
const result = await response.json();
console.log(result); // { deleted: true }
curl -X DELETE https://crm.rentix.md/api/v1/media/123 \
-H "Authorization: ApiKey YOUR_API_KEY"
$ch = curl_init('https://crm.rentix.md/api/v1/media/123');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: ApiKey YOUR_API_KEY'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$result = json_decode($response, true);
Response
{
"deleted": true
}
By External ID
const response = await fetch('https://crm.rentix.md/api/v1/media/external/apt-001-photo-1', {
method: 'DELETE',
headers: {
'Authorization': 'ApiKey YOUR_API_KEY'
}
});
const result = await response.json();
console.log(result); // { deleted: true, mediaId: 123 }
curl -X DELETE https://crm.rentix.md/api/v1/media/external/apt-001-photo-1 \
-H "Authorization: ApiKey YOUR_API_KEY"
$ch = curl_init('https://crm.rentix.md/api/v1/media/external/apt-001-photo-1');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: ApiKey YOUR_API_KEY'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$result = json_decode($response, true);
Response
{
"deleted": true,
"mediaId": 123
}
Deletion is irreversible. If the file is linked to listings, it will be unlinked from them.
Manage External ID
Link External ID
If a file was uploaded without an external ID, you can add it later:
const response = await fetch('https://crm.rentix.md/api/v1/media/123/link', {
method: 'POST',
headers: {
'Authorization': 'ApiKey YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ externalId: 'apt-001-photo-1' })
});
const result = await response.json();
console.log(result); // { mediaId: 123, externalId: 'apt-001-photo-1', linked: true }
curl -X POST https://crm.rentix.md/api/v1/media/123/link \
-H "Authorization: ApiKey YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "externalId": "apt-001-photo-1" }'
$data = ['externalId' => 'apt-001-photo-1'];
$ch = curl_init('https://crm.rentix.md/api/v1/media/123/link');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: ApiKey YOUR_API_KEY',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$result = json_decode($response, true);
Response
{
"mediaId": 123,
"externalId": "apt-001-photo-1",
"linked": true
}
Unlink External ID
const response = await fetch('https://crm.rentix.md/api/v1/media/123/link', {
method: 'DELETE',
headers: {
'Authorization': 'ApiKey YOUR_API_KEY'
}
});
const result = await response.json();
console.log(result); // { mediaId: 123, externalId: 'apt-001-photo-1', unlinked: true }
curl -X DELETE https://crm.rentix.md/api/v1/media/123/link \
-H "Authorization: ApiKey YOUR_API_KEY"
$ch = curl_init('https://crm.rentix.md/api/v1/media/123/link');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: ApiKey YOUR_API_KEY'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$result = json_decode($response, true);
Response
{
"mediaId": 123,
"externalId": "apt-001-photo-1",
"unlinked": true
}
Optimization Statuses
After upload, a file goes through optimization. Check the optimization field:
| Status | Description | Action |
|---|---|---|
pending | Queued | Wait |
in_progress | Processing | Wait |
success | Ready | Can use |
failed | Error | Upload a different file |
When linking to a listing, the system automatically waits for optimization to complete.
Common Errors
| Error | Cause | Solution |
|---|---|---|
External ID already linked | ID is already used by another file | Use a unique ID |
File already has external ID | File already has an external ID | Unlink the current one first |
File not found | File doesn't exist or belongs to another agency | Check the ID |