> ## 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.

# Generate trade confirmation

> Generate a trade confirmation PDF for a matched savings order



## OpenAPI

````yaml POST /savings/orders/{id}/trade-confirmations/generate
openapi: 3.0.3
info:
  title: Wealthyhood Savings Orders API
  version: 1.0.0
  description: >
    Savings-specific trading endpoints for Wealthyhood portfolios.


    All requests use machine-to-machine (M2M) authentication. Each request
    requires:

    - A bearer access token (M2M token with required scopes)

    - An `x-user-id` header to specify which user's data to access
servers:
  - url: https://{host}
    variables:
      host:
        default: api.wealthyhood.com
        description: Wealthyhood API host name.
security:
  - bearerAuth: []
tags:
  - name: Savings Orders
    description: Submit top ups or withdrawals against a user's savings plan.
paths:
  /savings/orders/{id}/trade-confirmations/generate:
    post:
      tags:
        - Savings Orders
      summary: Generate trade confirmation PDF
      description: >
        Generate a trade confirmation PDF for a matched savings order. The `id`
        is the savings

        transaction ID (same as returned by GET /savings/orders/{id}). Returns a
        signed URL to

        download the generated PDF. Only orders with status `Matched` or
        `Settled` can have

        trade confirmations generated.
      parameters:
        - $ref: '#/components/parameters/XUserId'
        - $ref: '#/components/parameters/SavingsOrderId'
      responses:
        '200':
          description: Trade confirmation generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TradeConfirmationResponse'
              example:
                fileUri: >-
                  https://storage.example.com/trade-confirmations/7501d8537fb3fc001234abcd/abc123/wealthyhood-trade-confirmation_12-jul-2024.pdf
        '400':
          description: Order is not matched
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                status: 400
                error:
                  message: Trade confirmation can only be generated for matched orders!
                  description: Operation failed
                responseId: 7c91c5fe-d5a8-4b82-8e3f-5af2e30e43c2
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
components:
  parameters:
    XUserId:
      name: x-user-id
      in: header
      required: true
      description: >-
        User identifier for the M2M client to specify which user's data to
        access.
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
    SavingsOrderId:
      name: id
      in: path
      required: true
      description: Savings order identifier (MongoDB ObjectId)
      schema:
        type: string
        pattern: ^[a-f0-9]{24}$
  schemas:
    TradeConfirmationResponse:
      type: object
      required:
        - fileUri
      properties:
        fileUri:
          type: string
          format: uri
          description: URL to download the generated trade confirmation PDF
    ApiErrorResponse:
      type: object
      properties:
        status:
          type: integer
        error:
          type: object
          properties:
            message:
              type: string
            description:
              type: string
              nullable: true
        responseId:
          type: string
          format: uuid
  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: 145f2b0d-1d5b-4e91-8d0d-7af0ae9ad13a
    ForbiddenError:
      description: >-
        Authenticated user cannot act on 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: 5e467f79-c62c-4d83-9810-7a0f8529fd76
    NotFoundError:
      description: Savings order or related resource was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            status: 404
            error:
              message: Savings order not found
            responseId: 65c0b1f6-2a48-4c4f-a5aa-9b9c8c6f9b58
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Auth0-issued access token that includes the scopes listed for the
        endpoint.

````