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

# Delete order

> Deletes the order, its lines and its customer movement.

Deletes the order, its lines, the automatically assigned approval and status records and, if it has one, its customer movement. An order whose customer movement has been closed by a collection or payment cannot be deleted (`6016`, `6017`). An order that other records (for example a quote or an opportunity) refer to cannot be deleted either (`6014`). There is no other restriction by status: see [editing and deleting](/en/v1/orders/overview#editing-and-deleting).

## Error codes

Codes this endpoint can return. The [general errors](/en/v1/guides/result-codes) that apply to every endpoint (authentication, permissions, request headers, daily limit) are not repeated here.

| Code   | HTTP | Meaning                                                                                                                                                            |
| ------ | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `6000` | 404  | Order not found                                                                                                                                                    |
| `6014` | 400  | The order cannot be deleted because other records (quote, opportunity, ...) refer to it                                                                            |
| `6016` | 400  | The credit record the purchase order created on the customer's account has been closed by a payment, so the order's customer movement cannot be changed or removed |
| `6017` | 400  | The debit record the sales order created on the customer's account has been closed by a collection, so the order's customer movement cannot be changed or removed  |


## OpenAPI

````yaml api-reference/openapi.json DELETE /api/v1/orders/{orderId}
openapi: 3.1.1
info:
  title: Noyax API
  description: Server-to-server API for integrations to access Noyax data.
  version: '1.0'
servers:
  - url: https://dev.noyax.com/services/noyax_api
security:
  - Bearer: []
tags:
  - name: Sections
  - name: Warehouses
  - name: Quotes
  - name: Product Critical Stock
  - name: Product groups
  - name: Product Parameter Definitions
  - name: Product Parameters
  - name: Product Prices
  - name: Products
  - name: Orders
  - name: Cities
  - name: Countries
  - name: Currencies
  - name: Districts
  - name: Line Groups
  - name: Shipment Definitions
  - name: Units
  - name: VAT rates
  - name: Customer Addresses
  - name: Customer Bank Accounts
  - name: Customer Definitions
  - name: Customer Group Members
  - name: Customer Links
  - name: Customer Parameters
  - name: Customer Representatives
  - name: Customers
  - name: Customer Statement
  - name: Customer Telephones
paths:
  /api/v1/orders/{orderId}:
    delete:
      tags:
        - Orders
      summary: Delete order
      description: >-
        Deletes the order, its lines and its customer movement. An order whose
        customer movement has been closed by a collection or payment, or that
        other records (for example quotes or opportunities) refer to, cannot be
        deleted.
      parameters:
        - name: orderId
          in: path
          description: Order ID.
          required: true
          schema:
            type: string
            format: uuid
        - name: X-UserID
          in: header
          description: >-
            ID of the Noyax user the request is made on behalf of. Written to
            the audit fields of created, updated and deleted records.
          required: true
          schema:
            minimum: 1
            type: integer
            format: int32
        - name: X-CompanyID
          in: header
          description: >-
            ID of the company. The user must be assigned to this company. All
            reads and writes are limited to this company.
          required: true
          schema:
            minimum: 1
            type: integer
            format: int32
        - name: X-PeriodID
          in: header
          description: >-
            ID of the accounting period. Optional for customer endpoints; if
            sent, it is written to created records.
          schema:
            minimum: 1
            type: integer
            format: int32
      responses:
        '204':
          description: No Content
          content:
            application/json: {}
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '6017'
                Message: >-
                  The debit record created by this order for customer 'Example
                  Trading Ltd.' has been closed. Operation cancelled.
                Errors:
                  - Code: '6017'
                    Message: >-
                      The debit record created by this order for customer
                      'Example Trading Ltd.' has been closed. Operation
                      cancelled.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0102'
                Message: Token has expired. Obtain a new token using the refresh token.
                Errors:
                  - Code: '0102'
                    Message: >-
                      Token has expired. Obtain a new token using the refresh
                      token.
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0110'
                Message: You do not have permission for this operation.
                Errors:
                  - Code: '0110'
                    Message: You do not have permission for this operation.
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '6000'
                Message: Order not found.
                Errors:
                  - Code: '6000'
                    Message: Order not found.
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0120'
                Message: Daily request limit (10000) exceeded.
                Errors:
                  - Code: '0120'
                    Message: Daily request limit (10000) exceeded.
components:
  schemas:
    ErrorResult:
      type: object
      properties:
        Success:
          type: boolean
          description: Whether the operation succeeded.
          example: false
        ResultCode:
          type:
            - 'null'
            - string
          description: >-
            "0000" on success. On failure, the code of the first error; all
            errors are listed in Errors.
        Message:
          type:
            - 'null'
            - string
          description: >-
            Error message when Success is false. Messages of all errors are
            joined into a single text.
        Errors:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/ResultError'
          description: All errors with their codes. Only present when Success is false.
    ResultError:
      required:
        - Code
        - Message
      type: object
      properties:
        Code:
          type: string
          description: Error code. See the result codes page for the full list.
        Message:
          type: string
          description: Error description.
  securitySchemes:
    Bearer:
      type: http
      description: Access token obtained from the Noyax auth service with your API key.
      scheme: bearer
      bearerFormat: JWT

````