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

# Give stock

> Gives a user stock by recording a stock award. The award is created with status `recorded`; Stockly then fulfills it and the stock appears in the user's portfolio. `idempotencyKey` makes this safe to retry: replaying the same request returns the original award with `idempotentReplay: true` and creates no duplicate. Reusing a key with a different payload returns 409.



## OpenAPI

````yaml /openapi.json post /v1/rewards
openapi: 3.1.0
info:
  title: Stockly Partner API
  description: >-
    Create users, give them stock, and read their portfolios. All requests and
    responses are JSON.
  version: 1.0.0
servers:
  - url: https://api.stockly.com
    description: Production (replace with your Stockly API base URL)
security:
  - apiKey: []
tags:
  - name: Users
    description: Your customers.
  - name: Stock awards
    description: Give users stock and read back award status.
  - name: Portfolio
    description: A user's live stock holdings.
  - name: Catalog
    description: Stocks available to give.
paths:
  /v1/rewards:
    post:
      tags:
        - Stock awards
      summary: Give stock
      description: >-
        Gives a user stock by recording a stock award. The award is created with
        status `recorded`; Stockly then fulfills it and the stock appears in the
        user's portfolio. `idempotencyKey` makes this safe to retry: replaying
        the same request returns the original award with `idempotentReplay:
        true` and creates no duplicate. Reusing a key with a different payload
        returns 409.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GiveStockRequest'
            example:
              userId: 6f1d2a3b-7c8d-4e9f-a0b1-c2d3e4f5a6b7
              idempotencyKey: order-1001-reward
              amountUsd: 5.25
              assetSymbol: AAPL
              source: cashback
              metadata:
                orderId: '1001'
      responses:
        '200':
          description: >-
            Idempotent replay — the award already existed and is returned
            unchanged
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockAwardResponse'
        '201':
          description: Stock award created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockAwardResponse'
              example:
                reward:
                  id: b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e
                  appId: 1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d
                  userId: 6f1d2a3b-7c8d-4e9f-a0b1-c2d3e4f5a6b7
                  idempotencyKey: order-1001-reward
                  amountUsd: 5.25
                  assetSymbol: AAPL
                  source: cashback
                  metadata:
                    orderId: '1001'
                  status: recorded
                  createdAt: '2026-06-13T12:00:00.000Z'
                  executedAt: null
                  failureReason: null
                status: recorded
                idempotentReplay: false
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: The referenced user does not exist in your app
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: idempotencyKey was already used with a different payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    GiveStockRequest:
      type: object
      required:
        - userId
        - idempotencyKey
        - amountUsd
        - assetSymbol
      properties:
        userId:
          type: string
          format: uuid
          description: Must reference an existing user in your app.
        idempotencyKey:
          type: string
          minLength: 8
          maxLength: 128
          description: Unique per logical award. Safe to retry.
        amountUsd:
          type: number
          exclusiveMinimum: 0
          maximum: 1000000
          description: Award value in USD.
        assetSymbol:
          type: string
          minLength: 1
          maxLength: 16
          description: Stock ticker from the catalog, e.g. AAPL. Normalized to uppercase.
          example: AAPL
        source:
          type: string
          minLength: 1
          maxLength: 64
          description: Optional label, e.g. cashback.
        metadata:
          type: object
          additionalProperties: true
          description: Optional arbitrary JSON, returned on reads.
    StockAwardResponse:
      type: object
      properties:
        reward:
          $ref: '#/components/schemas/StockAward'
        status:
          type: string
        idempotentReplay:
          type: boolean
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - bad_request
                - unauthorized
                - forbidden
                - not_found
                - conflict
                - unprocessable_entity
                - internal_error
                - upstream_error
            message:
              type: string
            details:
              description: Optional structured detail (e.g. validation issues).
            requestId:
              type: string
              description: Correlation id, also returned in the x-request-id header.
      example:
        error:
          code: conflict
          message: idempotencyKey was already used with a different payload
          details:
            idempotencyKey: order-1001-reward
          requestId: f0e1d2c3-4b5a-6789-0abc-def012345678
    StockAward:
      type: object
      description: A stock award. Moves from recorded to executed once fulfilled.
      properties:
        id:
          type: string
          format: uuid
        appId:
          type: string
          format: uuid
        userId:
          type: string
          format: uuid
        idempotencyKey:
          type: string
        amountUsd:
          type: number
        assetSymbol:
          type: string
        source:
          type:
            - string
            - 'null'
        metadata:
          type: object
          additionalProperties: true
        status:
          type: string
          enum:
            - recorded
            - executing
            - executed
            - failed
          description: >-
            Lifecycle. Starts at recorded; executed once the stock is in the
            user's portfolio.
        createdAt:
          type: string
          format: date-time
        executedAt:
          type:
            - string
            - 'null'
          format: date-time
        failureReason:
          type:
            - string
            - 'null'
  responses:
    BadRequest:
      description: >-
        Invalid JSON or request validation failed (details contains the specific
        issues)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid x-api-key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Your Stockly API key. Identifies your app; you never pass an app id.

````