Endpoint #
POST /wp-json/rtcl/v1/listing/fb/file
Description #
Uploads a file to a Form Builder file field. Supports both standalone file fields and file fields nested within repeater fields. If no listing exists, a temporary listing is automatically created to associate the file attachment.
Required Headers #
| Header | Required | Description |
|---|---|---|
Content-Type | ✅ | multipart/form-data |
X-API-KEY | ✅ | REST API key |
Authorization | ✅ | Bearer <access_token> |
Content-Type #
multipart/form-data
Request Parameters #
| Parameter | Type | Required | Location | Description |
|---|---|---|---|---|
file | file | ✅ Yes | File params | The file to upload |
form_id | integer | ✅ Yes | Body/Query | The Form Builder form ID |
listing_id | integer | No | Body/Query | The listing ID to attach the file to. If 0 or omitted, a temp listing is created. |
field_uuid | string | ✅ Yes | Body/Query | The UUID of the file field in the form |
repeater_uuid | string | Conditional | Body/Query | Required if uploading to a file field inside a repeater. The UUID of the parent repeater field. |
repeater_index | integer | Conditional | Body/Query | Required if repeater_uuid is provided. The zero-based index of the repeater item. |
Request Examples #
Standard File Field Upload #
bash
curl -X POST "https://example.com/wp-json/rtcl/v1/listing/fb/file" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-F "file=@/path/to/document.pdf" \
-F "form_id=5" \
-F "listing_id=123" \
-F "field_uuid=abc123-def456-ghi789"
New Listing (Auto-Create Temp Listing) #
bash
curl -X POST "https://example.com/wp-json/rtcl/v1/listing/fb/file" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-F "file=@/path/to/document.pdf" \
-F "form_id=5" \
-F "listing_id=0" \
-F "field_uuid=abc123-def456-ghi789"
Repeater File Field Upload #
bash
curl -X POST "https://example.com/wp-json/rtcl/v1/listing/fb/file" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-F "file=@/path/to/document.pdf" \
-F "form_id=5" \
-F "listing_id=123" \
-F "repeater_uuid=rep123-abc456" \
-F "field_uuid=file789-xyz012" \
-F "repeater_index=0"
Success Response (200 OK) #
json
{
"uid": 456,
"status": "done",
"url": "https://example.com/wp-content/uploads/classified-listing/2025/01/document.pdf",
"listingId": 123,
"name": "document.pdf",
"meta": {
"width": 0,
"height": 0,
"file": "classified-listing/2025/01/document.pdf",
"sizes": {}
},
"mime_type": "application/pdf"
}
Response Field Details #
| Field | Type | Description |
|---|---|---|
uid | integer | Attachment post ID |
status | string | Upload status (always "done" on success) |
url | string | Full URL to the uploaded file |
listingId | integer | ID of the listing the file is attached to |
name | string | Original filename |
meta | object | WordPress attachment metadata |
mime_type | string | File MIME type |
Error Responses #
403 Forbidden – Empty File #
json
{
"code": "FORBIDDEN",
"message": "Given file is empty to upload.",
"data": {
"status": 403
}
}
403 Forbidden – Missing Form ID #
json
{
"code": "FORBIDDEN",
"message": "From id is empty to upload.",
"data": {
"status": 403
}
}
403 Forbidden – Missing Field UUID #
json
{
"code": "FORBIDDEN",
"message": "Field id is empty to upload.",
"data": {
"status": 403
}
}
403 Forbidden – Field Not Found #
json
{
"code": "FORBIDDEN",
"message": "No field found to upload.",
"data": {
"status": 403
}
}
403 Forbidden – Missing Repeater Index #
json
{
"code": "FORBIDDEN",
"message": "Repeater field index is not defined.",
"data": {
"status": 403
}
}
403 Forbidden – Empty Field Name #
json
{
"code": "FORBIDDEN",
"message": "Field name is empty.",
"data": {
"status": 403
}
}
403 Forbidden – File Count Limit Exceeded #
json
{
"code": "FORBIDDEN",
"message": "Your file upload limit is over.",
"data": {
"status": 403
}
}
403 Forbidden – WordPress Upload Error #
json
{
"code": "FORBIDDEN",
"message": "Sorry, this file type is not permitted for security reasons.",
"data": {
"status": 403
}
}
REST API Disabled #
{
"code": "DENIED_REST_API",
"message": "Denied api call",
"data": {
"status": 403
}
}
Invalid API Key / Token #
{
"code": "rtcl_rest_authentication_error",
"message": "Invalid API authentication credentials.",
"data": {
"status": 403
}
}
Missing Authorization Header #
{
"status": "error",
"error": "MISSING_AUTHORIZATION_HEADER",
"code": "401",
"error_message": "Authorization header not received. Either authorization header was not sent or it was removed by your server due to security reasons."
}
Invalid Authorization Token Type #
{
"status": "error",
"error": "INVALID_AUTHORIZATION_HEADER_TOKEN_TYPE",
"code": "401",
"error_message": "Authorization header must be type of Bearer Token."
}
Invalid JWT Format (Segment Fault) #
{
"status": "error",
"error": "SEGMENT_FAULT",
"code": "401",
"error_message": "Incorrect JWT Format."
}
Invalid JWT Signature #
{
"status": "error",
"error": "INVALID_TOKEN",
"code": "401",
"error_message": "JWT signature verification failed."
}