# API Requests

The URL to the API service is either:

* Sandbox: <mark style="color:red;">`https://sandbox.smartfastpay.com`</mark>
* Live: <mark style="color:red;">`https://api.smartfastpay.com`</mark>

Optionally, you can include query parameters on GET calls to filter, limit the size of, and sort the data in the responses.

Most <mark style="color:red;">`GET`</mark>, <mark style="color:red;">`POST`</mark>, <mark style="color:red;">`PUT`</mark>, and <mark style="color:red;">`PATCH`</mark> calls require a JSON request body.

This sample request lists transactions:

```bash
curl -v --location --request GET 'https://sandbox.smartfastpay.com/transactions' \
        --header "Content-Type: application/json" \
        --header "Authorization: Bearer <Access-Token>"
```

***

### Query parameters

For most REST <mark style="color:red;">`GET`</mark> calls, you can include one or more query parameters on the request URI to filter, limit the size of, and sort the data in an API response. For filter parameters, see the individual <mark style="color:red;">`GET`</mark> calls.

To limit, or page, and sort the data that is returned in some API responses, use these, or similar, query parameters:<br>

> **Note:** Not all pagination parameters are available for all APIs.

<table><thead><tr><th width="193">Parameter</th><th width="209">Type</th><th>Description</th></tr></thead><tbody><tr><td><mark style="color:red;"><code>limit</code></mark></td><td><mark style="color:red;"><code>integer</code></mark><br><mark style="color:red;"><code>min: 1 | max: 40</code></mark></td><td>The number of items to return in the response.</td></tr><tr><td><mark style="color:red;"><code>page</code></mark></td><td><mark style="color:red;"><code>integer</code></mark><br><mark style="color:red;"><code>min: 1 | max: 9999999</code></mark></td><td>The page number indicates which set of items will be returned in the response. So, the combination of <mark style="color:red;"><code>page=1</code></mark> and <mark style="color:red;"><code>limit=20</code></mark> returns the first 20 items. The combination of <mark style="color:red;"><code>page=2</code></mark> and <mark style="color:red;"><code>limit=20</code></mark> returns items 21 through 40.</td></tr><tr><td><mark style="color:red;"><code>sort</code></mark></td><td><mark style="color:red;"><code>string</code></mark><br><mark style="color:red;"><code>Format: item,(asc|desc)</code></mark></td><td>Sorts the items in the response by filter in ascending or descending order.<br>Eg.: <mark style="color:red;"><code>sort=id,desc</code></mark><br><em>(This combination returns a list in descending order based on id.)</em></td></tr><tr><td><mark style="color:red;"><code>start_time</code></mark></td><td><mark style="color:red;"><code>string</code></mark><br><mark style="color:red;"><code>Internet date and time format</code></mark></td><td>The start date and time for the range to show in the response, in <a href="https://tools.ietf.org/html/rfc3339#section-5.6">Internet date and time format</a>.<br>Eg.: <mark style="color:red;"><code>start_time=2021-09-05T11:00:00Z</code></mark>.</td></tr><tr><td><mark style="color:red;"><code>end_time</code></mark></td><td><mark style="color:red;"><code>string</code></mark><br><mark style="color:red;"><code>Internet date and time format</code></mark></td><td>The end date and time for the range to show in the response, in <a href="https://tools.ietf.org/html/rfc3339#section-5.6">Internet date and time format</a>.<br>Eg.: <mark style="color:red;"><code>end_time=2021-09-05T11:00:00Z</code></mark>.</td></tr><tr><td><mark style="color:red;"><code>customer_id</code></mark></td><td><mark style="color:red;"><code>string</code></mark><br><mark style="color:red;"><code>min: 1 | max: 255</code></mark></td><td>Sorts the items in the response by looking for the customer_id that was once provided by your system.</td></tr><tr><td><mark style="color:red;"><code>transaction_id</code></mark></td><td><mark style="color:red;"><code>string</code></mark></td><td>Sorts the items in the response by looking for the transaction_id that was once provided by your system.<br>To get multiple transaction_id, send each transaction_id separating by comma (,).<br>Eg.: <mark style="color:red;"><code>8fecdfcc-4e4d-11ee,8fece5ee-4e4d-11ee,d42953be-4e4d-11ee</code></mark></td></tr></tbody></table>

For example, the Transaction API returns details for ten transactions starting with the second page sorted by descending id in the response:

{% code overflow="wrap" fullWidth="false" %}

```bash
curl -v --location --request GET 'https://sandbox.smartfastpay.com/transactions?limit=10&page=2&sort=id,desc' \
        --header "Content-Type: application/json" \
        --header "Authorization: Bearer < Access-Token >"
```

{% endcode %}

***

### HTTP request headers

The commonly used HTTP request headers are:

{% hint style="info" %}
**Content-Type**
{% endhint %}

The response format, which is required for operations with a response body. The syntax is:

```graphql
Content-Type: application/format
```

Where <mark style="color:red;">`format`</mark> is <mark style="color:red;">`json`</mark>.

{% hint style="info" %}
**Authorization**
{% endhint %}

Required to get an access token or make API calls:

* **Get an access token**

  When you create a sandbox or live REST API app, SmartFastPay generates a set of OAuth 2.0 client ID and secret credentials for the sandbox or live environment. When you make a [get an access token](/v1/guides/authentication.md) call, set the <mark style="color:red;">`Authorization`</mark> header to these credentials for the environment in which you're making the call.

  In exchange for these credentials, the SmartFastPay authorization server issues a *bearer* access token that you use for authorization when you make REST API requests.

  A bearer token enables you to complete actions on behalf and with the approval of the resource owner.
* **Make REST API calls**

  Include the access token in the <mark style="color:red;">`Authorization`</mark> header with the <mark style="color:red;">`Bearer`</mark> authentication scheme:

  ```graphql
  Authorization: Bearer <Access-Token>
  ```


---

# 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.smartfastpay.com/v1/reference/api-requests.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.
