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

# Update my portfolio allocation

> Persist target allocation weights for the signed-in investor portfolio. The response matches GET portfolio by id, including the updated targetAllocation array.



## OpenAPI

````yaml POST /portfolios/me/allocation
openapi: 3.0.3
info:
  title: Wealthyhood Portfolio API
  version: 1.0.0
  description: >
    Investments screen portfolio endpoints that expose chart prices and return
    metrics.


    All requests require a bearer token with the scopes advertised in the
    primary specification, 

    and must include the `x-user-id` header so the platform can resolve the
    acting investor.
servers:
  - url: https://{host}
    variables:
      host:
        default: api.wealthyhood.com
        description: Wealthyhood API host name.
security:
  - bearerAuth: []
tags:
  - name: Portfolio
    description: >-
      Investments screen data for a single portfolio (prices and performance by
      tenor).
paths:
  /portfolios/me/allocation:
    post:
      tags:
        - Portfolio
      summary: Update target allocation for the signed-in user
      description: >
        Persists target allocation weights for the authenticated user's **real**
        portfolio (the first

        real portfolio returned for the user). Percentages per active
        `assetCommonId` must sum to exactly 100.


        Optional `flow` indicates how the allocation was created (`builder`,
        `robo_advisor`, `from_scratch`).

        Omit `flow` or send an empty string when the client is not coming from
        the builder or robo flow.
      parameters:
        - $ref: '#/components/parameters/ExternalUserId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatePortfolioMeAllocationRequest'
            example:
              allocation:
                equities_uk: 50
                equities_eu: 50
      responses:
        '200':
          description: >-
            Updated portfolio view (same shape as GET portfolio by id),
            including holdings and target allocation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PortfolioHoldings'
        '400':
          description: >-
            Validation failed (missing allocation, invalid assets, weights do
            not sum to 100).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
components:
  parameters:
    ExternalUserId:
      name: x-user-id
      in: header
      required: true
      description: MongoDB identifier of the user whose portfolio is being queried.
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
  schemas:
    UpdatePortfolioMeAllocationRequest:
      type: object
      required:
        - allocation
      properties:
        allocation:
          type: object
          description: Map of assetCommonId to percentage weight. Must sum to 100.
          additionalProperties:
            type: number
        flow:
          type: string
          enum:
            - builder
            - robo_advisor
            - from_scratch
          description: Optional creation flow. Omit when not applicable.
      additionalProperties: false
    PortfolioHoldings:
      type: object
      required:
        - id
        - currency
        - holdings
        - targetAllocation
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          description: Portfolio unique identifier.
        currency:
          type: string
          description: ISO currency code for the portfolio (e.g. EUR, GBP, USD).
        holdings:
          type: array
          description: Array of holdings with asset details and quantities.
          items:
            $ref: '#/components/schemas/Holding'
        targetAllocation:
          type: array
          description: >-
            Target allocation by asset. Weights are persisted with the
            portfolio. May be an empty array when unset.
          items:
            $ref: '#/components/schemas/TargetAllocationItem'
        createdAt:
          type: string
          format: date-time
          description: Portfolio creation timestamp.
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp.
      additionalProperties: false
    ApiErrorResponse:
      type: object
      properties:
        status:
          type: integer
        error:
          type: object
          properties:
            message:
              type: string
            description:
              type: string
              nullable: true
        responseId:
          type: string
          format: uuid
      additionalProperties: false
    Holding:
      type: object
      required:
        - isin
        - assetCommonId
        - quantity
      properties:
        isin:
          type: string
          description: International Securities Identification Number (ISIN) for the asset.
        assetCommonId:
          type: string
          description: Wealthyhood internal asset identifier.
        quantity:
          type: number
          format: double
          description: Number of shares/units held.
    TargetAllocationItem:
      type: object
      required:
        - assetCommonId
        - percentage
      properties:
        assetCommonId:
          type: string
          description: Wealthyhood internal asset identifier.
        percentage:
          type: number
          format: double
          description: >-
            Target allocation percentage for the asset (weights for active
            assets sum to 100 when a target is configured).
      additionalProperties: false
  responses:
    UnauthorizedError:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            status: 401
            error:
              message: User not found
            responseId: 56962f31-e1bc-4a32-8b47-623f793aa2f8
    ForbiddenError:
      description: >-
        Authenticated user cannot access the requested portfolio or lacks
        scopes.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            status: 403
            error:
              message: Portfolio does not belong to user
            responseId: 1c8b2106-5f8f-4f71-8f06-23a53205b384
    NotFoundError:
      description: Portfolio or related resource was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            status: 404
            error:
              message: Portfolio not found
            responseId: 77354fbd-2d0a-4f5a-8e15-a64c2b7ac3b5
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Auth0-issued access token that includes the scopes listed for the route.

````