Messages API

The Messages API lets you manage floating messages programmatically. All endpoints require an authenticated session cookie — they are intended for use from the FloatMessage dashboard or server-side integrations that share the same session.

GET/api/messages

Returns all messages belonging to the authenticated user.

Authentication

Requires a valid session cookie. Returns 401 if unauthenticated.

Response 200

[
  {
    "id": "clx1abc2d0001ab12example",
    "name": "Welcome Discount",
    "template": "banner",
    "position": "BOTTOM_RIGHT",
    "active": true,
    "clicks": 142,
    "impressions": 3891,
    "createdAt": "2026-03-01T10:00:00.000Z",
    "updatedAt": "2026-03-20T14:30:00.000Z"
  }
]

POST/api/messages

Creates a new floating message. Requires an authenticated session and an active plan or trial.

Authentication

Requires a valid session cookie and an active subscription or trial. Returns 401 if unauthenticated, or 403 if the plan/trial has expired.

Request Body

{
  "name": "Welcome Discount",
  "template": "banner",
  "htmlContent": "<div>...</div>",
  "cssContent": ".class { ... }",
  "slidesData": null,
  "position": "BOTTOM_RIGHT",
  "trigger": "IMMEDIATE",
  "triggerValue": null,
  "domains": [],
  "geoCountries": ["US", "GB"],
  "scheduleDays": [1, 2, 3, 4, 5],
  "scheduleTimeStart": "09:00",
  "scheduleTimeEnd": "17:00",
  "scheduleDateStart": "2026-03-01",
  "scheduleDateEnd": "2026-03-31",
  "dismissBehavior": "SESSION",
  "dismissDuration": null
}

Body Fields

FieldTypeDescription
namestringDisplay name for the message.
templatestringTemplate type, e.g. banner, story, popup.
htmlContentstring | nullHTML content for non-story templates.
cssContentstring | nullCustom CSS scoped to the message.
slidesDataarray | nullSlide objects for story templates. Each slide has imageUrl, linkUrl, and duration.
positionstringScreen position: BOTTOM_RIGHT, BOTTOM_LEFT, TOP_RIGHT, TOP_LEFT.
triggerstringWhen to show: IMMEDIATE, DELAY, SCROLL.
triggerValuestring | nullDelay in ms or scroll percentage, depending on trigger type.
domainsstring[]Allowed domains. Empty array means all domains.
geoCountriesstring[]ISO 3166-1 alpha-2 country codes. Empty means all countries.
scheduleDaysnumber[]Days of week (0 = Sunday, 6 = Saturday).
scheduleTimeStart / scheduleTimeEndstring | nullTime range in HH:mm format, or null for all day.
scheduleDateStart / scheduleDateEndstring | nullDate range in YYYY-MM-DD format, or null for no date restriction.
dismissBehaviorstringSESSION, DURATION, or NONE.
dismissDurationnumber | nullSeconds before the message can reappear (for DURATION behavior).

Response 201

Returns the created message object with all fields including id, createdAt, and updatedAt.

Error Responses

StatusDescription
401Unauthenticated. No valid session.
403Plan or trial expired.

PUT/api/messages

Updates an existing message. The request body must include the id field, and the authenticated user must own the message.

Authentication

Requires a valid session cookie and message ownership.

Request Body

{
  "id": "clx1abc2d0001ab12example",
  "name": "Updated Discount Banner",
  "htmlContent": "<div>New content</div>",
  ...all other fields from POST
}

Response 200

Returns the updated message object.

Error Responses

StatusDescription
401Unauthenticated.
403Not the owner of this message.
404Message not found.

DELETE/api/messages?id={messageId}

Deletes a message. The authenticated user must own the message.

Query Parameters

ParameterTypeDescription
idstringRequired. The message ID to delete.

Response 200

{ "ok": true }

Error Responses

StatusDescription
401Unauthenticated.
403Not the owner of this message.
404Message not found.