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

# Cancel an ugwo

> Cancel an unpaid payment request.

Moves the ugwo to the `cancelled` status. Use this to close out
abandoned carts or orders the customer aborted.

<Warning>
  **An ugwo can only be cancelled while it is in `requires_ugwo`.**
  Once any activity has been started against it (and certainly once
  it has been paid), the cancel call returns an error. There are no
  refunds via cancel; refunds are handled separately.
</Warning>

| Current status                                                                     | Result                      |
| ---------------------------------------------------------------------------------- | --------------------------- |
| `requires_ugwo`                                                                    | Transitions to `cancelled`. |
| `processing` / `ugwo_successful` / `refunded` / `partially_refunded` / `cancelled` | `409 Conflict`.             |

## Path parameters

<ParamField path="ugwoUid" type="string" required>
  The ugwo ID, `ugw.XXXX.YYYY...`.
</ParamField>

## Response

Returns the cancelled ugwo with `status: "cancelled"`.

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE https://api.kwugwo.africa/v1/ugwo/ugw.VCvr.7K2qPmRtV9xLnQ8sD1cYwHfE \
    -H "Authorization: Bearer $KWUGWO_SECRET_KEY"
  ```

  ```js Node theme={null}
  await fetch(`https://api.kwugwo.africa/v1/ugwo/${ugwoUid}`, {
    method: "DELETE",
    headers: { Authorization: `Bearer ${process.env.KWUGWO_SECRET_KEY}` },
  });
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init("https://api.kwugwo.africa/v1/ugwo/{$ugwoUid}");
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST  => 'DELETE',
      CURLOPT_HTTPHEADER     => ['Authorization: Bearer ' . getenv('KWUGWO_SECRET_KEY')],
  ]);
  $ugwo = json_decode(curl_exec($ch), true);
  curl_close($ch);
  ```

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

  requests.delete(
      f"https://api.kwugwo.africa/v1/ugwo/{ugwo_uid}",
      headers={"Authorization": f"Bearer {os.environ['KWUGWO_SECRET_KEY']}"},
  )
  ```

  ```go Go theme={null}
  url := fmt.Sprintf("https://api.kwugwo.africa/v1/ugwo/%s", ugwoUid)
  req, _ := http.NewRequest("DELETE", url, nil)
  req.Header.Set("Authorization", "Bearer "+os.Getenv("KWUGWO_SECRET_KEY"))
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "uid": "ugw.VCvr.7K2qPmRtV9xLnQ8sD1cYwHfE",
    "status": "cancelled",
    "amount": 500000,
    "currency": "NGN"
  }
  ```

  ```json 409 Conflict theme={null}
  {
    "type": "https://tools.ietf.org/html/rfc2616#section-10",
    "title": "Conflict",
    "status": 409,
    "detail": "ugwo.error.cannot_cancel"
  }
  ```
</ResponseExample>
