---
title: "Pre-Auth, Completion & Cancel Pre-Auth"
source_url: https://docs.rapyd.net/en/pre-auth,-completion---cancel-pre-auth.html
lang: en
---

# Pre-Auth, Completion & Cancel Pre-Auth

Pre-authorisation reserves funds on the card without capturing them. A completion finalises the capture. A cancel releases the reservation.

### Start a pre-auth

```java

Api.startTransaction(amount, TransactionType.PREAUTH, context);
```

The `TRANSACTION_RESULT_ACTION` result contains `authCode` and `messageId` — save these to perform a completion or cancel later.

### Completion - with UI

Displays the completion screen, allowing the operator to confirm or adjust the amount.

```java

HashMap<String, String> params = new HashMap<>();
params.put(Parameters.REFERENCE_ID, "ref-789");
Api.completion(context, params);
```

To provide card details from your own records and show the UI:

```java

Api.completion(context, firstSix, lastFour, amount, authCode, messageId, cardNumberLength, params);
```

### Completion - silent (no UI)

Pass `SHOW_UI = "false"` to perform the completion entirely in the background:

```java

params.put(Parameters.SHOW_UI, "false");
Api.completion(context, firstSix, lastFour, amount, authCode, messageId, cardNumberLength, params);
```

Silent completion uses a broadcast instead of launching an activity. The result is returned via `TRANSACTION_RESULT_ACTION`.

### Cancel pre-auth - with UI

```java

Api.cancelPreAuth(context, params);
// Or with explicit card details:
Api.cancelPreAuth(context, firstSix, lastFour, authCode, messageId, cardNumberLength, params);
```

### Cancel pre-auth - silent (no UI)

```java

params.put(Parameters.SHOW_UI, "false");
Api.cancelPreAuth(context, firstSix, lastFour, authCode, messageId, cardNumberLength, params);
```

**Response for all completion/cancel operations:** `TRANSACTION_RESULT_ACTION`

> **Note:**
>
> Prefer the overloads that accept `cardNumberLength` - the variants without it assume a 16-digit PAN.
