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

# Get Latest Subscription Transaction

> Use this GET endpoint to retrieve the latest transaction attempt for the highest-numbered subscription cycle that is not successful.

Use the internal `subscription_id` returned by the subscription initialize API.

Use the API key in the `x-api-key` header. Do not send it in the `Authorization` header.

> [!TIP]
>
> **Quick Reference**
>
> **Required:** `subscription_id`
>
> **Returns:** Latest transaction attempt for the highest-numbered cycle whose status is not `SUCCESS`
>
> **Method:** `GET`

## Endpoint

```http theme={"dark"}
GET https://api.fastflowpe.com/merchant/recurring/subscription/{subscription_id}/latest-transaction
```

## Request Headers

**x-api-key** `string` *required*

Your merchant API key issued by FastFlowPe.

**Accept** `string` *required*

Must be `application/json`.

## Path Parameters

**subscription\_id** `string` *required*

Internal FastFlowPe subscription UUID returned by the subscription initialize API.

Example:

`550e8400-e29b-41d4-a716-446655440000`

```bash cURL theme={"dark"}
curl --location 'https://api.fastflowpe.com/merchant/recurring/subscription/YOUR_SUBSCRIPTION_UUID/latest-transaction' \
--header 'Accept: application/json' \
--header 'x-api-key: <your-x-api-key>'
```

```python Python theme={"dark"}
import requests

url = "https://api.fastflowpe.com/merchant/recurring/subscription/YOUR_SUBSCRIPTION_UUID/latest-transaction"
headers = {"Accept": "application/json", "x-api-key": "<your-x-api-key>"}

response = requests.get(url, headers=headers)
print(response.json())
```

```javascript Node.js theme={"dark"}
const response = await fetch("https://api.fastflowpe.com/merchant/recurring/subscription/YOUR_SUBSCRIPTION_UUID/latest-transaction", {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "x-api-key": "<your-x-api-key>",
  },
});
console.log(await response.json());
```

```java Java theme={"dark"}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.fastflowpe.com/merchant/recurring/subscription/YOUR_SUBSCRIPTION_UUID/latest-transaction"))
    .header("Accept", "application/json")
    .header("x-api-key", "<your-x-api-key>")
    .GET()
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

```go Go theme={"dark"}
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.fastflowpe.com/merchant/recurring/subscription/YOUR_SUBSCRIPTION_UUID/latest-transaction", nil)
    req.Header.Set("Accept", "application/json")
    req.Header.Set("x-api-key", "<your-x-api-key>")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```php PHP theme={"dark"}
<?php
$ch = curl_init("https://api.fastflowpe.com/merchant/recurring/subscription/YOUR_SUBSCRIPTION_UUID/latest-transaction");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Accept: application/json",
    "x-api-key: <your-x-api-key>",
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
```

```ruby Ruby theme={"dark"}
require 'net/http'
require 'uri'

uri = URI('https://api.fastflowpe.com/merchant/recurring/subscription/YOUR_SUBSCRIPTION_UUID/latest-transaction')
request = Net::HTTP::Get.new(uri)
request['Accept'] = 'application/json'
request['x-api-key'] = '<your-x-api-key>'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }
puts response.body
```

Replace `YOUR_SUBSCRIPTION_UUID` with the internal `subscription_id` returned by `/merchant/recurring/subscription/initialize`.

## Response

The API returns the latest transaction attempt for the highest-numbered subscription cycle whose status is not `SUCCESS`.

```json Success theme={"dark"}
{
  "status": "success",
  "status_code": 200,
  "message": "Latest cycle transaction fetched successfully",
  "detail": null,
  "data": {
    "subscription_id": "550e8400-e29b-41d4-a716-446655440000",
    "cycle_number": 3,
    "attempt_number": 2,
    "billing_period": "2026-10-01",
    "transaction_id": "8d727851-a14e-46ea-aee4-e0fd9ca915bb",
    "amount": "499.00",
    "status": "FAILED",
    "failure_code": "PAYMENT_DECLINED",
    "remark": "Payment declined by the issuing bank",
    "created_at": "2026-10-04T12:30:15.124000"
  },
  "meta": null
}
```

```json All Cycles Successful theme={"dark"}
{
  "status": "success",
  "status_code": 200,
  "message": "All cycles are successful. No pending or failed cycle found.",
  "detail": null,
  "data": null,
  "meta": null
}
```

```json Not Found theme={"dark"}
{
  "status": "error",
  "status_code": 404,
  "message": "Subscription not found",
  "detail": null,
  "data": null,
  "meta": null
}
```

```json Authentication Error theme={"dark"}
{
  "detail": "No authorization/ x-api-key header provided."
}
```

**status** `string`

Indicates whether the API request succeeded or failed.

**status\_code** `integer`

HTTP-style status code associated with the response.

**message** `string`

Human-readable message describing the result of the request.

**detail** `object`

Additional response details when available.

This may be `null`.

**data.subscription\_id** `string`

Internal FastFlowPe subscription UUID.

**data.cycle\_number** `integer`

Highest-numbered subscription cycle that is not currently successful.

**data.attempt\_number** `integer`

Latest transaction attempt number for the selected cycle.

**data.billing\_period** `string`

Billing period associated with the subscription cycle.

Example: `2026-10-01`

**data.transaction\_id** `string`

Unique FastFlowPe transaction ID for the latest transaction attempt.

**data.amount** `string`

Transaction amount for the recurring payment attempt.

**data.status** `string`

Current status of the transaction attempt.

Example: `FAILED`

**data.failure\_code** `string`

Failure code associated with the recurring transaction.

This may be `null` when no failure code exists.

**data.remark** `string`

Human-readable remark describing the transaction result.

**data.created\_at** `string`

Timestamp when the transaction attempt was created.

**meta** `object`

Optional response metadata.

This may be `null`.

> [!NOTE]
>
> The API selects the highest-numbered subscription cycle whose status is not `SUCCESS`, then returns the latest transaction attempt for that cycle.

> [!NOTE]
>
> The subscription must belong to the merchant associated with the supplied `x-api-key`.
>
> If the subscription belongs to another merchant, it is returned as not found.

> [!TIP]
>
> Use this endpoint when you need the most recent pending or failed recurring payment attempt without fetching the complete transaction history.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.