Skip to main content

Overview

The VaultWares API uses API keys for authentication. All API requests must include a valid API key in the request headers. API keys are associated with your organization and can be scoped to specific permissions.

Getting an API key

1

Log in to the portal

Navigate to portal.vaultwares.com and log in with your credentials.
2

Navigate to API settings

Go to Settings > API Keys in the left sidebar.
3

Create new API key

Click Create API Key and provide:
  • Key name (for identification)
  • Permissions (read-only, read-write, admin)
  • Expiration date (optional)
4

Save your key

Copy the API key immediately. It will only be shown once for security reasons.
Store your API key securely. Never commit API keys to version control or share them publicly.

Authentication methods

Include your API key in the X-API-Key header:
curl https://api.vaultwares.com/v1/devices \
  -H "X-API-Key: vw_live_1234567890abcdef"

Bearer token

Alternatively, use the Authorization header with Bearer token:
curl https://api.vaultwares.com/v1/devices \
  -H "Authorization: Bearer vw_live_1234567890abcdef"

API key types

Prefix: vw_live_
  • Used for production environments
  • Access to real data and devices
  • Rate limits apply
  • All operations are permanent
X-API-Key: vw_live_1234567890abcdef

Permissions

API keys can be scoped to specific permissions:
PermissionDescriptionOperations
devices:readView device informationGET /devices, GET /devices/:id
devices:writeManage devicesPOST, PUT, PATCH /devices
devices:deleteDelete devicesDELETE /devices/:id
policies:readView policiesGET /policies
policies:writeManage policiesPOST, PUT, PATCH /policies
users:readView usersGET /users
users:writeManage usersPOST, PUT, PATCH /users
audit:readView audit logsGET /audit
adminFull accessAll operations

Creating scoped API keys

curl https://api.vaultwares.com/v1/api-keys \
  -H "X-API-Key: vw_live_admin_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Monitoring Key",
    "permissions": ["devices:read", "audit:read"],
    "expires_at": "2025-12-31T23:59:59Z"
  }'

OAuth 2.0 (Enterprise)

Enterprise customers can use OAuth 2.0 for user-delegated access.

Authorization code flow

1

Redirect user to authorization URL

https://auth.vaultwares.com/oauth/authorize?
  client_id=your_client_id&
  redirect_uri=https://yourapp.com/callback&
  response_type=code&
  scope=devices:read+devices:write
2

User authorizes application

User logs in and grants permissions to your application.
3

Receive authorization code

VaultWares redirects to your callback URL with an authorization code:
https://yourapp.com/callback?code=AUTH_CODE
4

Exchange code for access token

curl https://auth.vaultwares.com/oauth/token \
  -d grant_type=authorization_code \
  -d code=AUTH_CODE \
  -d client_id=your_client_id \
  -d client_secret=your_client_secret \
  -d redirect_uri=https://yourapp.com/callback
5

Use access token

curl https://api.vaultwares.com/v1/devices \
  -H "Authorization: Bearer ACCESS_TOKEN"

Refresh tokens

Access tokens expire after 1 hour. Use refresh tokens to obtain new access tokens:
curl https://auth.vaultwares.com/oauth/token \
  -d grant_type=refresh_token \
  -d refresh_token=REFRESH_TOKEN \
  -d client_id=your_client_id \
  -d client_secret=your_client_secret

Rate limiting

API requests are rate limited to ensure fair usage and system stability.

Rate limit tiers

TierRequests per minuteRequests per hour
Free601,000
Professional30010,000
Enterprise1,000100,000
CustomNegotiableNegotiable

Rate limit headers

Every API response includes rate limit information:
HTTP/1.1 200 OK
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 987
X-RateLimit-Reset: 1640995200
  • X-RateLimit-Limit: Maximum requests allowed in the current window
  • X-RateLimit-Remaining: Requests remaining in the current window
  • X-RateLimit-Reset: Unix timestamp when the rate limit resets

Handling rate limits

When you exceed the rate limit, you’ll receive a 429 Too Many Requests response:
{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Please retry after 60 seconds.",
    "retry_after": 60
  }
}
Implement exponential backoff in your application:
import time
import requests

def make_request_with_retry(url, headers, max_retries=3):
    for attempt in range(max_retries):
        response = requests.get(url, headers=headers)
        
        if response.status_code == 429:
            retry_after = int(response.headers.get('Retry-After', 60))
            time.sleep(retry_after)
            continue
            
        return response
    
    raise Exception("Max retries exceeded")

Security best practices

Rotate API keys regularly

# Create new API key
NEW_KEY=$(curl https://api.vaultwares.com/v1/api-keys \
  -H "X-API-Key: vw_live_current_key" \
  -d '{"name": "Rotated Key", "permissions": ["admin"]}' \
  | jq -r '.key')

# Update your application to use new key
# ...

# Delete old API key
curl -X DELETE https://api.vaultwares.com/v1/api-keys/old_key_id \
  -H "X-API-Key: $NEW_KEY"

Use environment variables

Never hardcode API keys in your application:
# .env file
VAULTWARES_API_KEY=vw_live_1234567890abcdef
import os
from vaultwares import VaultWaresAPI

api_key = os.environ.get('VAULTWARES_API_KEY')
client = VaultWaresAPI(api_key=api_key)

Restrict by IP address

Limit API key usage to specific IP addresses:
curl https://api.vaultwares.com/v1/api-keys/key_id \
  -X PATCH \
  -H "X-API-Key: vw_live_admin_key" \
  -d '{
    "allowed_ips": ["203.0.113.0/24", "198.51.100.10"]
  }'

Monitor API key usage

# Get API key usage statistics
curl https://api.vaultwares.com/v1/api-keys/key_id/usage \
  -H "X-API-Key: vw_live_admin_key"

# Response:
{
  "key_id": "key_abc123",
  "requests_today": 1247,
  "requests_this_month": 45678,
  "last_used_at": "2024-01-15T14:32:10Z",
  "last_used_ip": "203.0.113.42"
}

Webhook signatures

Verify webhook authenticity using HMAC signatures.

Verify webhook signature

import hmac
import hashlib

def verify_webhook(payload, signature, secret):
    expected_signature = hmac.new(
        secret.encode(),
        payload.encode(),
        hashlib.sha256
    ).hexdigest()
    
    return hmac.compare_digest(signature, expected_signature)

# Usage
webhook_secret = os.environ.get('VAULTWARES_WEBHOOK_SECRET')
payload = request.body
signature = request.headers.get('X-VaultWares-Signature')

if verify_webhook(payload, signature, webhook_secret):
    # Process webhook
    pass
else:
    # Reject webhook
    return 401

Testing authentication

Test API key validity

curl https://api.vaultwares.com/v1/auth/verify \
  -H "X-API-Key: vw_live_1234567890abcdef"

# Response:
{
  "valid": true,
  "key_id": "key_abc123",
  "permissions": ["admin"],
  "organization_id": "org_xyz789",
  "expires_at": null
}

Test OAuth token

curl https://api.vaultwares.com/v1/auth/verify \
  -H "Authorization: Bearer ACCESS_TOKEN"

# Response:
{
  "valid": true,
  "user_id": "user_123",
  "scopes": ["devices:read", "devices:write"],
  "expires_at": "2024-01-15T15:30:00Z"
}

Error responses

Authentication errors

{
  "error": {
    "code": "invalid_api_key",
    "message": "The provided API key is invalid or has been revoked.",
    "type": "authentication_error"
  }
}
Common authentication error codes:
CodeHTTP StatusDescription
invalid_api_key401API key is invalid or revoked
expired_api_key401API key has expired
insufficient_permissions403API key lacks required permissions
ip_not_allowed403Request from unauthorized IP address
rate_limit_exceeded429Too many requests

Next steps