Ledger Enterprise
API Documentation V2
API Documentation V2
  • Introduction
    • Getting Started
    • Overview
  • Guides
    • Authentication
    • Balance Reporting Bot
      • 1. Project setup
      • 2. Connect to revault-api
      • 3. Fetch accounts balances
      • 4. Conclusion
  • reference
    • API reference
      • Users
      • Accounts
        • Transactions
      • Groups
      • Whitelists
      • Policies
      • Entities
      • Requests
        • Generate registration challenge
        • Confirm registration challenge
        • Challenge
        • Approve
        • Reject
      • Auth
        • Token
          • Refresh
      • Permissions
        • Allowed actions
        • Resources
      • Assets
        • Currencies
        • Tokens
      • Tradelink
        • Network
          • Blueprint
    • Specification
Powered by GitBook
On this page
  • Create API operator ​
  • Request a JWT ​
  • Use the JWT in headers ​
  • Refresh the JWT ​
  1. Guides

Authentication

PreviousOverviewNextBalance Reporting Bot

In order to access and interact with our API endpoints, authentication is required using the JSON Web Token () standard.

This page will guide you through the process of obtaining and attaching the JWT token to your requests' headers. The JWT token serves as a secure and efficient way to verify the identity of the user and authorize access to protected resources.

By following the instructions provided here, you will be able to successfully authenticate your requests and ensure the security of your interactions with our API. Let's dive in and explore the details of the authentication process.

Create API operator ​

Follow the to create API operator, and save the generated credentials:

  • API Key ID

  • API Key secret

Request a JWT ​

You can exchange API Key ID + API Key secret for a valid on the target workspace:

bash

curl $API_BASE_URL/auth/token \
  -H "Content-Type: application/json" \
  -X POST --data '{
    "workspace": "<workspace>",
    "apiKeyId": "<api-key-id>",
    "apiKeySecret": "<api-key-secret>"
  }'

Response will look like:

json

{
  "accessToken": "eyJhbGci...ZDi022eQ",
  "expiresInSeconds": 300,
  "refreshToken": "eyJhbGci...zj9YL6Ow",
  "refreshExpiresInSeconds": 1800
}

The accessToken key contains the JWT.

Use the JWT in headers ​

Attach the JWT to requests like this:

bash

JWT="eyJhbGci...ZDi022eQ"
curl -H "Authorization: Bearer $JWT" $API_BASE_URL/users/me

Refresh the JWT ​

You can obtain new JWT without exchanging API credentials again and rather just exchanging refreshToken :

bash

curl $API_BASE_URL/auth/token/refresh \
  -H "Content-Type: application/json" \
  -X POST --data '{
    "workspace": "<workspace>",
    "refreshToken": "eyJhbGci...zj9YL6Ow",
  }'

The response will have exactly same structure as the /auth/token response (see ).

JWT ↗
official documentation ↗
JWT ↗
Request a JWT