# Builderly API reference

Base URL: http://builderly.app
Generated from the running server on 2026-11-05T16:56:09.697Z. Every mounted route is listed with the access it needs, the parameters its handler reads and the data models it uses.

## Authentication

Send `Authorization: Bearer <token>` where a route needs a token. Add `?ionic=true` to get JSON from routes that also render pages.

- **Admin token** (`admin`): Bearer token of a site admin (Authorization: Bearer <token>).
- **User token** (`user`): Bearer token of a signed-in user of the site.
- **Optional user** (`optional-user`): Works without a token; a user token personalises the answer.
- **User with access** (`user-priv`): A signed-in user whose plan grants access to the item.
- **Page access** (`page-priv`): Pages limited to some users check the token when one is sent.
- **Webhook signature** (`webhook`): Called by a provider; verified by its signature.
- **reCAPTCHA** (`recaptcha`): Needs a reCAPTCHA token from the site form.
- **System** (`system`): Internal - called by the platform itself.

### For AI assistants: getting a token

Public endpoints (Access: Public) need no token. Everything else - changing the site, or reading its orders, bookings, customers and other private data - needs the site owner's API token.

You cannot create a token yourself, and you must not ask for the owner's password. Ask the user for a token instead - you can send them this message as it is:

> To work with your site through its API, I need an API token from you:
> 1. Sign in to your Builderly admin: https://admin.max-media.io
> 2. Open Developers > API reference (or go straight to https://admin.max-media.io/tabs/site-builder/api-docs).
> 3. Press "Generate token", copy the token and paste it here.
> The token acts as you, so only share it in this chat. You can cancel it at any time by signing out of all devices.

Then send it with every request as `Authorization: Bearer <token>`, and add `?ionic=true` to get JSON. Calls go to the site's own address (its domain), not to the reference's.

The token acts as the user: say what you will change and wait for their yes before any request that creates, changes or deletes something, never repeat the token back, and never put it in a link or a file you share.

## Status codes

| Code | Name | Meaning |
| --- | --- | --- |
| 200 | OK | It worked. The answer is the object or list asked for. |
| 201 | Created | The object was created. Some endpoints send it back; others send an empty body. |
| 202 | Accepted | The work was started and finishes in the background - for example a video being processed ({ "status": "processing" }). Check back on the object. |
| 204 | No Content | It worked, and there is nothing to send back - for example after removing a staff member. |
| 301 | Moved Permanently | The address changed; follow the Location header. |
| 400 | Bad Request | The request was refused as sent: a required field is missing, a value has the wrong type or fails validation. The body says what - often as plain text. |
| 401 | Unauthorized | No token, or one that is invalid or signed out. Without ?ionic=true, some endpoints answer this with the HTML login page instead of JSON. |
| 402 | Payment Required | The content needs a subscription: the user has no price plan that unlocks it. |
| 403 | Forbidden | The token is valid but may not do this - the record belongs to someone else, or the user is not an admin. AI builder endpoints also answer 403 when the account is out of credits. |
| 404 | Not Found | No object with that ID or URL slug, or no such endpoint. |
| 409 | Conflict | It clashes with the current state: the item is already being processed, a version is already applied, or an AI plan or preview is no longer available. |
| 410 | Gone | It existed but is no longer there - for example a comment already deleted on the social network. |
| 412 | Precondition Failed | A rule the request must meet is not met - for example push notifications of the same type at least 48 hours apart. |
| 418 | I'm a teapot | An account confirmation or password reset link was used with an email that does not match it. |
| 421 | Misdirected Request | The domain is not a Builderly site. Call the site's own address. |
| 422 | Unprocessable Content | The request was understood but could not be done - for example the AI could not read the website it was asked to clone. The message says what to try instead. |
| 429 | Too Many Requests | Slow down: the site's request limit was reached, an AI chat already has a request running, or the hourly limit of AI search answers is used up. Wait and retry. |
| 500 | Internal Server Error | Something failed on the server. Retrying later may work; if it keeps failing, the request may be one the endpoint does not handle. |
| 502 | Bad Gateway | A service the request depends on failed - for example the address a redirect forwards to. |
| 503 | Service Unavailable | Used by the lead form when an order is below its minimum value, not only for outages: read the message. |

Errors do not share one shape: depending on the endpoint the body is plain text, { "error": "..." }, { "message": "..." } or empty. Rely on the status code, and show the body to the user as the reason.

## Endpoints

### Collections

Collections group and filter the site's items. The prefix of the name is its kind: product/ is a top-level product category, grouping/ a filter inside one, service/ a service category, calendar-filter/ a filter on the booking page, blogpost/ a blog category, and so on. Collections can nest and can show their own page.

#### Collection

##### Retrieve an associated group
`GET /associated-groups/:id`
Get associated collections to another collection.
- Access: Public
- Path:
  - `id` (string): The ID of the associated group.
- Query:
  - `topic` (string): Only associated groups with this topic.
  - `service` (string): Only associated groups with this service.
  - `donation-topic` (string): Only associated groups with this donation topic.
- Status codes: 200, 404, 500
- Models: Collection

##### List all collections
`GET /collections`
Returns the site's collections, newest first unless a sort is given.
- Access: Public
- Query:
  - `type` (string): Only collections with this type.
- Returns: a list of Collection objects.
- Status codes: 200, 500
- Models: Collection

##### Create a collection
`POST /collections`
Create new collection.
- Access: Admin token
- Body:
  - `createNav` (string): The collection's create nav.
- Returns: the Collection object.
- Status codes: 201, 400, 401, 500
- Models: Collection, SiteMenu

##### Reorder collections
`PATCH /collections-reorder`
Persist a new display order for a set of collections.
- Access: Admin token
- Body:
  - `items` (string): The collection's items.
- Status codes: 200, 400, 401, 500

##### Retrieve a collection
`GET /collections/:id`
Returns one collection, found by its ID.
- Access: Public
- Path:
  - `id` (string): The ID of the collection.
- Returns: the Collection object.
- Status codes: 200, 404, 500
- Models: Collection

##### Update a collection
`PATCH /collections/:id`
Update Collection by id.
- Access: Admin token
- Path:
  - `id` (string): The ID of the collection.
- Returns: the Collection object.
- Status codes: 200, 400, 401, 404, 500
- Models: Collection, SiteMenu

##### Delete a collection
`DELETE /collections/:id`
Delete Collection record by id.
- Access: Admin token
- Path:
  - `id` (string): The ID of the collection.
- Returns: an empty answer on success.
- Status codes: 200, 401, 404, 500
- Models: Collection

##### Retrieve a collection
`GET /collections/:id/media`
Returns one collection, found by its ID.
- Access: Public
- Path:
  - `id` (string): The ID of the collection.
- Returns: the Collection object.
- Status codes: 200, 404, 500
- Models: Collection

##### Create a collection
`POST /collections/:id/media`
Creates a collection from the fields sent.
- Access: Admin token
- Path:
  - `id` (string): The ID of the collection.
- Status codes: 200, 400, 401

##### Delete a collection
`DELETE /collections/:id/media`
Deletes the collection. This cannot be undone.
- Access: Admin token
- Path:
  - `id` (string): The ID of the collection.
- Returns: an empty answer on success.
- Status codes: 200, 401
- Models: Collection, Media

#### AI builder

##### Create a collection with AI
`POST /create-new-collection`
Create a collection from a prompt, written by the AI builder.
- Access: Admin token
- Body:
  - `prompt` (string): What the AI should do with the collection, in plain words - any language.
  - `chatId` (string): The AI chat this request belongs to; its history and language carry over. Leave it out to start a new chat.
  - `aiVersion` (string): Which version of the AI builder to use; leave it out for the current one.
  - `item_id` (string): The ID of the collection to change.
- Status codes: 200, 401, 500
- Models: ChatMessage

##### Generate a collection with AI
`POST /generate-collection`
Use it to create a new category/collection/filter/store/topic for products, services, programs, blogposts, or donations.
- Access: Admin token
- Body:
  - `prompt` (string): What the AI should do with the collection, in plain words - any language.
  - `chatId` (string): The AI chat this request belongs to; its history and language carry over. Leave it out to start a new chat.
- Status codes: 200, 401, 500

##### Generate an undefined collection with AI
`POST /generate-undefined-collection`
Generate an undefined collection from a prompt, written by the AI builder.
- Access: Admin token
- Body:
  - `chatId` (string): The AI chat this request belongs to; its history and language carry over. Leave it out to start a new chat.
- Status codes: 200, 401, 500
- Models: ChatMessage

##### Modify a collection with AI
`POST /modify-collection`
Use it to modify existing collection/category/filter.
- Access: Admin token
- Body:
  - `prompt` (string): What the AI should do with the collection, in plain words - any language.
  - `item_data` (string): The current collection, as JSON - the AI changes it and returns the result.
  - `chatId` (string): The AI chat this request belongs to; its history and language carry over. Leave it out to start a new chat.
  - `item_id` (string): The ID of the collection to change.
  - `item_ids` (string): The collection's item ids.
- Status codes: 200, 401, 500

## Objects

### ChatMessage

- `chat_id`: ObjectId, required, → ChatHistory
- `role`: String, one of user | model
- `text`: String
- `target_url`: String
- `action`: String, one of RESPONSE | REDIRECT | OBJECT_RESPONSE | ERROR | CLARIFY | PROPOSED_ACTION
- `options`: String[]
- `data.object`: Mixed
- `data.object_type`: String
- `data.edit_summary`: Mixed
- `data.edit_diff`: Mixed
- `data.undo_record`: Mixed
- `data.hero_animation_offer`: Mixed
- `data.preview_state`: String
- `data.pending_credit_cost`: Number
- `data.target_restore`: Mixed
- `data.media_request`: Mixed
- `data.item_request`: Mixed
- `data.reference_request`: Mixed
- `data.section_options`: Mixed
- `data.section_blueprint`: Mixed
- `data.section_style_options`: Mixed
- `data.section_style_blueprint`: Mixed
- `data.section_role_picker`: Mixed
- `data.small_section_regeneration_options`: Mixed
- `data.small_section_regeneration_target`: Mixed
- `data.small_section_regeneration_prompt`: String
- `data.selected_small_section_action`: Mixed
- `data.component_regeneration_input`: Mixed
- `data.selected_section_role`: Mixed
- `data.selected_section_option`: Mixed
- `data.selected_section_style`: Mixed
- `data.section_options_target`: Mixed
- `data.section_options_prompt`: String
- `data.style_options_target`: Mixed
- `data.style_options_prompt`: String
- `data.previous_container`: Mixed
- `data.preserved_custom_components`: Mixed[]
- `data.selection_request`: Mixed
- `data.proposed_action`: Mixed
- `data.plan_result`: Mixed
- `data.parsed_intent`: Mixed
- `data.parsed_intent_version`: Number
- `data.parsed_intent_at`: Date
- `data.item_id`: ObjectId
- `data.design_archetype`: String
- `data.design_palette`: Mixed
- `data.out_of_credits`: Boolean
- `data.site_wide_edit`: Mixed
- `data.redesign`: Mixed
- `medias`: Object[]
  - `media`: ObjectId, → Media
  - `gcs_url`: String
  - `gemini_uri`: String
  - `gemini_interaction_id`: String
  - `_id`: ObjectId
- `products`: ObjectId[], → Product
- `services`: ObjectId[], → Service
- `blogposts`: ObjectId[], → BlogPost
- `programs`: ObjectId[], → Program
- `suggestions`: Object[]
  - `text`: String
  - `route`: String
  - `item_id`: ObjectId
  - `medias`: Mixed[]
  - `picture`: ObjectId
  - `_id`: ObjectId
- `is_system`: Boolean, default false
- `_id`: ObjectId
- `updatedAt`: Date
- `createdAt`: Date

### Collection

A group or filter of items; the prefix of its name is its kind (product/, grouping/, service/, blogpost/...).

- `name`: String, required - Name of the collection, should be unique, required.
- `parent_collection`: ObjectId, → Collection - Reference to Collection.
- `picture`: ObjectId, → Media - Reference to Media.
- `about_page`: ObjectId, → AboutPage - Reference to AboutPage.
- `match_to_option`: Boolean, default false - Matches all products which have an option with match_to_collection true.
- `is_color`: Boolean, default false - Used for products with color options.
- `color`: String - Used to visually show the color on the page when is_color is true.
- `position`: Number
- `items`: ObjectId[]
- `thumbnail`: ObjectId, → Media
- `_id`: ObjectId

### Media

An uploaded image, video or file.

- `file`: Buffer
- `file_path`: String
- `alt`: String
- `filename`: String
- `filetype`: String
- `vimeo_uri`: String
- `vimeo_picture`: String
- `duration`: Number
- `vimeo_url`: String
- `youtube_url`: String
- `youtube_picture`: String
- `thumbnail`: String
- `gcs_url`: String
- `gcs_480_30_url`: String
- `gcs_720_30_url`: String
- `gcs_1080_30_url`: String
- `picture_gcs_url`: String
- `transcode_status`: String, default "not_started"
- `owner_id`: ObjectId, → User
- `sequence.status`: String
- `sequence.started_at`: Date
- `sequence.updated_at`: Date
- `sequence.step`: String
- `sequence.done`: Number
- `sequence.total`: Number
- `sequence.ext`: String
- `sequence.trim_start`: Number
- `sequence.trim_end`: Number
- `sequence.build_id`: String
- `sequence.previous_base`: String
- `sequence.frame_count`: Number
- `sequence.fps`: Number
- `sequence.width`: Number
- `sequence.height`: Number
- `sequence.desktop_path`: String
- `sequence.mobile_path`: String
- `sequence.portrait_path`: String
- `sequence.poster`: String
- `sequence.error`: String
- `source_url`: String
- `origin`: String
- `width`: Number
- `height`: Number
- `_id`: ObjectId
- `updatedAt`: Date
- `createdAt`: Date

### SiteMenu

A link in the site's menu.

- `title`: String - The menu link label shown to users, required.
- `url`: String - The link target.
- `position`: Number - Display order starting from 0, optional.
- `submenus`: Object[]
  - `title`: String
  - `url`: String
  - `position`: Number
  - `badge`: String
  - `badge_background`: String
  - `badge_color`: String
  - `badge_radius`: Number
  - `_id`: ObjectId
- `customDropdown`: Boolean, default false
- `customDropdownId`: ObjectId, → AboutPage
- `sideMenu`: Boolean, default false
- `sidemenus`: Object[] - A list of groups, used when sideMenu is true: [{.
  - `title`: String
  - `submenus`: Object[]
    - `title`: String
    - `url`: String
    - `position`: Number
    - `icon`: String
    - `img`: ObjectId, → Media
    - `badge`: String
    - `badge_background`: String
    - `badge_color`: String
    - `badge_radius`: Number
    - `submenus`: Object[]
      - `title`: String
      - `url`: String
      - `position`: Number
      - `icon`: String
      - `img`: ObjectId, → Media
      - `badge`: String
      - `badge_background`: String
      - `badge_color`: String
      - `badge_radius`: Number
      - `_id`: ObjectId
    - `_id`: ObjectId
  - `_id`: ObjectId
- `icon`: String - FontAwesome 5 class (e.g. "fas fa-home"), optional.
- `_id`: ObjectId
