> ## Documentation Index
> Fetch the complete documentation index at: https://docs.surnex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Add a widget to a report page

> Add a new widget to a report page at the specified grid position. widget_type must be one of: stat_card, line_chart, bar_chart, donut_chart, table, text. data_source identifies which SEO dataset powers the widget (e.g., 'ranking_overview', 'backlink_summary'). Static widgets such as 'text' do not require a data_source.



## OpenAPI

````yaml https://api.surnex.io/openapi.json post /v1/projects/{project_id}/reports/{report_id}/pages/{page_id}/widgets
openapi: 3.1.0
info:
  title: Surnex API
  description: |-
    Surnex SEO Platform API — api.surnex.io

    Provides the complete backend for the Surnex SEO dashboard including:
    - Multi-tenant organization management
    - Project tracking (domains)
    - Keyword rank tracking (Phase 1+)
    - Backlink analysis (Phase 3+)
    - Site auditing (Phase 4+)
    - Stripe billing integration
    - MCP endpoint for AI agents at /mcp
  version: 0.1.0
servers: []
security: []
paths:
  /v1/projects/{project_id}/reports/{report_id}/pages/{page_id}/widgets:
    post:
      tags:
        - Reports
      summary: Add a widget to a report page
      description: >-
        Add a new widget to a report page at the specified grid position.
        widget_type must be one of: stat_card, line_chart, bar_chart,
        donut_chart, table, text. data_source identifies which SEO dataset
        powers the widget (e.g., 'ranking_overview', 'backlink_summary'). Static
        widgets such as 'text' do not require a data_source.
      operationId: >-
        add_widget_v1_projects__project_id__reports__report_id__pages__page_id__widgets_post
      parameters:
        - name: project_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Project Id
        - name: report_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Report Id
        - name: page_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Page Id
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReportWidgetCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIResponse_ReportWidgetResponse_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ReportWidgetCreate:
      properties:
        widget_type:
          type: string
          title: Widget Type
          description: >-
            Type of widget to render. One of: stat_card, line_chart, bar_chart,
            donut_chart, table, text.
        data_source:
          anyOf:
            - type: string
            - type: 'null'
          title: Data Source
          description: >-
            Identifier for the data source powering this widget (e.g.,
            'ranking_overview', 'backlink_summary'). Null for static widgets
            such as 'text'.
        title:
          type: string
          maxLength: 255
          minLength: 1
          title: Title
          description: Display title shown in the widget header.
        config:
          additionalProperties: true
          type: object
          title: Config
          description: >-
            Widget-specific configuration object (metrics to display, chart
            colours, table columns, text content, etc.).
        position_x:
          type: integer
          title: Position X
          description: Horizontal grid position (column index, 0-based).
          default: 0
        position_y:
          type: integer
          title: Position Y
          description: Vertical grid position (row index, 0-based).
          default: 0
        width:
          type: integer
          maximum: 3
          minimum: 1
          title: Width
          description: Width of the widget in grid columns (1–3).
          default: 1
        height:
          type: integer
          maximum: 2
          minimum: 1
          title: Height
          description: Height of the widget in grid rows (1–2).
          default: 1
      type: object
      required:
        - widget_type
        - title
      title: ReportWidgetCreate
      description: Request body for adding a new widget to a report page.
    APIResponse_ReportWidgetResponse_:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        data:
          anyOf:
            - $ref: '#/components/schemas/ReportWidgetResponse'
            - type: 'null'
      type: object
      title: APIResponse[ReportWidgetResponse]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ReportWidgetResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        widget_type:
          type: string
          title: Widget Type
        data_source:
          anyOf:
            - type: string
            - type: 'null'
          title: Data Source
        title:
          type: string
          title: Title
        config:
          additionalProperties: true
          type: object
          title: Config
        position_x:
          type: integer
          title: Position X
        position_y:
          type: integer
          title: Position Y
        width:
          type: integer
          title: Width
        height:
          type: integer
          title: Height
        created_at:
          type: string
          format: date-time
          title: Created At
      type: object
      required:
        - id
        - widget_type
        - title
        - config
        - position_x
        - position_y
        - width
        - height
        - created_at
      title: ReportWidgetResponse
      description: A single report widget as returned by the API.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````