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

# Cancel a transaction

> Cancels a given transaction

<Warning>You can only cancel a transaction if it has not yet been delivered. For additional details on how transaction statuses works, click this [link](/about/transaction-status)</Warning>

<RequestExample>
  ```bash Request theme={null}
  curl --location --request PUT 'https://staging-api.propaga.io/v1/transaction/{transactionId}' \
  --header 'Authorization: <your_awesome_token>' \
  --header 'Content-Type: application/json' \
  --data '{
      "status": "cancel",
      "cancellationReason": ""
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
      "success": true
  }
  ```
</ResponseExample>

## Path parameters

<ParamField path="transactionId" type="string" required>
  Propaga's transaction id
</ParamField>

## Body

<ParamField body="status" type="string" required>
  Transaction's new status, in this case always had to be `cancel`
</ParamField>

<ParamField body="cancellationReason" type="string">
  Cancellation reason for this order.

  <Expandable title="Reasons">
    ```
      DAMAGED_PRODUCT
      NEVER_RECEIVED
      MISSING_ITEMS_FROM_ORDER
      WRONG_PRODUCT
      CANCELLED_BY_USER
    ```
  </Expandable>
</ParamField>

## Response

<ResponseField name="success" type="boolean" />

## Error codes

<ResponseField>
  ```json Transaction not found (404) theme={null}
  {
      "errorCode": "TRANSACTION_NOT_FOUND",
      "errorMessage": "This transaction not found"
  }
  ```

  ```json Transaction is not on a valid status to cancel (422) theme={null}
  {
      "errorCode": "TRANSACTION_STATUS_NOT_VALID_FOR_CANCELLATION",
      "errorMessage": "The status of this transaction is not valid for cancellation"
  }
  ```
</ResponseField>
