Skip to main content
REST API endpoints are a Pro feature. Upgrade to BoxBuilder Pro →
BoxBuilder Pro provides REST API endpoints for sharing functionality, and AJAX handlers for all other frontend operations.

REST API Endpoints

REST endpoints are registered under the boxbuilder/v1 namespace.
POST /wp-json/boxbuilder/v1/share
Creates a shareable link for a box configuration. Requires the user to be logged in. Request body:
{
  "box_id": 123,
  "items": [
    { "product_id": 45, "quantity": 2 },
    { "product_id": 67, "quantity": 1 }
  ],
  "size": "medium",
  "gift_message": "Happy Birthday!"
}
Parameters:
ParameterTypeRequiredDescription
box_idintegerYesThe WooCommerce product ID for the box
itemsarrayYesArray of selected items with product_id and quantity
sizestringNoSelected box size ID
gift_messagestringNoGift message text
Response:
{
  "share_key": "a1b2c3d4e5f6",
  "share_url": "https://yourstore.com/?boxbuilder_share=a1b2c3d4e5f6",
  "expires": "2025-02-15T00:00:00"
}

Get Shared Box

GET /wp-json/boxbuilder/v1/share/{key}
Retrieves a shared box configuration by its share key. No authentication required. Parameters:
ParameterTypeDescription
keystring12-character alphanumeric share key
Response:
{
  "box_id": 123,
  "items": [
    { "product_id": 45, "quantity": 2 },
    { "product_id": 67, "quantity": 1 }
  ],
  "size": "medium",
  "gift_message": "Happy Birthday!",
  "created_at": "2025-01-16T12:00:00"
}
Share links expire after 30 days. They are stored as WordPress transients.

AJAX Handlers

BoxBuilder uses WordPress AJAX (admin-ajax.php) for all frontend builder operations. These handlers are available to both logged-in and guest users.

Product & Configuration

ActionDescription
boxbuilder_pro_get_productsFetch paginated products for the box picker
boxbuilder_pro_get_productGet a single product’s details
boxbuilder_pro_get_categoriesFetch product categories for filter tabs
boxbuilder_pro_get_box_configGet the box configuration for a product
boxbuilder_pro_get_sizesFetch available box sizes (Pro)
boxbuilder_pro_check_stockReal-time stock check for products

Session & Cart

ActionDescription
boxbuilder_pro_save_sessionSave the current builder session (selected items)
boxbuilder_pro_load_sessionLoad a previously saved session
boxbuilder_pro_add_to_cartAdd a completed box to the WooCommerce cart
boxbuilder_pro_validate_boxValidate box contents before checkout

Sharing (Pro)

ActionDescription
boxbuilder_pro_create_share_linkCreate a shareable box link
boxbuilder_pro_get_shared_boxRetrieve shared box data
boxbuilder_pro_load_shared_boxLoad a shared box into the builder

Analytics (Pro)

ActionDescription
boxbuilder_pro_get_analyticsFetch analytics dashboard data
boxbuilder_pro_export_analyticsExport analytics as CSV

Using AJAX in Custom Code

All AJAX requests require a nonce for security. The nonce is available via the localized boxbuilderData object:
// Example: fetch products for a box
wp.ajax.post( 'boxbuilder_pro_get_products', {
    nonce: boxbuilderData.nonce,
    box_id: 123,
    page: 1,
    per_page: 12,
    category: 0,
    search: ''
}).done( function( response ) {
    console.log( response.products );
    console.log( response.total_pages );
}).fail( function( error ) {
    console.error( error );
});

Error Handling

Both REST API and AJAX endpoints return standard error responses:
{
  "success": false,
  "data": {
    "code": "boxbuilder_invalid_box",
    "message": "The specified box product does not exist."
  }
}
Error CodeDescription
boxbuilder_invalid_boxBox product not found or not enabled
boxbuilder_box_incompleteBox doesn’t meet minimum capacity
boxbuilder_invalid_itemProduct not allowed in this box
boxbuilder_out_of_stockOne or more items are out of stock
boxbuilder_invalid_nonceSecurity nonce is invalid or expired