# 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&#x26;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&#x20;

{% @arcade/embed flowId="JdbvBHxefpi2kUJBK2eP" url="<https://app.arcade.software/share/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&#x26;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&#x26;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&#x26;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 "mention") section.
{% endhint %}

* Go to [https://www.base64encode.org](https://www.base64encode.org/).
* Paste the string and click **Encode**.<br>

**Example**

<figure><img src="https://2362209233-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkI31NxRW8eJprVIe4Xs1%2Fuploads%2FPMykfidko8auKVbpDyHQ%2Fimage.png?alt=media&#x26;token=bf43754e-8bf3-4936-88c2-754651fec0bf" alt=""><figcaption></figcaption></figure>

Copy the result:

<figure><img src="https://2362209233-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkI31NxRW8eJprVIe4Xs1%2Fuploads%2FEaN8vlBnUaqWozK5dzj1%2Fimage.png?alt=media&#x26;token=73c50cde-e21c-4251-8b7d-623e3991cd55" alt=""><figcaption></figcaption></figure>

and paste it 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&#x26;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&#x26;token=410ce855-f47e-4baa-b9c5-db690bad836e" alt=""><figcaption></figcaption></figure>

***

## :map:Flow&#x20;

<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&#x26;token=dfa54466-64c1-4d51-9167-6be1e1a5ca89" alt=""><figcaption></figcaption></figure>
