Skip to main content
The API uses Bearer token authentication for all requests. This simple and secure method requires you to include your API token in the Authorization header of every request.

Getting Your API Token

Step 1: Access API Settings

Navigate to your Penbox API settings page:

Step 2: Create a New Token

  1. Click the “Create API Token” button
  2. Give your token a descriptive name (e.g., “Production Integration”, “Development”, “Analytics Tool”)
  3. Select the workspace you want to authorize
  4. Copy the generated token immediately
Important: Your API token will only be displayed once. Copy it immediately and store it securely. If you lose it, you’ll need to generate a new token.

Token Format

Your API token will look like this:
Tokens always start with the pnbx_ prefix.

Using Your API Token

Include your API token in the Authorization header of every API request using the Bearer scheme:

Example Requests

Making Authenticated Requests

Every API endpoint requires authentication. Here’s an example creating a form request:

Token Scopes and Permissions

Each API token is associated with a specific workspace. The token will have access to:
  • All forms in the workspace
  • All cases in the workspace
  • All form templates enabled for the workspace
  • All files and attachments in the workspace
  • Document intelligence features for the workspace
Tokens are workspace-specific. If you need to access multiple workspaces, create a separate token for each one.

Token Security

Best Practices

  • Never commit tokens to version control (Git, SVN, etc.)
  • Store tokens in environment variables or secure credential management systems
  • Use secrets management services (AWS Secrets Manager, HashiCorp Vault, etc.)
  • Never expose tokens in client-side code or browser JavaScript
Store your API token in environment variables:
.env
Then load it in your application:
  • Rotate tokens periodically for enhanced security
  • Create a new token before revoking the old one to avoid downtime
  • Update all applications using the old token
  • Revoke the old token once migration is complete
Give your tokens meaningful names to track usage:
  • ✅ “Production API - CRM Integration”
  • ✅ “Development Environment”
  • ✅ “Analytics Dashboard”
  • ❌ “Token 1”, “Test”, “My Token”
  • Track which applications use which tokens
  • Monitor for unexpected API usage patterns
  • Set up alerts for unusual activity
  • Revoke tokens immediately if compromised

What NOT to Do

Never:
  • Commit tokens to Git repositories
  • Share tokens via email, chat, or screenshots
  • Store tokens in plain text files
  • Use the same token across multiple environments
  • Hardcode tokens in your source code
  • Post tokens in public forums or documentation

Managing Tokens

Viewing Active Tokens

Visit app.penbox.io/workspace/settings/api to see all your active API tokens:
  • Token name
  • Creation date
  • Last used date
  • Associated workspace

Revoking Tokens

To revoke a token:
  1. Go to app.penbox.io/workspace/settings/api
  2. Find the token you want to revoke
  3. Click the “Revoke” button
  4. Confirm the action
Once revoked, a token is immediately invalidated. All API requests using that token will fail with a 401 Unauthorized error.

Token Lifecycle

Authentication Errors

Common Error Responses

401 Unauthorized - Missing Token

Cause: The Authorization header is missing from your request. Solution: Add the Authorization header with your Bearer token.

401 Unauthorized - Invalid Token

Cause: The token is invalid, expired, or has been revoked. Solution: Check your token is correct, or create a new token if it was revoked.

403 Forbidden - No Access

Cause: Your token doesn’t have access to the requested resource (e.g., wrong workspace). Solution: Verify you’re using the correct token for the workspace you’re trying to access.

Debugging Authentication Issues

If you’re experiencing authentication issues:
  1. Verify the token format
    • Token should start with pnbx_
    • No extra spaces or newlines
    • Complete token copied
  2. Check the Authorization header
    • Includes “Bearer ” prefix with a space
    • Token immediately after the space
  3. Verify token is active
  4. Test with cURL
    The -v flag shows detailed request/response information.

Rate Limiting

API tokens are subject to rate limiting to ensure fair usage and system stability.

Rate Limit Exceeded

If you exceed the rate limit, you’ll receive a 429 Too Many Requests response:

Best Practices for Rate Limiting

  • Cache responses when possible
  • Implement exponential backoff on errors
  • Monitor your usage patterns
  • Spread requests over time instead of bursting
  • Use webhooks instead of polling when possible

Testing Your Authentication

Quick Test

Test your token with a simple request to list workspaces:
Expected response (success):
Error response (invalid token):

Integration Checklist

Before deploying to production:
  • Token stored securely (environment variable or secrets manager)
  • Authorization header correctly formatted
  • Error handling implemented for 401/403 responses
  • Rate limiting handled with backoff strategy
  • Token name clearly identifies the integration
  • Monitoring/logging in place for API usage
  • Token rotation plan documented

Multiple Environments

For different environments, create separate tokens:

Development

Staging

Production

Then load the appropriate token based on your environment:

Next Steps

Create Forms

Learn how to create forms

List Workspaces

Retrieve your authorized workspaces

API Overview

Complete API capabilities guide

All Endpoints

Browse all available endpoints

Support

If you encounter issues with authentication:
  1. Check this documentation for troubleshooting steps
  2. Verify your token at app.penbox.io/workspace/settings/api
  3. Test with the cURL examples above
  4. Contact support at support@penbox.io with:
    • Token name (never send the actual token)
    • Error messages received
    • API endpoint being called
    • Request timestamp