GET /api/v1/account/billing • HTTP 200 OK

Bearer Token JWT Authentication API Example — Request & Response Example

The standard industry pattern for securing REST APIs. The client passes a cryptographically signed JSON Web Token (JWT) in the Authorization header to verify identity.

1. HTTP Client Request (GET)

GET /api/v1/account/billing HTTP/1.1
{
  "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c3JfNDIxIiwiZXhwIjoxNzg5MTIzNDU2fQ.demoSignatureKey",
  "Accept": "application/json"
}

2. Server JSON Response (HTTP 200 OK)

{
  "account_id": "acct_enterprise_88",
  "plan": "Growth Pro",
  "status": "active",
  "current_cycle_spend_usd": 480,
  "next_invoice_date": "2026-11-01",
  "payment_method": {
    "brand": "Visa",
    "last4": "4242"
  }
}

Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)

curl -X GET "https://cometflow.space/api/v1/account/billing" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Accept: application/json"
const token = 'YOUR_JWT_TOKEN';

fetch('https://cometflow.space/api/v1/account/billing', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
  .then(res => res.json())
  .then(data => console.log(data));
import requests

headers = {
    "Authorization": "Bearer YOUR_JWT_TOKEN",
    "Accept": "application/json"
}

res = requests.get("https://cometflow.space/api/v1/account/billing", headers=headers)
print(res.json())

How This API Call Works Step-by-Step

  1. 1. Client Login: Earlier, the client submitted login credentials and received a signed JWT.
  2. 2. Authorization Header: Client includes "Authorization: Bearer <token>" in every subsequent request.
  3. 3. Token Verification: The server decrypts and verifies the signature using a secret key without querying the DB.
  4. 4. Authorized Data Return: If valid and not expired, the protected billing record is returned.

Backend API Functions: An auth middleware function verifyJwt(req, res, next) intercepts the request, checks req.headers.authorization, parses the Bearer string, validates the cryptographic signature, attaches req.user, and calls next().

Frequently Asked Questions

What happens if the Bearer token is expired or invalid?

The API rejects the request immediately with an HTTP 401 Unauthorized status code and a JSON response like {"error": "Token expired"}.