# get\_\_subscription\_payments

`GET /subscriptions/payments`

*Get Organization Payments*

Retrieve payment history for the authenticated user's organization. Supports optional date filtering to get payments within a specific time range.

#### Parameters

| Name      | In    | Type   | Required | Description                                         |
| --------- | ----- | ------ | -------- | --------------------------------------------------- |
| startDate | query | string | false    | Start date for filtering payments (ISO 8601 format) |
| endDate   | query | string | false    | End date for filtering payments (ISO 8601 format)   |

#### TypeScript Client Library

```typescript
public getPayments = async (params?: PaymentsQueryParams): Promise<PaymentsListResponse> => {
  const queryParams = new URLSearchParams();
  if (params?.startDate) {
    queryParams.append('startDate', params.startDate);
  }
  if (params?.endDate) {
    queryParams.append('endDate', params.endDate);
  }
  return this.makeRequest<PaymentsListResponse>(
    `subscriptions/payments${queryParams.toString() ? `?${queryParams.toString()}` : ''}`,
    'GET',
    null
  );
};
```

#### Code Samples

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

```shell
# Get all payments
curl -X GET https://backend.flashback.tech/subscriptions/payments \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}'

# Get payments with date filter
curl -X GET 'https://backend.flashback.tech/subscriptions/payments?startDate=2024-01-01&endDate=2024-12-31' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}'
```

{% endtab %}

{% tab title="HTTP" %}

```http
GET https://backend.flashback.tech/subscriptions/payments HTTP/1.1
Host: localhost:3000
Accept: application/json
Authorization: Bearer {access-token}

# With date filter
GET https://backend.flashback.tech/subscriptions/payments?startDate=2024-01-01&endDate=2024-12-31 HTTP/1.1
Host: localhost:3000
Accept: application/json
Authorization: Bearer {access-token}
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const headers = {
  'Accept':'application/json',
  'Authorization':'Bearer {access-token}'
};

// Get all payments
fetch('https://backend.flashback.tech/subscriptions/payments',
{
  method: 'GET',
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

// Get payments with date filter
const params = new URLSearchParams({
  startDate: '2024-01-01',
  endDate: '2024-12-31'
});

fetch(`https://backend.flashback.tech/subscriptions/payments?${params}`,
{
  method: 'GET',
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'rest-client'
require 'json'

headers = {
  'Accept' => 'application/json',
  'Authorization' => 'Bearer {access-token}'
}

# Get all payments
result = RestClient.get 'https://backend.flashback.tech/subscriptions/payments',
  params: {
  }, headers: headers

p JSON.parse(result)

# Get payments with date filter
result = RestClient.get 'https://backend.flashback.tech/subscriptions/payments',
  params: {
    startDate: '2024-01-01',
    endDate: '2024-12-31'
  }, headers: headers

p JSON.parse(result)
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
headers = {
  'Accept': 'application/json',
  'Authorization': 'Bearer {access-token}'
}

# Get all payments
r = requests.get('https://backend.flashback.tech/subscriptions/payments', headers = headers)
print(r.json())

# Get payments with date filter
params = {
  'startDate': '2024-01-01',
  'endDate': '2024-12-31'
}
r = requests.get('https://backend.flashback.tech/subscriptions/payments', 
                 headers=headers, 
                 params=params)
print(r.json())
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

require 'vendor/autoload.php';

$headers = array(
    'Accept' => 'application/json',
    'Authorization' => 'Bearer {access-token}',
);

$client = new \GuzzleHttp\Client();

// Get all payments
try {
    $response = $client->request('GET','https://backend.flashback.tech/subscriptions/payments', array(
        'headers' => $headers,
       )
    );
    print_r($response->getBody()->getContents());
 }
 catch (\GuzzleHttp\Exception\BadResponseException $e) {
    // handle exception or api errors.
    print_r($e->getMessage());
 }

// Get payments with date filter
try {
    $response = $client->request('GET','https://backend.flashback.tech/subscriptions/payments', array(
        'headers' => $headers,
        'query' => [
            'startDate' => '2024-01-01',
            'endDate' => '2024-12-31'
        ]
       )
    );
    print_r($response->getBody()->getContents());
 }
 catch (\GuzzleHttp\Exception\BadResponseException $e) {
    // handle exception or api errors.
    print_r($e->getMessage());
 }

 // ...
```

{% endtab %}

{% tab title="Java" %}

```java
// Get all payments
URL obj = new URL("https://backend.flashback.tech/subscriptions/payments");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());

// Get payments with date filter
String url = "https://backend.flashback.tech/subscriptions/payments?startDate=2024-01-01&endDate=2024-12-31";
URL obj2 = new URL(url);
HttpURLConnection con2 = (HttpURLConnection) obj2.openConnection();
con2.setRequestMethod("GET");
// ... rest of the code similar to above
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
       "bytes"
       "net/http"
       "net/url"
)

func main() {

    headers := map[string][]string{
        "Accept": []string{"application/json"},
        "Authorization": []string{"Bearer {access-token}"},
    }

    // Get all payments
    data := bytes.NewBuffer([]byte{})
    req, err := http.NewRequest("GET", "https://backend.flashback.tech/subscriptions/payments", data)
    req.Header = headers

    client := &http.Client{}
    resp, err := client.Do(req)
    // ...

    // Get payments with date filter
    params := url.Values{}
    params.Add("startDate", "2024-01-01")
    params.Add("endDate", "2024-12-31")
    
    req2, err := http.NewRequest("GET", "https://backend.flashback.tech/subscriptions/payments?"+params.Encode(), data)
    req2.Header = headers
    
    resp2, err := client.Do(req2)
    // ...
}
```

{% endtab %}
{% endtabs %}

> Example responses

> 200 Response

```json
{
  "success": true,
  "data": [
    {
      "id": "pay_1234567890abcdef",
      "amount": 1999,
      "currency": "usd",
      "status": "COMPLETED",
      "timestamp": "2024-01-15T10:00:00Z"
    },
    {
      "id": "pay_0987654321fedcba",
      "amount": 0,
      "currency": "usd",
      "status": "CANCELLED",
      "timestamp": "2024-01-20T14:30:00Z"
    }
  ]
}
```

> 200 Response (Empty)

```json
{
  "success": true,
  "data": []
}
```

> 400 Response (No Organization)

```json
{
  "success": false,
  "error_code": "NO_ORGANIZATION",
  "message": "User must belong to an organization"
}
```

> 400 Response (Invalid Start Date)

```json
{
  "success": false,
  "error_code": "INVALID_START_DATE",
  "message": "Invalid start date format"
}
```

> 400 Response (Invalid End Date)

```json
{
  "success": false,
  "error_code": "INVALID_END_DATE",
  "message": "Invalid end date format"
}
```

> 400 Response (Invalid Date Range)

```json
{
  "success": false,
  "error_code": "INVALID_DATE_RANGE",
  "message": "Start date must be before end date"
}
```

> 404 Response

```json
{
  "success": false,
  "error_code": "USER_NOT_FOUND",
  "message": "User not found"
}
```

> 500 Response

```json
{
  "success": false,
  "error_code": "INTERNAL_ERROR",
  "message": "Failed to retrieve payments"
}
```

#### Responses <a href="#get__subscription_payments-responses" id="get__subscription_payments-responses"></a>

| Status | Meaning                                                                                             | Description                        | Schema |
| ------ | --------------------------------------------------------------------------------------------------- | ---------------------------------- | ------ |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)                                             | List of payments                   | Inline |
| 400    | [Bad Request](https://www.rfc-editor.org/rfc/rfc9110.html#name-400-bad-request)                     | Invalid request or date parameters | Inline |
| 404    | [Not Found](https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found)                         | User not found                     | Inline |
| 500    | [Internal Server Error](https://www.rfc-editor.org/rfc/rfc9110.html#name-500-internal-server-error) | Server error                       | Inline |

#### Response Schema <a href="#get__subscription_payments-responseschema" id="get__subscription_payments-responseschema"></a>

Status Code **200**

| Name         | Type              | Required | Restrictions | Description                                    |
| ------------ | ----------------- | -------- | ------------ | ---------------------------------------------- |
| » success    | boolean           | false    | none         | Indicates if the request was successful        |
| » data       | \[object]         | false    | none         | Array of payment records                       |
| »» id        | string            | false    | none         | Unique identifier for the payment              |
| »» amount    | number            | false    | none         | Payment amount in the smallest currency unit   |
| »» currency  | string            | false    | none         | Currency code (e.g., usd, eur)                 |
| »» status    | string            | false    | none         | Payment status (COMPLETED, PENDING, CANCELLED) |
| »» timestamp | string(date-time) | false    | none         | Payment timestamp (paidAt or createdAt)        |

Status Code **400**

| Name          | Type    | Required | Restrictions | Description                       |
| ------------- | ------- | -------- | ------------ | --------------------------------- |
| » success     | boolean | false    | none         | Will be false for error responses |
| » error\_code | string  | false    | none         | Machine-readable error code       |
| » message     | string  | false    | none         | Human-readable error message      |

Status Code **404**

| Name          | Type    | Required | Restrictions | Description                       |
| ------------- | ------- | -------- | ------------ | --------------------------------- |
| » success     | boolean | false    | none         | Will be false for error responses |
| » error\_code | string  | false    | none         | Machine-readable error code       |
| » message     | string  | false    | none         | Human-readable error message      |

Status Code **500**

| Name          | Type    | Required | Restrictions | Description                       |
| ------------- | ------- | -------- | ------------ | --------------------------------- |
| » success     | boolean | false    | none         | Will be false for error responses |
| » error\_code | string  | false    | none         | Machine-readable error code       |
| » message     | string  | false    | none         | Human-readable error message      |


---

# 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.flashback.tech/support-reference/platform-api-reference/subscriptions/get__subscription_payments.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.
