Authentication

You'll need to authenticate your requests to access most of the endpoints in the Felloh API.

Requests to our API need to be authorised using a JWT token, JWT is an open standard designed to allow powerful server-to-server authentication.

Authenticating your requests

You can generate a public and private key from the felloh dashboard and can generate further keys via the API or dashboard (if your initial token has permission to do so).

Felloh uses public & private keys to generate a JWT bearer token to allow you to access our API's.

Once you have generated a public and private key using our dashboard, you can generate a Bearer token to make requests against our API.

Authentication Request

POST
https://api.felloh.com/token
<div class="syntax-highlighter"><pre style="color:#d4d4d4;font-size:13px;text-shadow:none;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Courier New&quot;, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;background:#1b0f27"><code class="language-js" style="white-space:pre;color:#d4d4d4;font-size:13px;text-shadow:none;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Courier New&quot;, monospace;direction:ltr;text-align:left;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span class="token" style="color:#c586c0">import</span><span> </span><span class="token">axios</span><span> </span><span class="token" style="color:#c586c0">from</span><span> </span><span class="token" style="color:#ce9178">&#x27;axios&#x27;</span><span class="token" style="color:#d4d4d4">;</span><span>
</span>
<span></span><span class="token" style="color:#569CD6">const</span><span> </span><span class="token function-variable" style="color:#c0a9e5">getToken</span><span> </span><span class="token" style="color:#d4d4d4">=</span><span> </span><span class="token" style="color:#569CD6">async</span><span> </span><span class="token" style="color:#d4d4d4">(</span><span class="token" style="color:#d4d4d4">)</span><span> </span><span class="token" style="color:#569CD6">=&gt;</span><span> </span><span class="token" style="color:#d4d4d4">{</span><span>
</span><span>  </span><span class="token" style="color:#569CD6">const</span><span> response </span><span class="token" style="color:#d4d4d4">=</span><span> </span><span class="token" style="color:#c586c0">await</span><span> </span><span class="token" style="color:#c0a9e5">axios</span><span class="token" style="color:#d4d4d4">(</span><span class="token" style="color:#d4d4d4">{</span><span>
</span><span>    </span><span class="token literal-property" style="color:#9cdcfe">method</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#ce9178">&#x27;post&#x27;</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token literal-property" style="color:#9cdcfe">url</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#ce9178">&#x27;https://api.felloh.com/token&#x27;</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token literal-property" style="color:#9cdcfe">headers</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#d4d4d4">{</span><span>
</span><span>      </span><span class="token string-property" style="color:#9cdcfe">&#x27;Content-Type&#x27;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#ce9178">&#x27;application/json&#x27;</span><span>
</span><span>    </span><span class="token" style="color:#d4d4d4">}</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token literal-property" style="color:#9cdcfe">data</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token known-class-name" style="color:#4ec9b0">JSON</span><span class="token" style="color:#d4d4d4">.</span><span class="token method property-access" style="color:#c0a9e5">stringify</span><span class="token" style="color:#d4d4d4">(</span><span class="token" style="color:#d4d4d4">{</span><span>
</span><span>        </span><span class="token string-property" style="color:#9cdcfe">&quot;public_key&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> process</span><span class="token" style="color:#d4d4d4">.</span><span class="token property-access">env</span><span class="token" style="color:#d4d4d4">.</span><span class="token" style="color:#9cdcfe">PUBLIC_KEY</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>        </span><span class="token string-property" style="color:#9cdcfe">&quot;private_key&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> process</span><span class="token" style="color:#d4d4d4">.</span><span class="token property-access">env</span><span class="token" style="color:#d4d4d4">.</span><span class="token" style="color:#9cdcfe">PRIVATE_KEY</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>      </span><span class="token" style="color:#d4d4d4">}</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token" style="color:#d4d4d4">)</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>  </span><span class="token" style="color:#d4d4d4">}</span><span class="token" style="color:#d4d4d4">)</span><span class="token" style="color:#d4d4d4">;</span><span>
</span>

<span>  </span><span class="token" style="color:#c586c0">return</span><span> response</span><span class="token" style="color:#d4d4d4">.</span><span class="token property-access">data</span><span class="token" style="color:#d4d4d4">;</span><span>
</span><span></span><span class="token" style="color:#d4d4d4">}</span><span class="token" style="color:#d4d4d4">;</span><span>
</span></code></pre></div>
<div class="syntax-highlighter"><pre style="color:#d4d4d4;font-size:13px;text-shadow:none;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Courier New&quot;, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;background:#1b0f27"><code class="language-json" style="white-space:pre;color:#d4d4d4;font-size:13px;text-shadow:none;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Courier New&quot;, monospace;direction:ltr;text-align:left;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span class="token" style="color:#d4d4d4">{</span><span>
</span><span>  </span><span class="token" style="color:#9cdcfe">&quot;data&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#d4d4d4">{</span><span>
</span><span>    </span><span class="token" style="color:#9cdcfe">&quot;expiry_time&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#b5cea8">1657485864</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token" style="color:#9cdcfe">&quot;type&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#ce9178">&quot;BEARER&quot;</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token" style="color:#9cdcfe">&quot;token&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#ce9178">&quot;vXdvRb0DIw9DSnC4NCeCWmjmI5dJmeMrl0Esg2HG6EeaHZmcaYtymifw7YVCySCAuAEpruJx8fZBAX0FYmhfOc5WSzp9uDRQ3xdC06JTIDLVVmngvfFRkxCsPaV4oqmYCZcwe6oldLhWZnHE2EPUbc7OG3W3klyGQg8u00UmwqXeLIgA8CryoNGgA3Y3mitxKV7Y2uhlmPySP0BQ1K64ml8bJMLoLbQj3PMpt1eKwJdlETCTRjW&quot;</span><span>
</span><span>  </span><span class="token" style="color:#d4d4d4">}</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>  </span><span class="token" style="color:#9cdcfe">&quot;errors&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#d4d4d4">[</span><span class="token" style="color:#d4d4d4">]</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>  </span><span class="token" style="color:#9cdcfe">&quot;meta&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#d4d4d4">{</span><span>
</span><span>    </span><span class="token" style="color:#9cdcfe">&quot;code&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#b5cea8">200</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token" style="color:#9cdcfe">&quot;reason&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#ce9178">&quot;OK&quot;</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token" style="color:#9cdcfe">&quot;message&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#ce9178">&quot;The request was successful&quot;</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token" style="color:#9cdcfe">&quot;request_id&quot;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#ce9178">&quot;10610d99-42cf-41dd-9d23-128df906544c&quot;</span><span>
</span><span>  </span><span class="token" style="color:#d4d4d4">}</span><span>
</span><span></span><span class="token" style="color:#d4d4d4">}</span><span>
</span></code></pre></div>

Using Bearer Token

To make an authenticated request, add the Authorization header with the bearer token to your HTTP request to the Felloh API.

An Example Authenticated Request

POST
https://api.felloh.com/agent/transactions${transactionID}/refund
<div class="syntax-highlighter"><pre style="color:#d4d4d4;font-size:13px;text-shadow:none;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Courier New&quot;, monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;padding:1em;margin:.5em 0;overflow:auto;background:#1b0f27"><code class="language-js" style="white-space:pre;color:#d4d4d4;font-size:13px;text-shadow:none;font-family:Menlo, Monaco, Consolas, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Courier New&quot;, monospace;direction:ltr;text-align:left;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none"><span class="token" style="color:#569CD6">const</span><span> transactionID </span><span class="token" style="color:#d4d4d4">=</span><span> </span><span class="token" style="color:#b5cea8">123</span><span class="token" style="color:#d4d4d4">-</span><span class="token" style="color:#b5cea8">123</span><span class="token" style="color:#d4d4d4">;</span><span>
</span><span></span><span class="token" style="color:#569CD6">const</span><span> bearerToken </span><span class="token" style="color:#d4d4d4">=</span><span> </span><span class="token" style="color:#ce9178">&#x27;Bearer token from authentication request&#x27;</span><span class="token" style="color:#d4d4d4">;</span><span>
</span>
<span></span><span class="token" style="color:#569CD6">const</span><span> response </span><span class="token" style="color:#d4d4d4">=</span><span> </span><span class="token" style="color:#c586c0">await</span><span> </span><span class="token" style="color:#c0a9e5">axios</span><span class="token" style="color:#d4d4d4">(</span><span>
</span><span>  </span><span class="token" style="color:#d4d4d4">{</span><span>
</span><span>    </span><span class="token literal-property" style="color:#9cdcfe">method</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#ce9178">&#x27;post&#x27;</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token literal-property" style="color:#9cdcfe">url</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token template-string template-punctuation" style="color:#ce9178">`</span><span class="token template-string" style="color:#ce9178">https://api.felloh.com/agent/transactions</span><span class="token template-string" style="color:#569cd6">${</span><span class="token template-string" style="color:#9cdcfe">transactionID</span><span class="token template-string" style="color:#569cd6">}</span><span class="token template-string" style="color:#ce9178">/refund</span><span class="token template-string template-punctuation" style="color:#ce9178">`</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token literal-property" style="color:#9cdcfe">data</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#d4d4d4">{</span><span> amount </span><span class="token" style="color:#d4d4d4">}</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token literal-property" style="color:#9cdcfe">headers</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#d4d4d4">{</span><span>
</span><span>        </span><span class="token string-property" style="color:#9cdcfe">&#x27;Content-Type&#x27;</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token" style="color:#ce9178">&#x27;application/json&#x27;</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>        </span><span class="token literal-property" style="color:#9cdcfe">Authorization</span><span class="token" style="color:#d4d4d4">:</span><span> </span><span class="token template-string template-punctuation" style="color:#ce9178">`</span><span class="token template-string" style="color:#ce9178">Bearer </span><span class="token template-string" style="color:#569cd6">${</span><span class="token template-string" style="color:#9cdcfe">bearerToken</span><span class="token template-string" style="color:#569cd6">}</span><span class="token template-string template-punctuation" style="color:#ce9178">`</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>    </span><span class="token" style="color:#d4d4d4">}</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span>  </span><span class="token" style="color:#d4d4d4">}</span><span class="token" style="color:#d4d4d4">,</span><span>
</span><span></span><span class="token" style="color:#d4d4d4">)</span><span class="token" style="color:#d4d4d4">;</span><span>
</span></code></pre></div>

Bearer tokens will expire after a set period. If a token expires, you will receive a 401 Unauthorized response.

Security Best Practices

  • Keep Tokens Confidential: Do not expose your bearer tokens in publicly accessible areas, such as GitHub repositories or client-side code.
  • Use HTTPS: Always use HTTPS to encrypt API requests and protect sensitive information.
  • Rotate Tokens Regularly: Periodically refresh and rotate your bearer tokens to enhance security.
  • Monitor for Unauthorised Use: Track API usage and revoke tokens if you suspect unauthorized access.