What the FBR sandbox is
FBR’s technical documentation for Digital Invoicing (version 1.12, issued by PRAL) describes two sets of web addresses for sending invoice data: a sandbox for testing and a production address for real invoices. The sandbox address for posting an invoice ends in “_sb”, and the production one does not.
The document also says the access token you are given decides how requests are routed, so the same address pattern can serve sandbox and production. In practice, the token and the address FBR gives your business tell your software which system it is talking to.
This guide summarises a public FBR document in plain words. It is general information, not legal or tax advice, and FBR can update the document. Read FBR’s technical documentation for Digital Invoicing for the exact wording. Billora is an independent private product and is not affiliated with or endorsed by FBR.
What to prepare before you test
- The security token. FBR’s document says every request carries a security token issued by PRAL in the Authorization header, with the word “Bearer” in front. The token is valid for 5 years, and a new one is requested when it expires.
- Seller details. Your NTN or CNIC, business name, province and address, as registered.
- Clean product and customer records. HS codes, units of measure, tax rates, buyer names, registration types and provinces. Most test failures come from data that does not match FBR’s reference lists. See product master data for clean invoices.
- Your scenario list. The scenarios for your business activity and sector. See FBR Digital Invoicing scenarios explained and scenarios by business type and sector.
FBR also publishes reference lists for provinces, document types, item codes, transaction types, units of measure, SRO schedules, rates and HS codes with their units. Your software should take its values from these lists.
Sandbox testing step by step
- List the scenarios that match what you actually sell, using FBR’s “Applicable Scenarios based on Business Activity” table.
- For each scenario, build a sample invoice that looks like a real one: seller, buyer, items, rates and amounts.
- Put the scenario ID, for example SN001, in the invoice. In FBR’s sample data this field is marked “Required for Sandbox only”.
- Optionally check the invoice data first with FBR’s validate method, which has its own sandbox address.
- Post the invoice to the sandbox address and read the response. A valid invoice returns an invoice number and status code 00.
- If the response is invalid (status code 01), read the error code and message, fix the data and send it again. See FBR Digital Invoicing error codes explained.
- Repeat for each scenario on your list until each one passes.
How to read the sandbox response
The response has a date, an invoice number when the invoice is valid, and a validation block with a status code (00 for valid, 01 for invalid), a status, and an error message when something is wrong. Each item on the invoice also has its own status, so one bad line can fail the invoice.
FBR’s document shows two kinds of invalid response. In one, the whole invoice is rejected with an error code, for example 0052 when the HS code does not suit the sale type. In the other, the invoice-level status is 00 but an individual item carries status 01 and an error code, for example 0046 when the rate is missing.
The document lists three HTTP status codes: 200 for OK, 401 for unauthorised and 500 for an internal server error, for which you contact the administrator.
Do I have to clear every scenario?
FBR’s document lists the scenarios that apply to each business activity and sector. It does not spell out a pass mark or a sign-off procedure for sandbox testing. What FBR or PRAL expects before they treat your testing as complete is set by them, so confirm it with PRAL or your tax adviser.
A sensible way to work is to test every scenario that matches your real sales, keep the responses for each passing invoice, and add a test for any unusual case you sell, such as a reduced rate, an exempt item or a service.
Moving from sandbox to production
Once your tests pass, your software moves to the production address. FBR’s production sample data has no scenario ID, because that field is for the sandbox only. Everything else about the invoice, such as the seller and buyer, the items and the sale type, stays the same.
From then on, an invoice that is accepted gets a real FBR invoice number, which must be printed with the Digital Invoicing logo and QR code. See FBR Digital Invoice format, invoice number and QR code.
How Billora handles sandbox testing
Billora is business software with integrated FBR Digital Invoicing. The Billora team collects your details, configures the integration and runs sandbox testing with you, using test invoices that cover your real cases, and then moves your company to live mode. Tell the team early about anything unusual you sell so those cases are in the test plan.
See the FBR integration checklist for what to prepare, FBR Digital Invoicing in Billora for how the feature works, and the FBR Digital Invoicing guide for the overall process.