Bahrain e-invoicing API

Submit invoice data to Wafeq to create, sign, validate and send Bahrain e-invoices
to the National Bureau for Revenue (NBR). Your integration supplies the business
transaction. Wafeq generates the UBL XML, calculates totals and VAT, adds the
cryptographic stamp and QR code, and requests clearance or reporting.

API address

https://api.wafeq.com/bh/v1

All reference paths are relative to this address. For example, POST /invoices
means POST https://api.wafeq.com/bh/v1/invoices.

Wafeq issues your API key. A pk_test_ key identifies test use against NBR
sandbox; a pk_live_ key identifies live use against NBR core. Wafeq enables
Live access for each organization; integrate with a test key first. See
authentication for mode checks and existing
pilot keys.

Connected accounts and devices

NBR asks two separate questions about every document, and each has its own
object in this API:

QuestionObjectWhat it holds
Who is selling?Connected accountA taxpayer's legal name, VAT number and address. They become the seller on the invoice.
Which software signed it?DeviceAn NBR certificate and private key. NBR issues the certificate to registered invoicing software, not to a company.

A device is not a physical terminal. It is an e-invoicing software instance
that NBR has certified, and Wafeq runs it for you. Its credentials never
leave Wafeq's servers.

Your organization, which your API key identifies, owns both kinds of object.

Organization (your API key)
├── Provider device              (THIRD_PARTY only: one for the whole organization)
└── Connected account            (one per taxpayer VAT registration)
    ├── Device per branch        (DIRECT only: one per sub-CR)
    └── Documents

A sub-CR is a branch's commercial registration number, for example 136690-1.

Whose device signs: DIRECT or THIRD_PARTY

Each connected account has an invoicing mode, which decides whose device
signs its documents. The seller is the connected account in both modes.

DIRECTTHIRD_PARTY
Use it whenThe taxpayer invoices for itself, for example your own company or a customer who gives you its NBR OTP.You invoice on behalf of suppliers who have authorized you, and they do not register their own software with NBR.
DeviceThe taxpayer's own, one per branch (sub-CR).Your organization's single provider device, shared by all of these suppliers.
OTPThe taxpayer's OTP, one per device.Your OTP, once, for the provider device. The suppliers need none.
On the invoiceThe connected account is the seller.The connected account is the seller, and your organization appears as the third-party agent.

One organization can have both kinds of account. For example, it can invoice for
itself through a DIRECT account and for its partners through THIRD_PARTY accounts.
The mode is fixed when the account is created.

What the OTP is for

The OTP is a one-time code that the device's owner generates in the NBR
e-invoicing portal: the taxpayer for a DIRECT device, or your organization for
the provider device. It authorizes one device registration: Wafeq exchanges it for the
device's first NBR certificate. You need a fresh OTP each time you register or
renew a device. Creating a connected account does not need one, but
POST /connected-accounts can register the account's first DIRECT device in
the same call if you pass an OTP.

Build your integration

  1. Authenticate and identify your organization.
  2. Set up signing:
  3. Validate and submit a document with the
    X-NBR-Connected-Account-Id header for the seller.
  4. Read the result and download the document.
  5. Handle errors and retries.
  6. Receive webhooks when documents and devices change.

The API reference describes the complete request and response
schemas. Tools can import the
OpenAPI schema or read the
AI integration guide.