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

# List expiry risks

> Lots projected to expire unsold (FEFO).

Key scope: read (or execute). Answers the list object (object, data, has_more, next_cursor); the same rows stay under `at_risk`, deprecated.



## OpenAPI

````yaml /openapi.json get /v1/inventory/expiry_risks
openapi: 3.1.0
info:
  title: InsightChain API
  version: 2.0.0
  description: 'The InsightChain API. Send your key as `Authorization: Bearer <key>`.'
  contact:
    name: InsightChain
    url: https://insightchain.ai/docs
  license:
    name: Proprietary
    url: https://insightchain.ai/terms
servers:
  - url: https://api.insightchain.ai
security: []
tags:
  - name: Data ingestion
  - name: Tariff check
  - name: Landed cost
  - name: Import taxes
  - name: Customs documents
  - name: Denied party screening
  - name: Location risk
  - name: Tariff impact and trade data
  - name: Recommendations
  - name: Orders and approval
  - name: Explanations
  - name: Alerts
  - name: Inventory
  - name: Forecast check
  - name: Disruptions
  - name: Product compliance
  - name: Product recalls
  - name: Product passports
  - name: Webhooks
  - name: Connections
  - name: Sync runs
  - name: API keys
  - name: Usage
  - name: Request log
  - name: Agent (MCP) server
paths:
  /v1/inventory/expiry_risks:
    get:
      tags:
        - Inventory
      summary: List expiry risks
      description: >-
        Lots projected to expire unsold (FEFO).


        Key scope: read (or execute). Answers the list object (object, data,
        has_more, next_cursor); the same rows stay under `at_risk`, deprecated.
      operationId: listExpiryRisks
      parameters:
        - name: window_days
          in: query
          required: false
          schema:
            type: integer
            minimum: 30
            maximum: 365
            default: 90
          description: Demand history window
        - name: item
          in: query
          required: false
          schema:
            type: string
            maxLength: 50
          description: Narrow to one item (external id)
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 100
        - name: cursor
          in: query
          required: false
          schema:
            type: string
            maxLength: 200
          description: >-
            next_cursor of the previous page. Opaque; valid only with the same
            filters
      responses:
        '200':
          description: OK
          headers:
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
            X-RateLimit-Limit-Day:
              $ref: '#/components/headers/X-RateLimit-Limit-Day'
            X-RateLimit-Remaining-Day:
              $ref: '#/components/headers/X-RateLimit-Remaining-Day'
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
            X-Client-Request-ID:
              $ref: '#/components/headers/X-Client-Request-ID'
            X-InsightChain-Sandbox:
              $ref: '#/components/headers/X-InsightChain-Sandbox'
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    const: list
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/InventoryExpiryRisk'
                  has_more:
                    type: boolean
                    description: Whether a further page exists
                  next_cursor:
                    type:
                      - string
                      - 'null'
                    description: Send as `cursor` for the next page; null on the last page
                  at_risk:
                    type: array
                    items:
                      $ref: '#/components/schemas/InventoryExpiryRisk'
                    deprecated: true
                    description: 'Deprecated: the same rows as `data`'
                  window_days:
                    type: integer
                    description: Demand history window used
                  data_as_of:
                    type:
                      - string
                      - 'null'
                    format: date-time
                    description: >-
                      When the organization's data was last received; null
                      before the first sync
                  demand_source:
                    $ref: '#/components/schemas/DemandSource'
                  stale:
                    type: boolean
                    description: >-
                      True when the data is more than 24 hours old, or was never
                      received
                  count:
                    type: integer
                    description: Rows in this page
                  total:
                    type: integer
                    description: Rows in the whole list, before paging
                  note:
                    type: string
                    description: >-
                      Present instead of the other fields when the organization
                      has no lots
                  notes:
                    type: array
                    items:
                      type: string
                  duration_ms:
                    type: integer
                    description: Milliseconds the request took
                  request_id:
                    type: string
                    description: >-
                      Quote this when asking about the request; also the
                      X-Request-ID header
                required:
                  - object
                  - data
                  - has_more
                  - next_cursor
                  - at_risk
                  - count
                  - duration_ms
                  - request_id
              example:
                request_id: 952d1a0d-1745-42a2-843d-409d48e548b4
                window_days: 90
                data_as_of: '2026-11-21T04:02:11.000+00:00'
                demand_source:
                  source: daily_demand
                  history_complete: true
                  history_as_of: '2026-11-21T04:10:00.000+00:00'
                  fallback_reason: null
                stale: false
                count: 1
                total: 1
                has_more: false
                at_risk:
                  - item: MAT-00000311
                    description: Hand cream 75 ml
                    location: '1004'
                    mean_daily_demand: 1.4
                    total_at_risk_units: 21
                    total_at_risk_value: 567
                    lots:
                      - lotCode: LOT-2026-0412
                        expiryDate: '2026-12-10'
                        daysToExpiry: 19
                        onHand: 48
                        projectedSold: 27
                        atRiskUnits: 21
                        atRiskValue: 567
                        status: at_risk
                duration_ms: 55
                notes:
                  - >-
                    FEFO: demand consumes earliest-expiring lots first; at-risk
                    = units projected to expire unsold before their date.
                object: list
                data:
                  - item: MAT-00000311
                    description: Hand cream 75 ml
                    location: '1004'
                    mean_daily_demand: 1.4
                    total_at_risk_units: 21
                    total_at_risk_value: 567
                    lots:
                      - lotCode: LOT-2026-0412
                        expiryDate: '2026-12-10'
                        daysToExpiry: 19
                        onHand: 48
                        projectedSold: 27
                        atRiskUnits: 21
                        atRiskValue: 567
                        status: at_risk
                next_cursor: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '405':
          $ref: '#/components/responses/MethodNotAllowed'
        '413':
          $ref: '#/components/responses/PayloadTooLarge'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalError'
        '502':
          $ref: '#/components/responses/UpstreamError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
      security:
        - apiKey: []
components:
  headers:
    RateLimit-Limit:
      schema:
        type: integer
      description: Requests allowed per minute. On every answer to an accepted API key
    RateLimit-Remaining:
      schema:
        type: integer
      description: Requests left in the current minute window
    RateLimit-Reset:
      schema:
        type: integer
      description: Seconds until the minute window resets
    X-RateLimit-Limit-Day:
      schema:
        type: integer
      description: The key's daily quota
    X-RateLimit-Remaining-Day:
      schema:
        type: integer
      description: Requests left today (resets 00:00 UTC)
    X-Request-ID:
      schema:
        type: string
      description: Quote this when asking about a request
    X-Client-Request-ID:
      schema:
        type: string
      description: Your own X-Request-ID request header, echoed. Absent when you sent none
    X-InsightChain-Sandbox:
      schema:
        type: string
        enum:
          - 'true'
      description: >-
        Present, and true, on every answer to a test key: the data is the
        sandbox's
    Allow:
      schema:
        type: string
      description: The methods the path takes
    Retry-After:
      schema:
        type: integer
      description: Seconds to wait before trying again
  schemas:
    InventoryExpiryRisk:
      type: object
      properties:
        item:
          type: string
          description: Item external id
        description:
          type:
            - string
            - 'null'
        location:
          type: string
          description: Location external id
        mean_daily_demand:
          type: number
        total_at_risk_units:
          type: number
        total_at_risk_value:
          type:
            - number
            - 'null'
          description: At-risk units at unit cost; null when the item has no cost
        lots:
          type: array
          items:
            type: object
            properties:
              lotCode:
                type: string
              expiryDate:
                type: string
                format: date
              daysToExpiry:
                type: integer
                description: Negative when already expired
              onHand:
                type: number
              projectedSold:
                type: number
                description: Units expected to sell before the lot expires
              atRiskUnits:
                type: number
                description: Units expected to expire unsold
              atRiskValue:
                type:
                  - number
                  - 'null'
              status:
                type: string
                enum:
                  - expired
                  - critical
                  - at_risk
                  - ok
            required:
              - lotCode
              - expiryDate
              - daysToExpiry
              - onHand
              - projectedSold
              - atRiskUnits
              - atRiskValue
              - status
      required:
        - item
        - description
        - location
        - mean_daily_demand
        - total_at_risk_units
        - total_at_risk_value
        - lots
    DemandSource:
      type: object
      properties:
        source:
          type: string
          enum:
            - daily_demand
            - order_lines
          description: >-
            Which demand history the answer was computed from. daily_demand: the
            daily history we keep (point of sale where a store has a feed, sales
            orders elsewhere). order_lines: your sales order lines, added up for
            this request while that history is not complete
        history_complete:
          type: boolean
          description: >-
            Whether the stored daily demand history is complete for the
            organization
        history_as_of:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            Every change committed before this time is in the stored history;
            null while it is not complete
        fallback_reason:
          type:
            - string
            - 'null'
          enum:
            - history_not_built
            - history_rebuilding
            - history_lagging
            - null
          description: Why the stored history did not answer; null when it did
      required:
        - source
        - history_complete
        - history_as_of
        - fallback_reason
    Error:
      type: object
      description: The body of every non-2xx answer
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              enum:
                - invalid_request_error
                - authentication_error
                - permission_error
                - rate_limit_error
                - api_error
            code:
              type: string
              description: >-
                Stable machine-readable code, e.g. parameter_invalid,
                scope_missing, rate_limit_exceeded. Every code is listed at
                /docs/errors
            message:
              type: string
              description: For people; what `error` used to be as a plain string
            param:
              type:
                - string
                - 'null'
              description: The parameter the error is about, when there is one
            doc_url:
              type: string
              description: Where the code is documented
          required:
            - type
            - code
            - message
            - param
            - doc_url
        request_id:
          type: string
        details:
          type: array
          items: {}
          description: >-
            On a 400 for input with several problems: one entry per problem, a
            sentence or an object with `field` and `message`
        limit:
          type: integer
          description: 'On a 429: the limit that was reached'
        code:
          type: string
          deprecated: true
          description: 'Deprecated: use error.code'
        field:
          type: string
          deprecated: true
          description: 'Deprecated: use error.param'
      required:
        - error
        - request_id
      additionalProperties: true
  responses:
    BadRequest:
      description: >-
        Invalid input: an unknown or invalid parameter (error.param names it) or
        a body the route does not accept
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-RateLimit-Limit-Day:
          $ref: '#/components/headers/X-RateLimit-Limit-Day'
        X-RateLimit-Remaining-Day:
          $ref: '#/components/headers/X-RateLimit-Remaining-Day'
        X-Client-Request-ID:
          $ref: '#/components/headers/X-Client-Request-ID'
        X-InsightChain-Sandbox:
          $ref: '#/components/headers/X-InsightChain-Sandbox'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid API key
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
        X-Client-Request-ID:
          $ref: '#/components/headers/X-Client-Request-ID'
        X-InsightChain-Sandbox:
          $ref: '#/components/headers/X-InsightChain-Sandbox'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >-
        The key lacks the scope, or the organization lacks the module or is
        suspended
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-RateLimit-Limit-Day:
          $ref: '#/components/headers/X-RateLimit-Limit-Day'
        X-RateLimit-Remaining-Day:
          $ref: '#/components/headers/X-RateLimit-Remaining-Day'
        X-Client-Request-ID:
          $ref: '#/components/headers/X-Client-Request-ID'
        X-InsightChain-Sandbox:
          $ref: '#/components/headers/X-InsightChain-Sandbox'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    MethodNotAllowed:
      description: The route does not take this method; Allow lists the ones it takes
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-RateLimit-Limit-Day:
          $ref: '#/components/headers/X-RateLimit-Limit-Day'
        X-RateLimit-Remaining-Day:
          $ref: '#/components/headers/X-RateLimit-Remaining-Day'
        X-Client-Request-ID:
          $ref: '#/components/headers/X-Client-Request-ID'
        X-InsightChain-Sandbox:
          $ref: '#/components/headers/X-InsightChain-Sandbox'
        Allow:
          $ref: '#/components/headers/Allow'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PayloadTooLarge:
      description: >-
        The body, or the data the request would read, is larger than the route
        allows
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-RateLimit-Limit-Day:
          $ref: '#/components/headers/X-RateLimit-Limit-Day'
        X-RateLimit-Remaining-Day:
          $ref: '#/components/headers/X-RateLimit-Remaining-Day'
        X-Client-Request-ID:
          $ref: '#/components/headers/X-Client-Request-ID'
        X-InsightChain-Sandbox:
          $ref: '#/components/headers/X-InsightChain-Sandbox'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    TooManyRequests:
      description: Per-minute or daily key limit; Retry-After is the real reset
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-RateLimit-Limit-Day:
          $ref: '#/components/headers/X-RateLimit-Limit-Day'
        X-RateLimit-Remaining-Day:
          $ref: '#/components/headers/X-RateLimit-Remaining-Day'
        X-Client-Request-ID:
          $ref: '#/components/headers/X-Client-Request-ID'
        X-InsightChain-Sandbox:
          $ref: '#/components/headers/X-InsightChain-Sandbox'
        Retry-After:
          $ref: '#/components/headers/Retry-After'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalError:
      description: Internal error; quote request_id
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-RateLimit-Limit-Day:
          $ref: '#/components/headers/X-RateLimit-Limit-Day'
        X-RateLimit-Remaining-Day:
          $ref: '#/components/headers/X-RateLimit-Remaining-Day'
        X-Client-Request-ID:
          $ref: '#/components/headers/X-Client-Request-ID'
        X-InsightChain-Sandbox:
          $ref: '#/components/headers/X-InsightChain-Sandbox'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UpstreamError:
      description: >-
        The API could not be reached, or a service this route depends on failed.
        Try again shortly
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-RateLimit-Limit-Day:
          $ref: '#/components/headers/X-RateLimit-Limit-Day'
        X-RateLimit-Remaining-Day:
          $ref: '#/components/headers/X-RateLimit-Remaining-Day'
        X-Client-Request-ID:
          $ref: '#/components/headers/X-Client-Request-ID'
        X-InsightChain-Sandbox:
          $ref: '#/components/headers/X-InsightChain-Sandbox'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServiceUnavailable:
      description: The API, or this route, is not available right now
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        X-RateLimit-Limit-Day:
          $ref: '#/components/headers/X-RateLimit-Limit-Day'
        X-RateLimit-Remaining-Day:
          $ref: '#/components/headers/X-RateLimit-Remaining-Day'
        X-Client-Request-ID:
          $ref: '#/components/headers/X-Client-Request-ID'
        X-InsightChain-Sandbox:
          $ref: '#/components/headers/X-InsightChain-Sandbox'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        An InsightChain API key: ic_live_... for your organization, ic_test_...
        for its sandbox

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.