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

# Cancel Order

> Cancel an existing translation order that is no longer needed

Cancel an existing translation order that is no longer needed. This action is typically irreversible, so use it carefully. Only orders in certain statuses can be cancelled.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api-integration.ollang.com/integration/orders/cancel/60b8d6f1e1b9b1d8c6c0d8e1" \
    -H "X-Api-Key: <your-api-key>"
  ```

  ```javascript JavaScript theme={null}
  const orderId = "60b8d6f1e1b9b1d8c6c0d8e1";

  const response = await fetch(
    `https://api-integration.ollang.com/integration/orders/cancel/${orderId}`,
    {
      method: "POST",
      headers: {
        "X-Api-Key": "<your-api-key>",
      },
    }
  );

  if (response.status === 204) {
    console.log("Order cancelled successfully");
  }
  ```

  ```python Python theme={null}
  import requests

  order_id = "60b8d6f1e1b9b1d8c6c0d8e1"

  headers = {
      'X-Api-Key': '<your-api-key>'
  }

  response = requests.post(
      f'https://api-integration.ollang.com/integration/orders/cancel/{order_id}',
      headers=headers
  )

  if response.status_code == 204:
      print("Order cancelled successfully")
  ```

  ```php PHP theme={null}
  $orderId = '60b8d6f1e1b9b1d8c6c0d8e1';

  $curl = curl_init();

  curl_setopt_array($curl, array(
      CURLOPT_URL => 'https://api-integration.ollang.com/integration/orders/cancel/' . $orderId,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_POST => true,
      CURLOPT_HTTPHEADER => array(
          'X-Api-Key: <your-api-key>'
      ),
  ));

  $response = curl_exec($curl);
  $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  curl_close($curl);

  if ($httpCode === 204) {
      echo "Order cancelled successfully";
  }
  ```

  ```go Go theme={null}
  package main

  import (
      "fmt"
      "net/http"
  )

  func main() {
      orderId := "60b8d6f1e1b9b1d8c6c0d8e1"
      url := fmt.Sprintf("https://api-integration.ollang.com/integration/orders/cancel/%s", orderId)

      req, _ := http.NewRequest("POST", url, nil)
      req.Header.Set("X-Api-Key", "<your-api-key>")

      client := &http.Client{}
      resp, _ := client.Do(req)

      if resp.StatusCode == 204 {
          fmt.Println("Order cancelled successfully")
      }
  }
  ```

  ```java Java theme={null}
  String orderId = "60b8d6f1e1b9b1d8c6c0d8e1";

  HttpResponse<String> response = Unirest.post("https://api-integration.ollang.com/integration/orders/cancel/" + orderId)
    .header("X-Api-Key", "<your-api-key>")
    .asString();

  if (response.getStatus() == 204) {
      System.out.println("Order cancelled successfully");
  }
  ```
</RequestExample>

## Authorizations

This endpoint requires API key authentication. Include your API key in the request header:

* **Header name**: `X-Api-Key`
* **Header value**: Your API key from the Ollang dashboard
* **Format**: `X-Api-Key: your-api-key-here`

You can obtain your API key from your [Ollang dashboard](https://lab.ollang.com).

## Path Parameters

<ParamField path="orderId" type="string" required>
  The unique identifier of the order you want to cancel. This should be a valid
  order ID that you have access to and that is eligible for cancellation.
</ParamField>

## Important Notes

<Warning>
  **Order Cancellation is Irreversible**

  Once an order is cancelled, it cannot be restored. Make sure you really want to cancel the order before making this request.
</Warning>

<Info>
  **Cancellation Eligibility**

  Not all orders can be cancelled. Orders that are already in progress, completed, or delivered typically cannot be cancelled. Only orders in `pending` or early `ongoing` status are usually eligible for cancellation.
</Info>

## Response

This endpoint returns no content on successful cancellation (HTTP 204 status code). The absence of an error response indicates that the order was successfully cancelled.

<ResponseExample>
  ```json 204 theme={null}
  No content - Order cancelled successfully
  ```

  ```json 404 theme={null}
  {
    "error": "Order not found",
    "message": "No order found with the provided orderId",
    "code": "ORDER_NOT_FOUND"
  }
  ```

  ```json 400 theme={null}
  {
    "error": "Cannot cancel order",
    "message": "Order cannot be cancelled because it is already in progress or completed",
    "code": "ORDER_NOT_CANCELLABLE"
  }
  ```

  ```json 403 theme={null}
  {
    "error": "Access denied",
    "message": "You don't have permission to cancel this order",
    "code": "ACCESS_DENIED"
  }
  ```

  ```json 409 theme={null}
  {
    "error": "Order already cancelled",
    "message": "This order has already been cancelled",
    "code": "ORDER_ALREADY_CANCELLED"
  }
  ```

  ```json 401 theme={null}
  {
    "error": "Unauthorized",
    "message": "Invalid or missing API key",
    "code": "UNAUTHORIZED"
  }
  ```
</ResponseExample>
