# Transaction

## Retrieve transactions on a card

<mark style="color:green;">`GET`</mark> <https://api.krezypay.com/v1/sandbox/card/card_transaction?card_id=c451ad689f414827abb0b6dc6ea96edb>

This endpoint allows you to retrieve transactions on a Visa or Mastercard card

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name     | Type   | Description         |
| -------- | ------ | ------------------- |
| card\_id | string | The card identifier |

**Response**

{% tabs %}
{% tab title="200" %}

```json

{
    "status": "success",
    "transactions": [
        {
            "reference": "b0f6c1d480ca4a3d93c83cca7e9a9b55",
            "amount": "+4.03",
            "date": "2024-10-21 07:23:29",
            "merchant": "AUTHORIZATION",
            "website": "None",
            "logo": "https://logos.ntropy.com/consumer_icons-ATM_bank_deposit",
            "description": "Mastercard Virtual dollar card funding"
        },
        {
            "reference": "a25cde08cff04e4ebef6bf2583150999",
            "amount": "+2.00",
            "date": "2024-10-21 07:18:04",
            "merchant": "AUTHORIZATION",
            "website": "None",
            "logo": "https://logos.ntropy.com/consumer_icons-ATM_bank_deposit",
            "description": "Mastercard Virtual dollar card funding"
        },
        {
            "reference": "08e42cdc02d141ebbf7c4ef5ed3916b8",
            "amount": "+10.00",
            "date": "2024-10-21 06:22:24",
            "merchant": "AUTHORIZATION",
            "website": "None",
            "logo": "https://logos.ntropy.com/consumer_icons-ATM_bank_deposit",
            "description": "Mastercard Virtual dollar card funding"
        },
        {
            "reference": "eb0162321322450196b7e931169f5f52",
            "amount": "+2.00",
            "date": "2024-10-20 14:32:24",
            "merchant": "AUTHORIZATION",
            "website": "None",
            "logo": "https://logos.ntropy.com/consumer_icons-ATM_bank_deposit",
            "description": "Mastercard Virtual dollar card funding"
        }
    ]
}

```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

See Examples Below

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const cardId = 'c451ad689f414827abb0b6dc6ea96edb'; // Replace with your card ID
const bearerToken = 'YOUR_BEARER_TOKEN'; // Replace with your Bearer token

const url = `https://api.krezypay.com/v1/sandbox/card/card_transaction?card_id=${cardId}`;

fetch(url, {
    method: 'GET',
    headers: {
        'Authorization': `Bearer ${bearerToken}`,
        'Content-Type': 'application/json'
    }
})
.then(response => {
    // Check if the response is okay (status in the range 200-299)
    if (!response.ok) {
        throw new Error(`HTTP error! Status: ${response.status}`);
    }
    return response.json(); // Parse the JSON from the response
})
.then(data => {
    console.log('Success:', data); // Log the successful response data
})
.catch(error => {
    console.error('Error:', error); // Log any errors that occurred
});

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$cardId = 'c451ad689f414827abb0b6dc6ea96edb'; // Replace with your card ID
$bearerToken = 'YOUR_BEARER_TOKEN'; // Replace with your Bearer token

$url = "https://api.krezypay.com/v1/sandbox/card/card_transaction?card_id=" . $cardId;

// Initialize a cURL session
$ch = curl_init($url);

// Set the request method to GET
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

// Set the headers
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer " . $bearerToken,
    "Content-Type: application/json"
]);

// Return the response instead of printing it
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the request
$response = curl_exec($ch);

// Check for errors
if (curl_errno($ch)) {
    echo json_encode(["status" => "error", "message" => curl_error($ch)]);
} else {
    // Decode the response
    $data = json_decode($response, true);
    
    // Print the response data
    echo json_encode(["status" => "success", "data" => $data]);
}

// Close the cURL session
curl_close($ch);
?>

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

# Replace with your card ID and Bearer token
card_id = 'c451ad689f414827abb0b6dc6ea96edb'
bearer_token = 'YOUR_BEARER_TOKEN'

# Construct the URL
url = f'https://api.krezypay.com/v1/sandbox/card/card_transaction?card_id={card_id}'

# Set up the headers
headers = {
    'Authorization': f'Bearer {bearer_token}',
    'Content-Type': 'application/json'
}

# Send the GET request
response = requests.get(url, headers=headers)

# Check if the request was successful
if response.status_code == 200:
    # Parse the JSON response
    data = response.json()
    print("Success:", data)
else:
    # Handle errors
    print("Error:", response.status_code, response.text)

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.krezypay.com/card/transaction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
