For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inBook a demo
HomeGuidesAPI ReferenceGlossary
HomeGuidesAPI ReferenceGlossary
  • Home
    • Overview
      • Step 1: API Keys and Concepts
      • Step 2: Backend Integration
      • Step 3: Frontend Integration
    • Testing and Errors
Logo
Sign inBook a demo
On this page
  • Steps to generate a token
  • Creating a Token
  • Using the Token
HomeGetting Started

Step 2: Backend Integration

Was this page helpful?
Previous

Step 3: Frontend Integration

Next
Built with

If you are using Mercoa for just payments check out our Creating Payouts via API guide.

Mercoa has a fully documented REST API that can be used in any language. We also have Node, Python, Java, and Go SDKs for easy backend integration.

At Mercoa, we aim to provide a seamless and whitelabeled experience for your users. As part of this experience, Mercoa does not force users to create a new account or log in to a different system.

Instead, Mercoa uses JWT tokens that you can generate to transparently authenticate the user session on the frontend.

Steps to generate a token

  1. User logs into your platform
  2. Find the Mercoa Entity that corresponds to that user’s business.
  3. Optional: Sync individual users and their roles. This is required for Approvals.
  4. Generate a JWT and pass it to the frontend.
  5. Use the JWT with our frontend SDK, React Components, or embedded iFrame.

Creating a Token

Let’s create an endpoint that authenticates the user, generates a JWT with the entityId, and return the generated token. We will use Mercoa’s Generate JWT Token endpoint to make this easy.

1from django.http import HttpResponse
2from mercoa.client import Mercoa
3
4client = Mercoa(token="YOUR_API_KEY")
5
6def generate_mercoa_token(request):
7 client.entity.get_token(entity_id="ENTITY_ID_FROM_STEP_ONE",{})
8 return HttpResponse(token)

Using the Token

Now that we have a token, we can use it to authenticate the user in our frontend application. Tokens have a default expiration of 1 hour, but you can change this by passing in the expiresIn option when generating the token.