Skip to content

Authentication

WalletHero API supports two authentication methods: API tokens for server-to-server communication and session tokens for user-based access.

API tokens are long-lived tokens ideal for server-side integrations.

Obtaining an API Token

  1. Log in to your WalletHero account
  2. Navigate to Settings > API Token
  3. Click "Generate Token"
  4. Copy and securely store the token (it won't be shown again)

Or via API after logging in:

bash
curl -X POST https://api.wallethero.app/wallethero-api/user/api-token/regenerate \
  -H "Authorization: Bearer your-session-token"

Response:

json
{
  "message": "API token regenerated successfully",
  "token": "abc123def456..."
}

Using the API Token

Include the token in the Authorization header:

bash
curl https://api.wallethero.app/wallethero-api/workspace/WORKSPACE_ID/pass-templates \
  -H "Authorization: Bearer your-api-token"

SDK Usage

typescript
import { WalletHero } from '@wallethero/sdk';

const client = new WalletHero({
  apiToken: 'your-api-token'
});

Session Token Authentication

Session tokens are obtained through the login flow and are used for user-based access.

Login Flow

bash
curl -X POST https://api.wallethero.app/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "your-password"
  }'

Response:

json
{
  "data": {
    "access_token": "eyJhbGciOiJIUzI1NiIs...",
    "refresh_token": "abc123...",
    "expires": 900000
  }
}

Refreshing Tokens

bash
curl -X POST https://api.wallethero.app/auth/refresh \
  -H "Content-Type: application/json" \
  -d '{
    "refresh_token": "abc123..."
  }'

Logout

bash
curl -X POST https://api.wallethero.app/auth/logout \
  -H "Content-Type: application/json" \
  -d '{
    "refresh_token": "abc123..."
  }'

Note: /auth/login, /auth/refresh, and /auth/logout are native Directus endpoints and are not under the /wallethero-api prefix.

Token Management

Check if API Token Exists

bash
curl https://api.wallethero.app/wallethero-api/user/api-token \
  -H "Authorization: Bearer your-session-token"

Response:

json
{
  "has_token": true
}

Revoke API Token

bash
curl -X DELETE https://api.wallethero.app/wallethero-api/user/api-token \
  -H "Authorization: Bearer your-session-token"

Response:

json
{
  "message": "API token revoked successfully"
}

Security Best Practices

  1. Never expose tokens in client-side code - API tokens should only be used server-side
  2. Rotate tokens periodically - Regenerate API tokens every 90 days
  3. Use environment variables - Store tokens in environment variables, not in code
  4. Monitor token usage - Check for unusual API activity regularly
  5. Revoke compromised tokens immediately - If a token is exposed, regenerate it right away

Error Codes

CodeStatusDescription
INVALID_TOKEN401The provided token is invalid or expired
TOKEN_EXPIRED401The session token has expired
FORBIDDEN403Token doesn't have permission for this operation
RATE_LIMITED429Too many requests, please slow down

WalletHero Documentation