Endpoint #
POST /wp-json/rtcl/v1/contact
Description #
Users to send a contact message that is emailed to the site administrator.
Request Headers #
| Header | Required | Description |
|---|---|---|
Content-Type | ✅ Yes | application/json |
x-api-key | ✅ Yes | API key used for request authentication |
Request Body Parameters #
Parameters #
| Name | Type | Required | Description |
|---|---|---|---|
name | string | ✅ Yes | Name of the contact sender |
email | ✅ Yes | Valid sender email address | |
phone | string | ❌ No | Sender phone number |
message | string | ✅ Yes | Contact message content |
Validation & Sanitization Rules #
| Field | Rule |
|---|---|
name | HTML tags are stripped |
email | Must be a valid email address (is_email) |
phone | No validation (optional field) |
message | HTML tags are stripped |
If the email address is invalid, the API will return a validation error.
Example Request #
JSON Request Body #
{
"name": "John Doe",
"email": "john@example.com",
"phone": "+880123456789",
"message": "I am interested in your listing."
}
cURL Example #
curl -X POST https://your-site.com/wp-json/rtcl/v1/contact \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"message": "Hello, I want more information."
}'
Success Response #
HTTP Status Code #
200 OK
Response Body #
{
"name": "John Doe",
"email": "john@example.com",
"phone": "+880123456789",
"message": "I am interested in your listing."
}
Error Responses #
Email Sending Failed #
If the email cannot be sent via the mailer system
HTTP Status Code #
503 Service Unavailable
Response Body #
{
"status": "error",
"error": "SERVERERROR",
"code": "503",
"error_message": "Email not sent."
}
Invalid Email Parameter #
If the email is invalid:
HTTP Status Code #
400 Bad Request
Response Body #
{
"code": "rest_invalid_param",
"message": "The filter argument must be a email.",
"data": {
"status": 400
}
}