Endpoint #
POST /wp-json/rtcl/v1/listing/email-seller
Description #
Sends a message from a logged-in user to a listing owner.
The system can also notify the site admin depending on email notification settings.
Authentication #
🔐 Required
- User must be logged in
- Request must pass via permission check
- Requests without authentication will return 403 Forbidden
Request Parameters #
Body Parameters #
| Parameter | Type | Required | Description |
|---|---|---|---|
listing_id | integer | ✅ Yes | ID of the listing |
message | string | ✅ Yes | Message content |
name | string | ❌ No | Sender name (default: user display name) |
email | string | ❌ No | Sender email (default: user email) |
Example Request (JSON) #
{
"listing_id": 123,
"message": "Hi, I am interested in your listing.",
"name": "John Doe",
"email": "john@example.com"
}
CURL Example #
curl -X POST "https://example.com/wp-json/rtcl/v1/listing/email-seller" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"listing_id": 123,
"message": "Hi, I am interested in your listing."
}'
Success Response #
200 OK #
Returns the total number of visitor notifications sent for this listing.
5
This value represents how many times visitors have contacted the seller.
Error Responses #
403 – User Not Logged In #
{
"status": "error",
"error": "FORBIDDEN",
"code": "403",
"error_message": "You are not logged in."
}
400 – Listing Not Found #
{
"status": "error",
"error": "BADREQUEST",
"code": "400",
"error_message": "Listing not found."
}
400 – Owner Not Allowed #
{
"status": "error",
"error": "BADREQUEST",
"code": "400",
"error_message": "You are not permitted to email."
}
Email Notifications #
This endpoint triggers email notifications based on plugin settings:
Seller Email #
- Triggered via:
Listing_Contact_Email_To_Owner - Can be disabled from:
Settings → Email → Email Notifications → Notify Users → Listing owner contact email
Admin Email #
- Triggered via:
Listing_Contact_Email_To_Admin - Controlled by:
Settings → Email → Email Notifications → Notify Admin → Contact message
Notes #
- Listing owners cannot contact themselves
- Sender name/email fallback to logged-in user data
- Message content is sanitized before sending
- Notification count is stored in post meta:
_notification_by_visitor