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

# Generate renewal orders

> Generates renewal orders from one or more sets of Purchase Activity Ids. Each entry in `purchaseActivities` corresponds to a single renewal order; all the Purchase Activity Ids inside a single set are rolled up into that one renewal order. Internally fires the `GenerateRenewalOrder` Service Layer event.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/orderRenewal
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/orderRenewal:
    post:
      tags:
        - Order Renewal
      summary: Generate renewal orders
      description: >-
        Generates renewal orders from one or more sets of Purchase Activity Ids.
        Each entry in `purchaseActivities` corresponds to a single renewal
        order; all the Purchase Activity Ids inside a single set are rolled up
        into that one renewal order. Internally fires the `GenerateRenewalOrder`
        Service Layer event.
      operationId: generateRenewalOrders
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderRenewalRequest'
            example:
              purchaseActivities:
                - purchaseActivityIds:
                    - a0B5g00000PA1AAA
                    - a0B5g00000PA2AAA
                - purchaseActivityIds:
                    - a0B5g00000PA3AAA
      responses:
        '200':
          description: >-
            Renewal request processed but one or more sets failed; check
            `results[*].purchaseActivityIdToErrorMessage` and the top-level
            `success`/`errors` fields.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderRenewalResponse'
        '201':
          description: All renewal orders generated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderRenewalResponse'
              example:
                results:
                  - purchaseActivityIds:
                      - a0B5g00000PA1AAA
                      - a0B5g00000PA2AAA
                    renewalOrderId: 8015g00000RenewalAAA
                    purchaseActivityIdToErrorMessage: {}
                success: true
        '400':
          description: >-
            Validation error (missing or empty `purchaseActivities` /
            `purchaseActivityIds`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    OrderRenewalRequest:
      type: object
      required:
        - purchaseActivities
      properties:
        purchaseActivities:
          type: array
          description: >-
            One entry per renewal order to generate. Each entry's
            `purchaseActivityIds` are rolled up into a single renewal order.
          items:
            type: object
            required:
              - purchaseActivityIds
            properties:
              purchaseActivityIds:
                type: array
                description: >-
                  Set of Purchase Activity Salesforce Ids that should be renewed
                  together as one order.
                items:
                  type: string
                minItems: 1
          minItems: 1
    OrderRenewalResponse:
      allOf:
        - $ref: '#/components/schemas/BaseResponse'
        - type: object
          properties:
            results:
              type: array
              description: One result per input `purchaseActivities` entry.
              items:
                type: object
                properties:
                  purchaseActivityIds:
                    type: array
                    items:
                      type: string
                    description: Echo of the input Purchase Activity Ids for this renewal.
                  renewalOrderId:
                    type: string
                    description: >-
                      Salesforce Id of the generated renewal Order, or `null`
                      when generation failed for this set.
                    nullable: true
                  purchaseActivityIdToErrorMessage:
                    type: object
                    description: >-
                      Map of Purchase Activity Id to the error message that
                      prevented its renewal. Empty when the set succeeded.
                    additionalProperties:
                      type: string
    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.

````