Layout API

Retrieve personalized layout configurations for users based on AI decisions and experiments.

Endpoint

GET/api/v1/layout

Query Parameters

PropTypeDefaultDescription
appId*string-Your m0rphic application ID.
userId*string-Identifier for the user to get personalized layout for.
pageId*string-Identifier for the page requesting the layout.
zoneIdstring-Optional zone identifier to narrow down the request.

Example Request

bash

Response

Success (200)

json

Layout Fields

PropTypeDefaultDescription
layoutId*string-Unique identifier for this layout configuration.
pageId*string-The page this layout is for.
zoneIdstring-The zone this layout is for, if applicable.
userId*string-The user this layout was generated for.
areas*LayoutAreas-Component placements organized by area.
settings*LayoutSettings-Layout display settings (density, theme, animations).
confidence*number-AI confidence score for this layout (0-1).
reasoningstring-AI explanation for why this layout was chosen.
expiresAt*string-ISO timestamp when this layout expires.

Layout Areas

Components are organized into areas for flexible rendering:

typescript

Layout Settings

typescript

Note

Layout settings are determined based on user behavior patterns. Users who quickly scan content may receive "compact" layouts, while users who spend more time may receive "spacious" layouts.

Caching

Layouts are cached in Redis for performance. The fromCache field indicates whether the response was served from cache.

  • •Default TTL: 1 hour
  • •Cache is invalidated when experiments change
  • •Add ?nocache=true to bypass cache (debug only)

Error Responses

No Layout Found (404)

json

Tip

When no layout is found, the SDK falls back to the defaultLayout specified in the M0rphicZone component.