Endpoint #
PUT /wp-json/rtcl/v1/my/mark-as-sold
Description #
This endpoint allows a logged-in user to toggle a listing as sold or unsold.
- If the listing is already sold, it will be unmarked (unsold).
2. If the listing is currently unsold, it will be marked as sold.
Authentication #
This endpoint requires authentication:
- JWT Authorization
- API Key – via
X-API-KEYheader. The key must match the option stored inrtcl_rest_api_key.
Request Headers #
| Header | Required | Description |
|---|---|---|
Authorization | ✅ Yes | JWT token: Bearer <JWT_TOKEN> |
X-API-KEY | ✅ Yes | API key from RTCL settings |
Content-Type | ✅ Yes | application/json |
Request Parameters #
| Parameter | Type | Required | Description |
|---|---|---|---|
| listing_id | integer | ✅ Yes | The ID of the listing to toggle sold/unsold status |
Example JSON Request Body #
{
"listing_id": 123
}
cURL Request Example #
curl -X POST "https://yourdomain.com/wp-json/rtcl/v1/my/mark-as-sold" \
-H "Authorization: Bearer <JWT_TOKEN>" \
-H "X-API-KEY: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"listing_id": 123
}'
Response #
Success Response #
Status Code: 200 OK
{
"listing_id": 123,
"action": "sold"
}
Error Responses #
1. Listing Not Found #
Status Code: 400 Bad Request
{
"status": "error",
"error": "BADREQUEST",
"code": "400",
"error_message": "Listing not found."
}
2. Not Logged In #
Status Code: 403 Forbidden
{
"code": "FORBIDDEN",
"message": "You are not logged in."
}
3. Invalid API Key #
Status Code: 401 Unauthorized
{
"status": "error",
"error": "INVALID_API_KEY",
"code": "401",
"error_message": "Sorry, you are using invalid API Key."
}
4. Missing API Key Header #
Status Code: 401 Unauthorized
{
"status": "error",
"error": "MISSING_X_API_KEY_HEADER",
"code": "401",
"error_message": "X_API_KEY header not received. Either authorization header was not sent or it was removed by your server due to security reasons."
}
5. REST API Disabled in Settings #
Status Code: 403 Forbidden
{
"code": "DENIED_REST_API",
"message": "Denied api call"
}
Notes #
- Toggle Behavior: The endpoint toggles the
_rtcl_mark_as_soldmeta key in the listing post. - Permissions: Only logged-in users can toggle their own listings.
- Security: Both JWT and API Key headers are required to prevent unauthorized access.
- Action Field:
"sold"→ listing is now marked as sold,"unsold"→ listing is unmarked.