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

# Add an order item

> Adds a new line item (Order Product) to an existing Order. The product must have a configured System Category and a matching `FCORE_PAY__Product_Config__mdt` record so that the appropriate Order Item config class can be instantiated. Subscription products may include `subscriptionPlanId`, `startDate`, and `endDate`.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/order-item
openapi: 3.0.3
info:
  title: fusionCore REST API
  version: 1.0.0
  description: >-
    External integration endpoints for the fusionCore unmanaged REST API
    package. Provides HTTP access to order creation, order item management,
    renewal generation, and subscription cancellation, all running as Salesforce
    Apex REST resources.
servers:
  - url: https://{instance}.my.salesforce.com/services/apexrest
    description: Salesforce org Apex REST endpoint
    variables:
      instance:
        default: your-instance
        description: >-
          Your Salesforce org's My Domain prefix (for example, acme-dev or
          acme.sandbox).
security:
  - bearerAuth: []
tags:
  - name: Order
    description: Order creation.
  - name: Order Item
    description: Order item creation and deletion.
  - name: Order Renewal
    description: Generate renewal orders from existing purchase activities.
  - name: Subscription Cancellation
    description: Cancel subscription renewals.
paths:
  /v1/order-item:
    post:
      tags:
        - Order Item
      summary: Add an order item
      description: >-
        Adds a new line item (Order Product) to an existing Order. The product
        must have a configured System Category and a matching
        `FCORE_PAY__Product_Config__mdt` record so that the appropriate Order
        Item config class can be instantiated. Subscription products may include
        `subscriptionPlanId`, `startDate`, and `endDate`.
      operationId: addOrderItem
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderItemCreateRequest'
            example:
              orderId: 8015g00000AbCdEAAQ
              accountId: 0015g00000XyZabAAB
              contactId: 0035g00000PqRstAAA
              productId: 01t5g00000ProductAAA
              quantity: 1
              subscriptionPlanId: a0S5g00000PlanXyzAAA
              startDate: '2026-01-01'
              endDate: '2026-12-31'
      responses:
        '201':
          description: Order item created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderItemCreateResponse'
              example:
                id: 8025g00000ItemAbAAA
                success: true
        '400':
          description: >-
            Validation error (missing required fields, non-positive quantity,
            `startDate` not before `endDate`, malformed JSON).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: >-
            Product or Product Config CMT record not found for the given
            `productId`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    OrderItemCreateRequest:
      type: object
      required:
        - orderId
        - accountId
        - contactId
        - productId
        - quantity
      properties:
        orderId:
          type: string
          description: Salesforce Id of the parent Order.
        accountId:
          type: string
          description: Salesforce Id of the Account associated with the line item.
        contactId:
          type: string
          description: Salesforce Id of the Contact associated with the line item.
        productId:
          type: string
          description: >-
            Salesforce Id of the Product2 record. Must have
            `FCORE_PAY__System_Category__c` populated and a matching
            `FCORE_PAY__Product_Config__mdt`.
        quantity:
          type: integer
          minimum: 1
          description: Number of units to add. Must be greater than zero.
        subscriptionPlanId:
          type: string
          description: >-
            Salesforce Id of the Subscription Plan. Used only for products whose
            config class is a `FCORE_MEM.SubscriptionOrderItemConfigDTO`.
        startDate:
          type: string
          format: date
          description: Subscription start date (ISO 8601, e.g. `2026-01-01`).
        endDate:
          type: string
          format: date
          description: >-
            Subscription end date (ISO 8601). When both `startDate` and
            `endDate` are supplied, `startDate` must be strictly before
            `endDate`.
    OrderItemCreateResponse:
      allOf:
        - $ref: '#/components/schemas/BaseResponse'
        - type: object
          properties:
            id:
              type: string
              description: Salesforce Id of the created Order Item.
    ErrorResponse:
      allOf:
        - $ref: '#/components/schemas/BaseResponse'
      example:
        success: false
        errors:
          - businessUnitId is required
    BaseResponse:
      type: object
      description: >-
        Common envelope returned by every endpoint. Concrete responses extend
        this shape with operation-specific fields.
      properties:
        success:
          type: boolean
          description: '`true` when the request completed without errors.'
        errors:
          type: array
          description: Populated with one or more error messages when `success` is `false`.
          items:
            type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Salesforce Session ID
      description: >-
        Salesforce session ID (or OAuth 2.0 access token issued by the
        Salesforce org) supplied as `Authorization: Bearer <token>`. Obtain via
        the Salesforce OAuth 2.0 flows or the SOAP login API.

````