Endpoint #
DELETE /wp-json/rtcl/v1/listing/fb/image
Description #
Deletes an image attachment from a listing. If the deleted image was the featured image, the next available image in the gallery is automatically promoted to featured.
Authentication #
Requires valid authentication with both API key and JWT token.
Required Headers:
| Header | Description |
|---|---|
X-API-KEY | API key configured in plugin settings |
Authorization | Bearer token (JWT) for authenticated user requests |
Content-Type #
This endpoint accepts parameters via query string (recommended), JSON body, or form URL encoded body.
Request Parameters #
| Parameter | Type | Required | Description |
|---|---|---|---|
listing_id | integer | Yes | The listing ID the image is attached to |
attach_id | integer | Yes | The attachment ID to delete |
form_id | integer | Yes | The Form Builder form ID |
Request Examples #
Option 1: Query Parameters (Recommended) #
bash
curl -X DELETE "https://example.com/wp-json/rtcl/v1/listing/fb/image?listing_id=405&attach_id=406&form_id=5" \
-H "X-API-KEY: your-api-key" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Option 2: JSON Body #
bash
curl -X DELETE "https://example.com/wp-json/rtcl/v1/listing/fb/image" \
-H "X-API-KEY: your-api-key" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"listing_id": 405,
"attach_id": 406,
"form_id": 5
}'
Option 3: Form URL Encoded #
bash
curl -X DELETE "https://example.com/wp-json/rtcl/v1/listing/fb/image" \
-H "X-API-KEY: your-api-key" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "listing_id=405&attach_id=406&form_id=5"
Success Response (200 OK) #
json
{
"attach_id": 406,
"listing_id": 405
}
Response Field Details #
| Field | Type | Description |
|---|---|---|
attach_id | integer | The deleted attachment ID |
listing_id | integer | The listing ID the image was attached to |
Error Responses #
403 Forbidden – Permission Denied #
json
{
"code": "FORBIDDEN",
"message": "You do not have sufficient permissions to access this page.",
"data": {
"status": 403
}
}
403 Forbidden – Attachment Not Found #
json
{
"code": "FORBIDDEN",
"message": "Attachment does not exist.",
"data": {
"status": 403
}
}
403 Forbidden – Incorrect Attachment ID #
json
{
"code": "FORBIDDEN",
"message": "Incorrect attachment ID.",
"data": {
"status": 403
}
}
403 Forbidden – Deletion Failed #
json
{
"code": "FORBIDDEN",
"message": "File could not be deleted.",
"data": {
"status": 403
}
}