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/v1All 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:
| Question | Object | What it holds |
|---|---|---|
| Who is selling? | Connected account | A taxpayer's legal name, VAT number and address. They become the seller on the invoice. |
| Which software signed it? | Device | An 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)
└── DocumentsA 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.
| DIRECT | THIRD_PARTY | |
|---|---|---|
| Use it when | The 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. |
| Device | The taxpayer's own, one per branch (sub-CR). | Your organization's single provider device, shared by all of these suppliers. |
| OTP | The taxpayer's OTP, one per device. | Your OTP, once, for the provider device. The suppliers need none. |
| On the invoice | The 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
- Authenticate and identify your organization.
- Set up signing:
- DIRECT: create the connected account with the
taxpayer's OTP andsub_cr. That call also registers its device. You can instead
register the device separately. - THIRD_PARTY: complete your identity with
PATCH /organizations/me, register the
provider device once, then
create each supplier with
{"onboarding": {"mode": "THIRD_PARTY"}}. No supplier OTP or device is needed.
- DIRECT: create the connected account with the
- Validate and submit a document with the
X-NBR-Connected-Account-Idheader for the seller. - Read the result and download the document.
- Handle errors and retries.
- 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.
Updated 10 days ago