> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cnaught.com/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 api-reference/openapi.yaml post /orders/{id}/cancel
openapi: 3.1.0
info:
  title: CNaught Carbon Credits API Documentation
  contact:
    email: support@cnaught.com
    name: CNaught
    url: https://cnaught.com/
  version: v1
  description: |
    Carbon Credits API Documentation
  termsOfService: https://cnaught.com/terms
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT.html
servers:
  - url: https://api.cnaught.com/v1
    description: CNaught API
security:
  - ApiKey: []
tags:
  - name: Orders
    description: Endpoints for placing orders and retrieving information about orders
  - name: Quotes
    description: Endpoints for obtaining price quotes for orders
  - name: Climate Impact
    description: >-
      Endpoints for retrieving climate impact data and hosted public impact page
      configuration
  - name: Subaccounts
    description: Endpoints for creating and retrieving information about subaccounts
paths:
  /orders/{id}/cancel:
    parameters:
      - $ref: '#/components/parameters/SubaccountId'
        description: >-
          If present, will only cancel the order if it belongs to the subaccount
          with given id.
      - $ref: '#/components/parameters/IdempotencyKey'
      - name: id
        in: path
        description: ID of order to cancel
        required: true
        schema:
          type: string
          examples:
            - Gre28Fc35bt3
    post:
      tags:
        - Orders
      summary: Cancel Order
      description: >
        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.
      operationId: CancelOrder
      responses:
        '200':
          description: Order Details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
              examples:
                Example:
                  value:
                    id: Gre28Fc35bt3
                    order_number: 47726-53238-46633-33562-7433
                    created_on: '2022-08-01T18:00:00.000000Z'
                    metadata: Customer metadata
                    description: On behalf of Jane Smith
                    amount_kg: 10.5
                    state: cancelled
                    price_usd_cents: 2350
                    certificate_public_url: null
                    certificate_download_public_url: null
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/CancelOrderForbidden'
        '404':
          $ref: '#/components/responses/OrderNotFound'
        '409':
          $ref: '#/components/responses/IdempotencyConflict'
        '422':
          $ref: '#/components/responses/IdempotencyUnprocessableEntity'
components:
  parameters:
    SubaccountId:
      name: X-Subaccount-Id
      in: header
      required: false
      description: >-
        If present, scopes the operation to the subaccount with given id. See
        [Subaccounts](/api/reference/#tag/Subaccounts) for more info.
      schema:
        type: string
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >
        If present, a unique identifier that allows you to retry a request
        multiple times while only performing the action once.

        See [Idempotency](/api/#idempotency) for more info.
      schema:
        type: string
  schemas:
    Order:
      type: object
      properties:
        id:
          type: string
          description: Identifier that can be used to retrieve the order details
          examples:
            - Gre28Fc35bt3
        order_number:
          type: string
          description: >-
            Hex representation derived from the order id that will be shown on
            the certificate
          examples:
            - 47726-53238-46633-33562-7433
        created_on:
          type: string
          description: Timestamp of when the order was created (in UTC)
        metadata:
          type:
            - string
            - 'null'
          description: Optional metadata that was provided with the order
          maxLength: 512
          examples:
            - internal_order_id=12345
        description:
          type:
            - string
            - 'null'
          description: >-
            Optional public description for the order that will be shown on the
            certificate, as provided when order was placed
          maxLength: 512
          examples:
            - on behalf of Jane Smith
        amount_kg:
          type: number
          description: Amount of credits purchased, in kg of CO₂e
          examples:
            - 10.5
        state:
          type: string
          enum:
            - placed
            - fulfilled
            - cancelled
          description: >
            The current state of the order.

            * `placed` - the order has been placed, and is waiting to be matched
            against available credits in our system.

            * `fulfilled` - the order has been fulfilled by matching it against
            available credits in our system, which have been retired.

            * `canceled` - the order has been canceled
        price_usd_cents:
          type: number
          description: Amount charged for the credits purchased, in USD cents
          examples:
            - 2350
        callback_url:
          type: string
          description: >-
            Callback URL to invoke when status of the order changes, if
            specified in the order
        certificate_public_url:
          type:
            - string
            - 'null'
          description: >-
            URL for the publicly accessible page showing order details and the
            certificate. This will be null if the order state is cancelled
          examples:
            - https://registry.cnaught.com/orders/ABCDE
        certificate_download_public_url:
          type:
            - string
            - 'null'
          description: >-
            URL for downloading the certificate PDF. This will be null if the
            order state is cancelled
          examples:
            - https://registry.cnaught.com/api/certificates/ABCDE/pdf
        project_allocations:
          type: array
          items:
            $ref: '#/components/schemas/ProjectAllocation'
          description: >-
            For fulfilled orders, a list of the projects that were used to
            fulfill the order
        checkout_session_id:
          type:
            - string
            - 'null'
          description: >
            Id of the checkout session whose completion resulted in the creation
            of this order.

            Null if the order did not originate from a checkout session.
          examples:
            - zpQ6QSNRQh
    ProjectAllocation:
      type: object
      properties:
        project:
          $ref: '#/components/schemas/Project'
          description: Details of the project for this allocation
        amount_kg:
          type: number
          description: Amount (in kg CO₂e) of the order fulfilled from this project
          examples:
            - 1000
        retirements:
          type: array
          items:
            $ref: '#/components/schemas/Retirement'
          description: List of retirement records for this project allocation
    BaseProblemDetails:
      type: object
      description: Problem details object returned on errors
      properties:
        title:
          type: string
          description: Short, human-readable summary of the problem
        details:
          type: string
          description: Longer, human-readable description of the problem
        type:
          type: string
          description: URI that identifies the problem type
        status:
          type: integer
          description: HTTP status code of the error
    Project:
      type: object
      description: Details about a project
      properties:
        id:
          type: string
          description: Identifier that can be used to retrieve the project details
          examples:
            - Fc35bt3
        name:
          type: string
          description: Name of the project
          examples:
            - Liling Landfill Gas Project
        summary:
          type:
            - string
            - 'null'
          description: A short summary of the project
          examples:
            - Lorem Ipsum
        description:
          type:
            - string
            - 'null'
          description: A longer description of the project
          examples:
            - Lorem Ipsum Shmipsum
        type:
          type: string
          description: Type of project, eg Afforrestation, Renewable Energy, etc
          examples:
            - REDD
        activity_types:
          type: array
          description: List of activity types for the project
          items:
            type: string
          examples:
            - - Landfill Gas
              - Renewable Energy
        developer:
          type:
            - string
            - 'null'
          description: The name of the company or organization sponsoring the project
          examples:
            - Charm Industrial
        registry_name:
          type:
            - string
            - 'null'
          description: >-
            The name of the registry on which the project's credits are
            registered
          examples:
            - Verra
        registry_id:
          type:
            - string
            - 'null'
          description: The id of the project within the registry
          examples:
            - 824
        registry_url:
          type:
            - string
            - 'null'
          description: The full url to the project's documentation on the registry website
          examples:
            - https://registry.verra.org/app/projectDetail/VCS/824
        location_name:
          type:
            - string
            - 'null'
          description: Location of the project
          examples:
            - Fujian Province, China
        location_latitude:
          type:
            - number
            - 'null'
          description: Latitude for the location of the project
          examples:
            - 26.0833
        location_longitude:
          type:
            - number
            - 'null'
          description: Longitude for the location of the project
          examples:
            - 119.3
        primary_image_url:
          type:
            - string
            - 'null'
          description: URL for the primary image of the project
          examples:
            - >-
              https://assets.cnaught.com/63a4ad4c853f90fd4c455107/64122d1dcf47f3840933826a_charm-industrial.jpg
        un_sdg_goals:
          type: array
          description: >-
            list of UN Sustainable Development Goals supported by this project;
            see https://sdgs.un.org/goals
          items:
            type: number
          examples:
            - - 1
              - 4
              - 6
        methodology:
          type:
            - string
            - 'null'
          description: The methodology used for the project
          examples:
            - VM0010
        verifier:
          type:
            - string
            - 'null'
          description: The verifier of the project
          examples:
            - DNV GL
        permanence:
          type:
            - string
            - 'null'
          description: Information about the permanence of the carbon removal
          examples:
            - 100+ years
        lifetime:
          type: object
          description: The lifetime of the project
          properties:
            start_year:
              type:
                - integer
                - 'null'
              description: The start year of the project
              examples:
                - 2020
            end_year:
              type:
                - integer
                - 'null'
              description: The end year of the project
              examples:
                - 2040
        impact_type:
          type:
            - string
            - 'null'
          description: >-
            The type of impact the project has (avoided emissions, removal, or
            mix of both)
          examples:
            - Avoided Emissions
        due_diligence:
          type:
            - string
            - 'null'
          description: Information about the due diligence performed on the project
          examples:
            - Extensive verification process was conducted...
        beyond_carbon:
          type:
            - string
            - 'null'
          description: Information about benefits beyond carbon reduction
          examples:
            - This project also supports local communities...
        risk_of_reversal:
          type:
            - string
            - 'null'
          description: Information about the risk of carbon reversal
          examples:
            - Low risk due to long-term conservation agreements...
        third_party_labels:
          type:
            - array
            - 'null'
          description: List of third-party labels or certifications
          items:
            type: string
          examples:
            - - Gold Standard
              - Climate Action Reserve
        notable_buyers:
          type:
            - array
            - 'null'
          description: List of notable buyers of credits from this project
          items:
            type: object
            properties:
              name:
                type: string
                description: Name of the buyer
                examples:
                  - Microsoft
              logo_url:
                type: string
                description: URL to the buyer's logo
                examples:
                  - https://assets.cnaught.com/logos/microsoft.png
              logo_alt_text:
                type:
                  - string
                  - 'null'
                description: Alt text for the buyer's logo
                examples:
                  - Microsoft logo
        due_diligence_figure:
          type:
            - object
            - 'null'
          description: Figure illustrating due diligence information
          properties:
            description:
              type: string
              description: Description of the due diligence figure
              examples:
                - This chart shows the verification process...
            image_url:
              type: string
              description: URL to the due diligence figure image
              examples:
                - https://assets.cnaught.com/figures/due-diligence.png
            image_alt_text:
              type:
                - string
                - 'null'
              description: Alt text for the due diligence figure image
              examples:
                - Due diligence verification process diagram
        news_articles:
          type:
            - array
            - 'null'
          description: List of news articles related to the project
          items:
            type: object
            properties:
              title:
                type: string
                description: Title of the news article
                examples:
                  - New Carbon Capture Project Launched
              url:
                type: string
                description: URL to the news article
                examples:
                  - https://example.com/news/carbon-capture
              author:
                type: string
                description: Author of the news article
                examples:
                  - John Smith
              published_on:
                type: string
                format: date-time
                description: Publication date of the news article
                examples:
                  - '2023-01-15T00:00:00Z'
              cnaught_take:
                type:
                  - string
                  - 'null'
                description: CNaught's perspective on the news article
                examples:
                  - This article highlights the importance of...
    Retirement:
      type: object
      properties:
        serial_number_range:
          type:
            - string
            - 'null'
          description: >-
            The serial number range of the retired tranche block(s) from which
            an order's project allocation is taken. The format differs depending
            on the registry
          examples:
            - GS1-1-KE-GS5642-16-2018-20671-12345-12350
        url:
          type:
            - string
            - 'null'
          description: >-
            The url to the retired tranche block(s) record on the project's
            registry
  responses:
    Unauthorized:
      description: Request Unauthorized
      content:
        application/problem+json:
          schema:
            properties:
              title:
                type: string
                description: Short, human-readable summary of the problem type
              status:
                type: integer
                description: HTTP status code of the error
          example:
            title: Authorization has been denied for this request
            status: 401
    CancelOrderForbidden:
      description: Forbidden Due to Order Already Cancelled
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/BaseProblemDetails'
          example:
            type: https://api.cnaught.com/v1/errors/forbidden
            title: Order xyz has already been cancelled
            status: 403
    OrderNotFound:
      description: Order Not Found
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/BaseProblemDetails'
          example:
            type: https://api.cnaught.com/v1/errors/not-found
            title: Could not find order
            status: 404
    IdempotencyConflict:
      description: Concurrent Requests with Same Idempotency Key
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/BaseProblemDetails'
          example:
            type: https://api.cnaught.com/v1/errors/idempotency-concurrent-requests
            title: Concurrent request in flight with same idempotency key
            status: 409
    IdempotencyUnprocessableEntity:
      description: Mismatched Requests with Same Idempotency Key
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/BaseProblemDetails'
          example:
            type: https://api.cnaught.com/v1/errors/idempotency-changed-payload
            title: >-
              Previous request submitted with same idempotency key had different
              payload
            status: 422
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer

````