> For the complete documentation index, see [llms.txt](https://docs.alternativepayments.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.alternativepayments.io/getting-started/3rd-party-tools/rewst.md). Agents can also search and read this documentation through its [MCP server](https://docs.alternativepayments.io/~gitbook/mcp).

# Rewst

Many MSPs use **Rewst** to automate workflows across PSA tools, billing systems, and third-party platforms. To enable automated invoice payments and customer operations via **Alternative Payments**, you’ll need to authenticate and interact with our API directly through Rewst using HTTP Request blocks.

This guide walks you through how to **authenticate with the Alternative Payments API** inside Rewst, so you can securely trigger additional API calls from your workflows.

<figure><img src="https://2362209233-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkI31NxRW8eJprVIe4Xs1%2Fuploads%2Fed3zE5TM2nSP8MIRGfOW%2Fimage.png?alt=media&amp;token=b86e8535-3664-48b9-8ac9-d61d6f4e3bef" alt=""><figcaption></figcaption></figure>

***

## :notebook\_with\_decorative\_cover:How It Works

Rewst supports HTTP requests through its workflow automation engine, allowing you to interact directly with external APIs like Alternative Payments.

To integrate with our API:

* **Authenticate using OAuth 2.0:** This authentication method is used to obtain secure, server-to-server access without user interaction.
* **Obtain an access token:** Upon successful authentication, the API returns an `access_token` that is valid for a limited time.
* **Authorize future requests:** Use this token in the `Authorization` header (`Bearer` format) to securely access other endpoints.
* **Follow standard REST practices:** All API interactions are based on REST conventions, using JSON payloads, HTTP methods, and header-based authentication.

***

## :sparkles:Step-by-Step

{% @arcade/embed url="<https://app.arcade.software/share/JdbvBHxefpi2kUJBK2eP>" flowId="JdbvBHxefpi2kUJBK2eP" %}

### :closed\_lock\_with\_key: Step 1: Authenticate using HTTP Request Block

1. In your **Rewst workflow**, click **+** to add a new **HTTP Request** block.
2. Set **Request method** to `POST`.
3. Set **URL** to:

<table><thead><tr><th width="180.22222900390625">Environment</th><th>URL</th></tr></thead><tbody><tr><td><strong>Demo</strong></td><td><code>https://public-api.demo.alternativepayments.io/oauth/token</code></td></tr><tr><td><strong>Production</strong></td><td><code>https://public-api.alternativepayments.io/oauth/token</code></td></tr></tbody></table>

<figure><img src="https://2362209233-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkI31NxRW8eJprVIe4Xs1%2Fuploads%2FtAQG2pegRHvm5JDzVN3y%2Fimage.png?alt=media&amp;token=2ed49e11-5dd7-4ba6-8bb2-2ce2af89eb77" alt=""><figcaption></figcaption></figure>

\
In the **Body** section, use:

```
grant_type=client_credentials
```

<figure><img src="https://2362209233-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkI31NxRW8eJprVIe4Xs1%2Fuploads%2Fb0nalwhX2B9zhAllMquj%2Fimage.png?alt=media&amp;token=5af66eff-1b32-4c3e-a012-75bc474dec98" alt=""><figcaption></figcaption></figure>

Set the following **Headers**:

<table><thead><tr><th width="159.77783203125">Header</th><th>Value</th></tr></thead><tbody><tr><td><code>Content-Type</code></td><td><code>application/x-www-form-urlencoded</code></td></tr><tr><td><code>Authorization</code></td><td><code>Basic </code><strong><code>your_base64_credentials</code></strong></td></tr></tbody></table>

<figure><img src="https://2362209233-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkI31NxRW8eJprVIe4Xs1%2Fuploads%2FsEPoy1nB9AdJB4OBw4Cu%2Fimage.png?alt=media&amp;token=8bf053a9-ee8c-4a6e-ad7b-7db87157d107" alt=""><figcaption></figcaption></figure>

#### :key: Base64 Credentials

To generate the **base64** credentials:

* Format your credentials as `clientId:clientSecret`

{% hint style="info" %}
You can find your `clientId` and `clientSecret` in the **Partner Dashboard** under the [API Keys](https://docs.alternativepayments.io/getting-started/quick-start/api-keys.md) section.
{% endhint %}

* Encode it locally. Don't paste your client secret into a third-party website.

```bash
printf '%s' 'clientId:clientSecret' | base64 | tr -d '\n'
```

On Windows PowerShell:

```powershell
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes('clientId:clientSecret'))
```

Paste the result in the Authorization header as:

```
Basic base64_encoded_value
```

***

### 🧪 Step 3: Test the Request

1. Click **Test** in the HTTP Request block.
2. Then click **View Result**.

✅ If successful, you will receive a JSON response containing:

<pre class="language-json"><code class="lang-json"><strong>{
</strong>  "access_token": "xxxxx",
  "token_type": "bearer",
  ...
}
</code></pre>

Copy the `access_token`.

***

### 🔁 Step 4: Use the Token in Future Requests

For any additional API calls (e.g., Listing customers, fetching invoices), include Authorization as a header:

```
Authorization: Bearer access_token
```

<figure><img src="https://2362209233-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkI31NxRW8eJprVIe4Xs1%2Fuploads%2FcWozBHInbAVsDwinEXcP%2Fimage.png?alt=media&amp;token=046ab2d6-9a52-4bc3-be5a-28aedbd197ae" alt=""><figcaption></figcaption></figure>

#### **📌 Example endpoint:**

**Request**

```
GET https://public-api.demo.alternativepayments.io/customers
```

**Response**

<figure><img src="https://2362209233-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkI31NxRW8eJprVIe4Xs1%2Fuploads%2FfPT5F7cV8nu6vUkgF4au%2Fimage.png?alt=media&amp;token=410ce855-f47e-4baa-b9c5-db690bad836e" alt=""><figcaption></figcaption></figure>

***

## :map:Flow

<figure><img src="https://2362209233-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkI31NxRW8eJprVIe4Xs1%2Fuploads%2F5srK5O88gIuoEFhOWcmN%2Fimage.png?alt=media&amp;token=dfa54466-64c1-4d51-9167-6be1e1a5ca89" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.alternativepayments.io/getting-started/3rd-party-tools/rewst.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
