Endpoint #
POST /wp-json/rtcl/v1/tags/new
Description #
Creates a new listing tag or returns an existing one if the tag already exists.
Request Headers #
| Header | Required | Description |
|---|---|---|
Content-Type | ✅ Yes | application/json |
x-api-key | ✅ Yes | API key used for request authentication |
Request Parameters #
Body Parameters #
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Name of the tag to be created |
Example Request Body #
{
"name": "Premium"
}
cURL Example #
curl -X POST https://example.com/wp-json/rtcl/v1/tags/new \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"name": "Premium"
}'
Request Validation Logic #
- The
nameparameter is trimmed and sanitized. - If the tag name is empty, the API returns an error.
- The API checks if the tag already exists in the listing tag taxonomy.
- If the tag exists → returns the existing tag.
- If not → creates a new tag and returns it.
Success Responses #
Existing Tag Found #
{
"term_id": 12,
"name": "Premium",
"slug": "premium",
"term_group": 0,
"term_taxonomy_id": 12,
"taxonomy": "rtcl_tag",
"description": "",
"parent": 0,
"count": 4
}
New Tag Created #
{
"term_id": 25,
"term_taxonomy_id": 25
}
Error Responses #
Missing or Empty Tag Name #
Status: 403 Forbidden
{
"code": "SANITIZATION_ERROR",
"message": "Tag name is required",
"data": {
"status": 403
}
}
Error While Creating Tag #
Status: 403 Forbidden
{
"code": "SANITIZATION_ERROR",
"message": "Error while creating new tag.",
"data": {
"status": 403
}
}