> ## Documentation Index
> Fetch the complete documentation index at: https://c-mass.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel Order

> When cancelling an order that has been fulfilled, a credit for the price of the order will be applied to the current invoice. This means that it is possible for the credit for a cancellation to appear on the invoice of the following billing period. For example, if a billing period ends between when the order was placed and when it is cancelled, then the credit will be applied to the latter billing period rather than the one during which the order was placed



## OpenAPI

````yaml POST /v1/orders/{id}/cancel
openapi: 3.0.1
info:
  title: c-mass API
  description: API for managing carbon credits, projects, portfolios, and orders
  version: 1.0.0
servers:
  - url: https://carbon-engine.onrender.com
security:
  - bearerAuth: []
paths:
  /v1/orders/{id}/cancel:
    post:
      tags:
        - Orders
      summary: Cancel an order by ID
      parameters:
        - name: id
          in: path
          schema:
            type: string
          required: true
          description: The order ID
      responses:
        '200':
          description: Order cancelled successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '400':
          description: Order is already cancelled
        '404':
          description: Order not found
        '500':
          description: Server error
      security:
        - bearerAuth: []
components:
  schemas:
    Order:
      type: object
      properties:
        _id:
          description: The unique order id
          type: string
        orderNumber:
          description: The unique order number
          type: string
        customer:
          description: If purchased by customer
          type: string
        description:
          description: Description of the order
          type: string
          nullable: true
        price_sar_halalas:
          description: Total price of the credits purchased in SAR halalas
          type: number
        amount_kg:
          description: Number of carbon credits requested, in kilograms
          type: number
        creditsPurchased:
          description: Number of carbon credits fulfilled, in kilograms
          type: number
        callbackUrl:
          description: Callback URL for order updates (if any)
          type: string
          nullable: true
        state:
          description: >-
            Current status of the order, e.g., `fulfilled`, `placed`, or
            `cancelled`
          type: string
        portfolio:
          description: The portfolio ID related to the order
          type: string
        certificateUrl:
          description: URL to the order page with the certificate of the carbon credits
          type: string
        projectRecords:
          description: List of project records for this order
          type: array
          items:
            type: object
            properties:
              project_id:
                description: The ID of the project
                type: string
              project_category_id:
                description: The category ID of the project
                type: string
              credit_batch_id:
                description: The batch ID for the credits in this project
                type: string
              delta:
                description: Amount of credits allocated to this project
                type: number
              recorded_on:
                description: Date when this allocation was recorded
                type: string
                format: date-time
        invoice:
          type: object
          properties:
            amountDueSarHalalas:
              description: The total amount due in SAR halalas
              type: number
            balanceAppliedSarHalalas:
              description: The balance applied to the invoice in SAR halalas
              type: number
            receiptUrl:
              description: URL to the receipt for this order
              type: string
              nullable: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````