Authentication and routing
Wafeq issues your organization's API key. Its prefix identifies its mode. Send
the complete key in the Authorization header on every API request:
Authorization: Api-Key pk_test_<your-test-key-secret>| Prefix | Mode | Deployment at the shared API address |
|---|---|---|
pk_test_ | test | Staging |
pk_live_ | live | Production |
nbr_sk_ | test | Staging, existing test accounts |
For an enabled live integration, the header is:
Authorization: Api-Key pk_live_<your-live-key-secret>Both modes use https://api.wafeq.com/bh/v1. Test keys, including existing
nbr_sk_ credentials, reach staging; live keys reach production. The deployments
have separate accounts, credentials and invoices. Each verifies the complete
key; its prefix alone never grants access.
Both services currently target NBR sandbox. Live invoice issuance requires
Wafeq to enable and confirm NBR core access separately. Missing, invalid or
wrong-mode credentials return HTTP 401; editing a key's prefix does not make
it valid.
Your existing nbr_sk_ key remains valid and reaches the same staging account
and data through the shared address. No replacement is required. Coordinate any
explicit rotation with Wafeq: it replaces the old key with a pk_test_ key for
the same staging account, and the old credential stops working. Rotation does
not move accounts or invoices between deployments.
Keep the key on your server. Do not embed it in a browser application, mobile app
or public repository.
Check your organization
The examples in these guides use these shell variables. Replace the key before
running them:
BASE=https://api.wafeq.com/bh/v1
KEY=pk_test_replace_with_your_complete_issued_key
curl "$BASE/organizations/me" \
-H "Authorization: Api-Key $KEY"The response identifies your organization and its configured legal details.
api_key_mode reports test or live for the stored key; a legacy pilot key
reports test. Missing, malformed, invalid or wrong-mode credentials return
HTTP 401.
Choose the taxpayer and branch
For device registration, document validation and submission, send the connected
account's ID. A DIRECT account with more than one active branch also needs the
branch header:
X-NBR-Connected-Account-Id: <connected-account-id>
X-NBR-Sub-CR: <branch-sub-cr>For DIRECT accounts, X-NBR-Sub-CR selects the taxpayer's signing device. For
THIRD_PARTY accounts, Wafeq selects the provider organization's active device;
the branch header records the supplier branch and does not select another
provider certificate.
Your key can access only your organization's connected accounts, devices and
documents. Organization profile and provider device endpoints do not need a
connected-account header. List and summary document endpoints can use the
headers to narrow results to one taxpayer or branch.
Updated 26 days ago