---
title: Create Listing via Form Builder REST API
description: "#### Endpoint ``` POST /wp-json/rtcl/v1/listing/fb ``` #### Description Creates a new listing or updates an existing listing using the Form Builder system. This endpoint handles form data validation, user registration for unregistered users (if enabled), taxonomy assignments, meta data storage,…"
url: "https://www.radiustheme.com/docs/classified-listing/docs/rest-api/create-listing-via-form-builder-rest-api/"
updated: "2026-01-30"
category: Developer Docs / REST API
---

# Create Listing via Form Builder REST API

#### Endpoint

```
POST /wp-json/rtcl/v1/listing/fb
```

#### Description

Creates a new listing or updates an existing listing using the Form Builder system. This endpoint handles form data validation, user registration for unregistered users (if enabled), taxonomy assignments, meta data storage, and all related listing operations.

### Required Headers

| Header | Required | Description |
| --- | --- | --- |
| `Content-Type` | ✅ | `multipart/form-data` |
| `X-API-KEY` | ✅ | REST API key |
| `Authorization` | ✅ | `Bearer <access_token>` |

### Request Example

bash

```
curl -X POST "https://example.com/wp-json/rtcl/v1/listing/fb" 
  -H "Content-Type: application/json" 
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" 
  -d '{
    "listing_id": 0,
    "form_id": 5,
    "form_data": "title=My+Listing&description=This+is+a+description&category[0][term_id]=10&price=500"
  }'
```

### Form Data Structure

The `form_data` parameter should be a URL-encoded string containing form field values. Field names correspond to the Form Builder field configurations.

### Preset Fields

These are core listing fields handled specially by the system:

| Field Element | Form Data Key | Value Format | Stored As |
| --- | --- | --- | --- |
| `title` | `title` | string | `post_title` |
| `description` | `description` | string | `post_content` |
| `excerpt` | `excerpt` | string | `post_excerpt` |
| `listing_type` | `listing_type` | string | `ad_type` meta |
| `category` | `category` | array of `{term_id: int}` | `rtcl_category` taxonomy |
| `location` | `location` | array of `{term_id: int}` | `rtcl_location` taxonomy |
| `tag` | `tag` | array of `{term_id: int}` | `rtcl_tag` taxonomy |
| `zipcode` | `zipcode` | string | `zipcode` meta |
| `address` | `address` | string | `address` meta |
| `geo_location` | `geo_location` | string | `_rtcl_geo_address` meta |
| `phone` | `phone` | string | `phone` meta |
| `whatsapp` | `whatsapp` | string | `_rtcl_whatsapp_number` meta |
| `email` | `email` | string (email) | `email` meta |
| `website` | `website` | string (URL) | `website` meta |
| `view_count` | `view_count` | integer | `_views` meta |
| `social_profiles` | `social_profiles` | object | `_rtcl_social_profiles` meta |
| `terms_and_condition` | `terms_and_condition` | boolean/int | `rtcl_agree` meta |
| `business_hours` | `business_hours` | object | `_rtcl_bhs` meta |
| `video_urls` | `video_urls` | array | `_rtcl_video_urls` meta |

### Pricing Field Structure

```
pricing[pricing_type]=price|range
pricing[price]=100.00
pricing[max_price]=200.00       // Only for range type
pricing[price_type]=fixed|negotiable|on_call|free
pricing[price_unit]=per_day|per_week|etc
```

**Stored Meta Keys:**

- `_rtcl_listing_pricing` - Pricing type
- `price` - Main price value
- `_rtcl_max_price` - Maximum price (for range)
- `price_type` - Price type
- `_rtcl_price_unit` - Price unit

### Map Field Structure

```
map[latitude]=40.7128
map[longitude]=-74.0060
map[hide_map]=1
```

**Stored Meta Keys:**

- `latitude`
- `longitude`
- `hide_map`

### Category/Location/Tag Field Structure

```
category[0][term_id]=5
category[1][term_id]=12
location[0][term_id]=3
tag[0][term_id]=8
tag[1][term_id]=15
```

### Field Type Sanitization Rules

| Element Type | Sanitization Method | Notes |
| --- | --- | --- |
| `title` | `sanitize_text_field()` | Shortcodes stripped for non-admin/editor. Truncated to max length if set. |
| `description`, `excerpt` | `wp_kses_post()` | Shortcodes stripped for non-admin/editor. Truncated with `wp_filter_nohtml_kses()` if exceeds max length. |
| `textarea` | `wp_kses_post()` or `sanitize_textarea_field()` | Depends on `editor_type` setting. |
| `address` | `sanitize_textarea_field()` |  |
| `html` | `wp_kses_post()` |  |
| `checkbox` | `esc_attr()` on each value | Returns array of escaped values. |
| `view_count` | `absint()` |  |
| `website`, `url` | `esc_url_raw()` |  |
| `social_profiles` | `esc_url_raw()` on each URL | Only valid social profile keys accepted. |
| `date` | DateTime formatting | Supports single and range types. Converts to save format. |
| `video_urls` | `esc_url_raw()` | Only YouTube and Vimeo URLs accepted (including shorts). |
| `business_hours` | Complex object sanitization | Times converted to H:i format. Special dates validated. |
| `switch` | Returns `'yes'` or `'no'` |  |
| `repeater` | Recursive sanitization | Each nested field sanitized according to its type. File fields preserve existing values. |
| `default` | `sanitize_text_field()` | Arrays/objects use `map_deep()`. |

### Response

### Success Response (200 OK)

Returns the complete listing data object via `Api::get_single_listing_data()`:

json

```
{
  "id": 123,
  "title": "My Listing",
  "slug": "my-listing",
  "status": "pending",
  "description": "This is a description (HTML tags and shortcodes stripped)",
  "url": "https://example.com/listing/my-listing/",
  "excerpt": "",
  "author_id": 1,
  "date_created": "2025-01-30T10:00:00",
  "date_modified": "2025-01-30T10:00:00",
  "categories": [
    {
      "term_id": 10,
      "name": "Category Name",
      "slug": "category-name"
    }
  ],
  "locations": [
    {
      "term_id": 3,
      "name": "Location Name",
      "slug": "location-name"
    }
  ],
  "tags": [],
  "images": [],
  "video_urls": ["https://www.youtube.com/watch?v=xxxxx"],
  "social_profiles": {
    "facebook": "https://facebook.com/example",
    "twitter": "https://twitter.com/example"
  },
  "bh": {
    "bhs": {
      "active": true,
      "type": "selective",
      "days": {}
    },
    "special_bhs": []
  },
  "author": {
    "id": 1,
    "name": "John Doe",
    "email": "john@example.com",
    "avatar_url": "https://example.com/avatar.jpg"
  },
  "is_favourite": false,
  "form_data": {
    "title": "My Listing",
    "description": "This is a description",
    "category": [{"term_id": 10, "name": "Category Name"}],
    "pricing": {
      "pricing_type": "price",
      "price": "500.00",
      "price_type": "fixed"
    }
  },
  "fb_custom_fields": [],
  "related": [],
  "review": {
    "rating": {
      "average": 4.5,
      "count": 10
    },
    "item": null
  },
  "form_id": 5
}
```

#### Response Field Details

| Field | Type | Description |
| --- | --- | --- |
| `id` | integer | Listing post ID |
| `title` | string | Listing title |
| `slug` | string | URL slug |
| `status` | string | Post status (publish, pending, draft, rtcl-temp) |
| `description` | string | Post content with HTML tags and shortcodes stripped |
| `url` | string | Full permalink to the listing |
| `video_urls` | array | Array of YouTube/Vimeo video URLs (if enabled) |
| `social_profiles` | object | Social profile URLs keyed by platform (if enabled) |
| `bh` | object | Business hours data including regular and special hours (if enabled) |
| `author` | object | Author user data |
| `is_favourite` | boolean | Whether current authenticated user has favorited this listing |
| `form_data` | object | Complete form field values retrieved via `FBHelper::getFormData()` |
| `fb_custom_fields` | array | Custom field definitions and values for Form Builder |
| `related` | array | Related listings |
| `review` | object | Review/rating data including user's own review if authenticated |

### Error Responses

#### 403 Forbidden - Permission Denied

json

```
{
  "code": "rtcl_rest_fb_permission",
  "message": "You do not have sufficient permissions to access.",
  "data": {
    "status": 403
  }
}
```

#### 403 Forbidden - Form Not Found

json

```
{
  "code": "rtcl_rest_fb_not_found",
  "message": "Form not found !!",
  "data": {
    "status": 403
  }
}
```

#### 403 Forbidden - Missing Form Fields

json

```
{
  "code": "rtcl_rest_fb_error_update_listing",
  "message": "Missing form field",
  "data": {
    "status": 403
  }
}
```

#### 403 Forbidden - Validation Errors

json

```
{
  "code": "rtcl_rest_fb_error_validation",
  "message": "Form validation errors",
  "data": {
    "errors": {
      "title": "Title is required",
      "price": "Price must be a valid number",
      "email": "Please enter a valid email address"
    },
    "status": 403
  }
}
```

#### 403 Forbidden - Registration Error (Unregistered User)

json

```
{
  "code": "rtcl_rest_fb_error_registration",
  "message": "Registration error message",
  "data": {
    "status": 403
  }
}
```

#### 403 Forbidden - Missing Email for Unregistered User

json

```
{
  "code": "rtcl_rest_fb_error",
  "message": "Missing required email to register user",
  "data": {
    "status": 403
  }
}
```

#### 403 Forbidden - WordPress Insert/Update Error

json

```
{
  "code": "rtcl_rest_fb_error_wp_insert_post_error",
  "message": "WordPress error message",
  "data": {
    "status": 403
  }
}
```

json

```
{
  "code": "rtcl_rest_fb_error_wp_update_post_error",
  "message": "WordPress error message",
  "data": {
    "status": 403
  }
}
```
