powerVFD Docs

PowerVFD API

Issue TRA-fiscalised receipts from your own software. You send an invoice; PowerVFD validates it, gives it a receipt number, Z number and verification code, and submits it to TRA.

The PowerVFD web dashboard and mobile app issue receipts through this same endpoint, so a POS, an ERP, Tally or any custom system gets exactly the same behaviour. These docs describe how the server behaves today, quirks included.

How a request is processed

  1. Licence check. Every device referenced in the request must hold a valid PowerVFD licence. If one doesn't, the request stops with 402 before anything else is looked at. See Device licence check.
  2. Interface and invoice checks. The fcode and fcodetoken in the body must match an authorised interface, and every invoice must pass the validation rules. Any failure returns an error and nothing is written.
  3. Receipt issued. The invoice is saved with its receipt number, Z number and verification code, and those come back in the response.
  4. Sent to TRA. PowerVFD submits the receipt to TRA. If TRA can't be reached, the invoice stays pending and is sent later.

What you need

  • A PowerVFD server your system can reach. Its address is the base URL for every request. Set it in the sidebar and the code samples on this site will use it.
  • Interface credentials: an fcode and fcodetoken for your system. See Authentication.
  • A device number such as DV03 for the TRA registration you're issuing against, unless the server has a default device.

Conventions

TopicRule
FormatJSON request and response bodies. Send Content-Type: application/json.
AmountsTanzanian shillings, VAT-inclusive, sent as numbers such as 5000.00.
Dates and timesidate as YYYY-MM-DD, itime as 24-hour HH:MM:SS.
Codestaxcode, custidtype and paytype are accepted as numbers or numeric strings: 1 and "1" are the same.
ErrorsAlways { status, message, statusCode }, with statusCode matching the HTTP status.

Quickstart

Send one invoice and read back the receipt details.

1. Point the samples at your server

Enter the address of your PowerVFD server. It's saved in this browser only, and every code sample on the site uses it.

Include the scheme, and the port if your server uses one, for example http://192.168.1.20:<port>. API paths start with /service/v1.

2. Get interface credentials

An interface is one system that's allowed to submit invoices. Each interface has two values:

FieldWhat it is
fcodeThe interface code, for example F-9CJ21A.
fcodetokenThe interface's secret token, issued together with the code.

For a POS, ERP or Tally, an administrator configures the interface in the PowerVFD web dashboard. The mobile app claims its own interface by scanning the interface's QR code.

The token is the only thing that authenticates an invoice. Keep it on your server, never in browser code or anywhere a customer can read it.

3. Find your device number

Each VFD registration with TRA is a device in PowerVFD, with a number like DV03. The invoice is fiscalised against that device's TIN and certificate. Send it as devicenumber. You can leave it out only if the server has a default device configured.

4. Send the invoice

This sends a cash sale to a walk-in customer (custidtype 6, no ID). The samples fill in today's date and the current time, because future dates are always rejected and past dates usually are.

curl -X POST "{{BASE_URL}}/service/v1/invoices" \
  -H "Content-Type: application/json" \
  -d '{
    "invoice": [
      {
        "idate": "{{TODAY}}",
        "itime": "{{NOW}}",
        "custinvoiceno": "INV-{{TODAY_COMPACT}}-0001",
        "custidtype": 6,
        "devicenumber": "DV03",
        "paytype": 1,
        "fcode": "F-9CJ21A",
        "fcodetoken": "YOUR_FCODETOKEN",
        "invoiceDetails": [
          { "description": "20L Drinking Water", "qty": 2, "taxcode": 1, "amt": 5000.00 }
        ]
      }
    ]
  }'
// Node.js 18+ (built-in fetch)
const res = await fetch("{{BASE_URL}}/service/v1/invoices", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    invoice: [
      {
        idate: "{{TODAY}}",
        itime: "{{NOW}}",
        custinvoiceno: "INV-{{TODAY_COMPACT}}-0001",
        custidtype: 6,
        devicenumber: "DV03",
        paytype: 1,
        fcode: "F-9CJ21A",
        fcodetoken: process.env.POWERVFD_TOKEN,
        invoiceDetails: [
          { description: "20L Drinking Water", qty: 2, taxcode: 1, amt: 5000.0 },
        ],
      },
    ],
  }),
});

const data = await res.json();
if (data.status !== "success") {
  throw new Error(`${data.statusCode}: ${data.message}`);
}
console.log(data.vfdinvoicenum, data.rctvcode, data.rctvnum);
<?php
$payload = [
    'invoice' => [[
        'idate'          => '{{TODAY}}',
        'itime'          => '{{NOW}}',
        'custinvoiceno'  => 'INV-{{TODAY_COMPACT}}-0001',
        'custidtype'     => 6,
        'devicenumber'   => 'DV03',
        'paytype'        => 1,
        'fcode'          => 'F-9CJ21A',
        'fcodetoken'     => getenv('POWERVFD_TOKEN'),
        'invoiceDetails' => [
            ['description' => '20L Drinking Water', 'qty' => 2, 'taxcode' => 1, 'amt' => 5000.00],
        ],
    ]],
];

$ch = curl_init('{{BASE_URL}}/service/v1/invoices');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode($payload),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 30,
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);

if (($data['status'] ?? '') !== 'success') {
    throw new RuntimeException($data['statusCode'] . ': ' . $data['message']);
}
echo $data['vfdinvoicenum'], ' ', $data['rctvcode'], PHP_EOL;
import os
import requests

payload = {
    "invoice": [
        {
            "idate": "{{TODAY}}",
            "itime": "{{NOW}}",
            "custinvoiceno": "INV-{{TODAY_COMPACT}}-0001",
            "custidtype": 6,
            "devicenumber": "DV03",
            "paytype": 1,
            "fcode": "F-9CJ21A",
            "fcodetoken": os.environ["POWERVFD_TOKEN"],
            "invoiceDetails": [
                {"description": "20L Drinking Water", "qty": 2, "taxcode": 1, "amt": 5000.00}
            ],
        }
    ]
}

r = requests.post("{{BASE_URL}}/service/v1/invoices", json=payload, timeout=30)
data = r.json()
if data["status"] != "success":
    raise RuntimeError(f'{data["statusCode"]}: {data["message"]}')
print(data["vfdinvoicenum"], data["rctvcode"], data["rctvnum"])

5. Read the response

A successful call returns 200:

{
  "status": "success",
  "message": "Success",
  "rctvnum": "https://verify.tra.go.tz/12345678_143200",
  "rctvcode": "12345678",
  "znumber": "{{TODAY_COMPACT}}",
  "custinvoiceno": "INV-{{TODAY_COMPACT}}-0001",
  "vfdinvoicenum": "0000123",
  "idate": "{{TODAY}}",
  "itime": "{{NOW}}",
  "senttime": "{{NOW}}",
  "qrpath": "",
  "qrcode_uri": ""
}

Store vfdinvoicenum, znumber, rctvcode and rctvnum against your own invoice and print them on the receipt. rctvnum is the TRA verification URL that the receipt's QR code encodes. Every field is described in Responses.

6. Handle errors

Errors share one envelope, { "status": "error", "message": "…", "statusCode": 400 }. The status tells you what kind of problem it is:

StatusMeaning
400Something in the invoice failed validation. Fix the request; don't resend it unchanged.
402The device can't fiscalise right now because of a licence problem. The invoice itself is fine.
403The user named in username isn't allowed to create invoices.
404The interface credentials weren't accepted.
500Unexpected server error. Safe to retry with the same custinvoiceno.

Every message is listed in Errors, and Retries and duplicates covers what to resend.

Authentication

The invoice endpoint is authenticated by credentials inside the request body, not by a header.

Other PowerVFD routes require a signed-in user's access token. Invoice submission deliberately doesn't. Instead it checks the fcode and fcodetoken in the body against the interfaces registered in PowerVFD. That's what lets a POS, Tally or another system submit invoices without ever logging in as a dashboard user.

Interface credentials

FieldWhere it comes from
fcodeThe interface code. Claimed by scanning the interface's QR code (mobile app) or configured in the dashboard (web and integrations).
fcodetokenThe interface's secret token, issued with the fcode when the interface is claimed. This is the actual authentication for the endpoint.

Send both in each invoice object:

{
  "invoice": [
    {
      "fcode": "F-9CJ21A",
      "fcodetoken": "a1b2c3d4e5f6...",
      "...": "..."
    }
  ]
}

Headers

HeaderRequiredValue
Content-TypeYesapplication/json

No Authorization header or JWT is required.

Device licence check

Before the credentials are even looked at, PowerVFD checks the licence of every device referenced in the request. If a licence is missing, expired, revoked or tied to another machine, the request is rejected with 402. Nothing about the invoice is wrong in that case: the device just can't fiscalise right now.

An expired licence gets one automatic online renewal attempt first. You only see the 402 if that renewal fails or the licence server can't be reached. The messages are listed under Errors.

When credentials are rejected

If the fcode and fcodetoken don't match an authorised interface, the response is:

{
  "status": "error",
  "message": "Interface: This request is not authorized to access the system, please contact system Administrator to authorize",
  "statusCode": 404
}

This is a 404, not a 403. It comes back as HTTP 404 with statusCode: 404 even though it's an authorisation failure. That's how the server behaves today. Treat a 404 from this endpoint as "credentials not accepted".

Keeping credentials safe

  • Submit from your server or back office, not from browser JavaScript, where anyone can read the token.
  • Give each system its own interface. If one is retired or exposed, an administrator can switch it off without affecting the others.
  • Keep full request bodies out of shared logs. They contain the token.

Submit invoices

POST/service/v1/invoices
POST/service/v1/invoices/tallySame handler, wrapped for Tally XML integrations

Creates one or more invoices, issues their receipts and returns the verification details. The web dashboard, the mobile app and third-party integrations all use it.

Headers

HeaderRequiredValue
Content-TypeYesapplication/json

Authentication travels in the body as fcode and fcodetoken. See Authentication.

Example request

{
  "invoice": [
    {
      "idate": "2026-09-05",
      "itime": "14:32:00",
      "custinvoiceno": "INV-20260905-0001",
      "custidtype": "1",
      "custid": "123456789",
      "custname": "ACME TRADING CO LTD",
      "mobilenum": "255712345678",
      "custemail": "billing@acme.co.tz",
      "username": "shakil",
      "devicenumber": "DV03",
      "branch": "HQ",
      "department": "Sales",
      "paytype": "1",
      "fcode": "F-9CJ21A",
      "fcodetoken": "a1b2c3d4e5f6...",
      "discount": 0,
      "invoiceDetails": [
        { "description": "20L Drinking Water", "qty": "2", "taxcode": "1", "amt": 5000.00 },
        { "description": "Bottled Soda 500ml", "qty": "6", "taxcode": "1", "amt": 3000.00 }
      ]
    }
  ]
}

invoice is always an array. The same shape submits one invoice or a batch, with one device and customer per entry. The mobile app always sends a single-element array; the dashboard uses batches for imported and migrated invoices. See Batch submission.

Invoice fields

FieldTypeRequiredDescription
idatestring
YYYY-MM-DD
YesInvoice date, as a strict YYYY-MM-DD date. Future dates are always rejected. Past dates are rejected unless the device's timeserver setting is lastinv, and even then only if no later-dated invoice already exists for that device.
itimestring
HH:MM:SS
YesInvoice time in 24-hour format.
custinvoicenostringRecommendedYour own invoice or reference number. If present, it must be unique per device across every send status, so resubmitting a number that was already sent is rejected as a duplicate. Required when paytype is 5.
custidtypenumber 1–6YesCustomer ID type. See Customer ID types.
custidstringUnless custidtype is 6Customer ID. For a TIN (type 1), spaces and dashes are stripped before the 9-digit check. For type 6 it must be omitted, empty or "null"; sending a value is a validation error.
custnamestringNoCustomer name. Checked against the special-characters blocklist.
mobilenumstringNoCustomer mobile number. Cleaned and normalised by the server.
custemailstringNoCustomer email address.
usernamestringNoThe cashier. When present, that user's per-invoice and per-day limits and approval rules are applied. See Cashier limits.
devicenumberstringYes*The device (TRA registration) to fiscalise against, for example DV03. *Can be omitted only if a default device is configured.
branchstringNoBranch name. If omitted, the device's default branch is used. A name with no matching branch returns 400.
departmentstringNoDepartment name. If omitted, the branch's default department is used. A name with no matching department returns 400.
paytypenumber 1–5YesPayment type. See Payment types.
fcodestringYesInterface code. See Authentication.
fcodetokenstringYesInterface secret token. This is what authenticates the request.
discountnumberNoMust be numeric if present. Defaults to 0.
invoiceDetailsarrayYesLine items. At least one is required. See below.

Line item fields

Each entry in invoiceDetails[]:

FieldTypeRequiredDescription
descriptionstringYesItem description. Checked against the special-characters blocklist.
qtynumberYesQuantity. Must be numeric; numeric strings are accepted.
taxcodenumber 1–5YesVAT category. See Tax codes.
amtnumberYesLine total including VAT. Must be numeric, not negative and not empty. Don't split net and tax yourself; the server does it from taxcode.
prodidnumberNoLinks the line to a product. Required, with qty capped at 1, when the device has unique item mode on. A product already marked sold can't be sold again.

Transactions

The whole request runs in a single database transaction. If any invoice in the array fails validation, the entire batch is rolled back and none of it is saved. The response shape for one invoice and for several is described in Responses.

The Tally route

/service/v1/invoices/tally runs the same handler, wrapped for Tally XML integrations. The fields, validation, responses and errors on this site apply to it unchanged. See Tally integration.

Responses

A success returns the receipt's verification details. An error returns one consistent envelope.

Success: one invoice

{
  "status": "success",
  "message": "Success",
  "rctvnum": "https://verify.tra.go.tz/12345678_143200",
  "rctvcode": "12345678",
  "znumber": "20260905",
  "custinvoiceno": "INV-20260905-0001",
  "vfdinvoicenum": "0000123",
  "idate": "2026-09-05",
  "itime": "14:32:00",
  "senttime": "14:32:00",
  "qrpath": "/qrstore/12345678.jpg",
  "qrcode_uri": "data:image/jpeg;base64,..."
}
FieldDescription
status"success".
message"Success" for one invoice.
rctvnumThe full TRA receipt-verification URL. This is what the printed QR code encodes.
rctvcodeThe receipt verification code: the device's receipt code plus its fiscal global counter (gc).
znumberThe Z report date/number this invoice was rolled into.
custinvoicenoYour invoice number, echoed back.
vfdinvoicenumThe TRA-assigned running receipt number (rctnum).
idate, itimeThe invoice date and time as stored.
senttimeThe time recorded with the submission.
qrpathServer path of the generated QR image. Filled only when the device's generate_qrcode setting is on; otherwise an empty string.
qrcode_uriThe QR image as a data URI, ready to embed. Same condition as qrpath.

Success: several invoices

When the array holds more than one invoice, each result is wrapped inside invoices instead of being spread onto the top level. Each entry has the same fields as a single result.

{
  "status": "success",
  "message": "All invoices processed successfully",
  "invoices": [
    { "rctvnum": "...", "rctvcode": "...", "znumber": "...", "custinvoiceno": "INV-001", "...": "..." },
    { "rctvnum": "...", "rctvcode": "...", "znumber": "...", "custinvoiceno": "INV-002", "...": "..." }
  ]
}

Match results to your invoices by custinvoiceno, which is a good reason to always send one.

Error envelope

{ "status": "error", "message": "<human-readable reason>", "statusCode": 400 }

statusCode in the body always matches the HTTP status. Note that an unauthorised interface returns 404. Every message is listed in Errors.

Putting it on the receipt

PowerVFD's own receipts print these values. If you print receipts from your system, show the same:

Receipt lineField
RECEIPT NOvfdinvoicenum
Z NUMBERznumber
RECEIPT VERIFICATION CODErctvcode
QR codeEncode rctvnum, or embed qrcode_uri when it's provided.

Errors

Every error uses the same envelope. Filter by status, or type part of the message you received.

{ "status": "error", "message": "<human-readable reason>", "statusCode": <number> }

Status codes

StatusKindWhat it means
400ValidationRaised before anything is written. Something in the request is wrong; fix it before resending.
402Licence / deviceRaised by the licence check before the invoice is read. The invoice is fine; the device can't fiscalise right now.
403AccessThe user in username isn't allowed to create invoices.
404InterfaceThe fcode / fcodetoken pair isn't authorised. An authorisation error, returned as 404.
500ServerAn unexpected failure, such as a lost database connection. Not a validation issue.

Messages

Values such as DV03, shakil, dates, amounts and invoice numbers in these messages are examples; yours will differ.

StatusMessageCause and fix
400Date is requiredidate is missing. Send it as YYYY-MM-DD.
400Date format not correct, format must be 'YYYY-MM-DD'idate isn't a strict date. Zero-pad the month and day: 2026-09-05, not 2026-9-5.
400Time not correct, 24 hours format requireditime isn't valid 24-hour time. Send HH:MM:SS, for example 14:32:00.
400Invoice details missinginvoiceDetails is missing or empty. Send at least one line.
400TIN number must be 9 digitscustidtype is 1 but custid doesn't have 9 digits once spaces and dashes are removed. Check the customer's TIN.
400Customer ID Type must be between 1 to 6custidtype is missing or out of range. Use a value from Customer ID types.
400Paytype missingpaytype isn't set. Send 1–5; see Payment types.
400Customer Invoice number is required when the payment type is 5.Payments on invoice (paytype 5) need a custinvoiceno.
400One of the items was not specified a taxcodeA line in invoiceDetails has no taxcode.
400Unrecognized tax code 9taxcode isn't 1–5 (for example 0, 6, non-numeric or missing). See Tax codes.
400Duplicated invoice number INV-20260905-0001, for selected or default deviceThis custinvoiceno already exists on the device, whatever its send status. If you're retrying after a timeout, the first attempt was saved; see Retries and duplicates. Otherwise use a new number.
4003 pending invoices are not submitted to TRA for more than 4 days. Please resolve before creating new invoices.The device has invoices that haven't reached TRA for over four days, and new invoices are blocked until they're cleared. Resolve the pending invoices from the PowerVFD dashboard, then resubmit.
400Invoice amount (TZS 500000.00) exceeds your per-invoice limit of TZS 200000.00.The invoice total is over the per-invoice limit of the user in username. An administrator can raise the limit, or a user with a higher limit can issue the invoice.
400Invoice date (2026-09-01) is out of sequence — invoice INV-0098 already exists for 2026-09-03. Please post missing dates in order before posting this date.A back-dated invoice would land before one that already exists for the device. Post invoices in date order. See Dates and order.
400custname: <detail>The customer name contains a character on the blocklist. The message names it; remove or replace that character.
400description: <detail>A line description contains a blocked character. The message names it.
400Branch or department not foundbranch or department doesn't match a configured name. Check the spelling, or leave it out to use the defaults. The exact wording of this message isn't documented yet.
403User shakil is not authorised to create invoices (per-invoice access is disabled).The user in username isn't allowed to create invoices. An administrator needs to enable it for that user.
404Interface: This request is not authorized to access the system, please contact system Administrator to authorizefcode and fcodetoken don't match an authorised interface. Check both values and that the interface is still active. Returned as 404 even though it's an authorisation error.
402Device DV03 not founddevicenumber doesn't match a device on this server. Check the number, or configure a default device.
402Device DV03 has no license token. Please install a license.No licence is installed for the device. Contact your administrator or Power Computers.
402License for device DV03 is activated on a different machine. Please contact your administrator to obtain a new license for this server.The licence is bound to another server. This server needs its own licence.
402License for device DV03 was rejected by the license server. Please contact your administrator.The licence server refused the licence. Contact your administrator or Power Computers.
402License for device DV03 has expired and no renewal was found. Please contact your administrator.The automatic renewal ran but found no renewal. The licence needs renewing.
402License for device DV03 has expired and the renewal server is unreachable. Please contact your administrator.The renewal couldn't reach the licence server. Check the server's internet connection; the next request will try the renewal again.
402License for device DV03 has been revoked. Please contact your administrator.The licence was revoked. Contact your administrator or Power Computers.
402License for device DV03 is invalid. Please contact your administrator.The installed licence isn't valid. Contact your administrator or Power Computers.
500Failed to process invoiceUnexpected server-side failure, such as a lost database connection. Retry with the same custinvoiceno and back off between attempts.

Validation rules

Everything the server checks before it writes an invoice. A failure returns 400 (or 403 for user permissions) and nothing is saved.

Dates and order

  • idate must be a strict YYYY-MM-DD date and itime a 24-hour HH:MM:SS time.
  • Future dates are always rejected.
  • Past dates are rejected unless the device's timeserver setting is lastinv.
  • Even with lastinv, a past date is only accepted if no later-dated invoice already exists for the device. Invoices stay in date order.

Posting historical invoices? The device's timeserver must be lastinv, and you have to submit them oldest first.

Invoice numbers

  • custinvoiceno is optional but recommended.
  • When present, it must be unique per device across every send status. A number that was already sent is rejected as a duplicate, not just pending ones.
  • It's required when paytype is 5 (invoice).

Customer identification

  • custidtype must be 1–6. See Customer ID types.
  • For a TIN (type 1), custid must have exactly 9 digits once non-digit characters are removed, so 123-456-789 passes.
  • For NIL (type 6), custid must be omitted, blank or "null". Any other value is an error.

Lines and amounts

  • invoiceDetails must contain at least one line.
  • Every line needs a taxcode of 1–5.
  • qty must be numeric.
  • amt must be numeric, not negative and not empty. It's the VAT-inclusive line total.
  • discount, if sent, must be numeric.

Special characters

custname and every line's description are checked against a blocklist of disallowed characters. The check is intentionally strict and won't be relaxed. A hit returns 400 with a message that names the field and the rejected character, such as description: <detail>.

Test with real data. The blocklist isn't reproduced here. Before going live, send your actual product descriptions and customer names through a test environment so rejected characters show up early.

Cashier limits and approvals

When username is present, the invoice is checked against that user's settings:

SettingEffect
invoice_limit_amountThe most a single invoice from this user can total.
perday_amount_limitThe most this user's invoices can total in a day.
approval_per_invoiceApproval gate applied per invoice.
approval_per_dayApproval gate applied per day.

Going over a limit returns 400. A user whose per-invoice access is disabled gets 403.

Branches and departments

If branch is omitted, the device's default branch is used; if department is omitted, the branch's default department is used. A name that doesn't match an existing branch or department returns 400.

Unique item mode

When a device has unique_item_mode on, each product can be sold once. Every line must carry a prodid, qty is capped at 1, and a product already marked sold can't be used again.

Pending invoices

If a device has invoices that haven't been submitted to TRA for more than four days, new invoices are refused until those are resolved. The message gives the count:

{ "status": "error", "message": "3 pending invoices are not submitted to TRA for more than 4 days. Please resolve before creating new invoices.", "statusCode": 400 }

Batch submission

Send several invoices in one call when they must succeed or fail together.

Shape

Put more than one object in the invoice array. Each entry is a complete invoice with its own device and customer.

{
  "invoice": [
    {
      "idate": "2026-09-05", "itime": "09:10:00",
      "custinvoiceno": "INV-001", "custidtype": 6, "paytype": 1,
      "devicenumber": "DV03", "fcode": "F-9CJ21A", "fcodetoken": "a1b2c3d4e5f6...",
      "invoiceDetails": [{ "description": "20L Drinking Water", "qty": 1, "taxcode": 1, "amt": 2500.00 }]
    },
    {
      "idate": "2026-09-05", "itime": "09:25:00",
      "custinvoiceno": "INV-002", "custidtype": 1, "custid": "123456789", "paytype": 4,
      "devicenumber": "DV03", "fcode": "F-9CJ21A", "fcodetoken": "a1b2c3d4e5f6...",
      "invoiceDetails": [{ "description": "Bottled Soda 500ml", "qty": 6, "taxcode": 1, "amt": 3000.00 }]
    }
  ]
}

All or nothing

The whole array is processed inside a single database transaction. If any one invoice fails validation, the entire batch is rolled back and none of it is committed. You get a single error response back.

Reading the response

A batch response wraps each result in an invoices array (see Responses). Match each result to your invoice by custinvoiceno, so always send one in a batch.

When to batch

SituationApproach
Importing or migrating historical invoicesBatch them, oldest first, on a device whose timeserver is lastinv. The dashboard does the same for imports.
Invoices that must be issued togetherBatch them. Either all are issued or none are.
Live sales at a tillOne invoice per call, so a single bad invoice doesn't hold up the rest.

Retries and duplicates

custinvoiceno is what stops a retry from creating a second receipt.

A duplicate custinvoiceno is a hard 400, not a silent no-op. That makes it a reliable guard against double receipts, as long as every invoice carries a number. Don't resend a failed submission with the same number unless you're prepared for the duplicate error that tells you the first attempt actually saved.

Should I retry?

ResultRetry?What to do
200—Store the receipt details.
Timeout or no responseYesResend the same request with the same custinvoiceno.
500Yes, with backoffSame request, same custinvoiceno. Each request runs in one transaction, so the retry either succeeds or returns a duplicate error if the first attempt did commit.
400 duplicate, after a retryNoAn earlier attempt saved. Treat the invoice as issued and get its receipt details from the PowerVFD dashboard.
400 anything elseNoFix the request. Resending it unchanged fails the same way.
402NoDevice licence problem; contact your administrator. The exception is "renewal server is unreachable", which can succeed later once the server is back online.
403 / 404NoUser permissions or interface credentials. These need an administrator.

Example: submit with retries

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

// invoice must include a custinvoiceno, or retries can create duplicates.
async function submitInvoice(invoice, attempts = 4) {
  for (let attempt = 1; attempt <= attempts; attempt++) {
    let res;
    try {
      res = await fetch("{{BASE_URL}}/service/v1/invoices", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ invoice: [invoice] }),
        signal: AbortSignal.timeout(30_000),
      });
    } catch (err) {
      // Network error or timeout: it may or may not have saved. Retry.
      await sleep(2 ** attempt * 1000);
      continue;
    }

    const data = await res.json();
    if (res.ok) return { issued: true, receipt: data };

    if (res.status === 400 && attempt > 1 &&
        data.message.startsWith("Duplicated invoice number")) {
      // An earlier attempt was saved. Look the receipt up in the dashboard.
      return { issued: true, receipt: null };
    }
    if (res.status === 500) {
      await sleep(2 ** attempt * 1000);
      continue;
    }
    throw new Error(`${data.statusCode}: ${data.message}`);
  }
  throw new Error("PowerVFD did not respond after several attempts");
}

Tally integration

POST/service/v1/invoices/tally

Tally submits to its own route, which runs the same handler as /service/v1/invoices, wrapped for Tally XML integrations.

The fields, validation rules, responses and errors in these docs all apply to it.

Setting up

  1. Create an interface for Tally in the PowerVFD dashboard. Its fcode and fcodetoken go in every request.
  2. Map the voucher number to custinvoiceno. Duplicates are then rejected, so a voucher can't be fiscalised twice, and receipts reconcile with Tally.
  3. Map the party's TIN to custid with custidtype 1, or send custidtype 6 for walk-in sales.
  4. Map each line's VAT treatment to a taxcode. See Tax codes. Send amt VAT-inclusive.
  5. Store the receipt details (vfdinvoicenum, znumber, rctvcode, rctvnum) against the voucher.

Getting help

The Tally-side setup depends on how your Tally company is configured. Contact Powercomputers at solutions@powercomputers.co.tz or +255 687 589 421.

For TallyPrime licences, implementation and training, see PowerTally, Powercomputers' Tally team.

Tax codes

taxcode is the number you send. PowerVFD derives TRA's VAT category letter (A–E) from it, which is what's stored, printed and sent to TRA. You never send the letter yourself.

taxcodeCategoryTRA labelRateHow the amount is split
1AStandard Rate18%VAT-registered device: netamount = amt / 1.18, taxamount = amt − netamount. Not registered: netamount = amt, taxamount = 0.
2BSpecial Rate0%netamount = amt, taxamount = 0
3CZero Rate0%netamount = amt, taxamount = 0
4DSpecial Relief0%netamount = amt, taxamount = 0
5EExempt0%netamount = amt, taxamount = 0

Any other value (0, 6, non-numeric or missing) returns 400 Unrecognized tax code.

VAT registration

Code 1 is the only category where a rate is actually applied, and only when the device is VAT-registered: its vrn is set and isn't the literal NOT REGISTERED. A business that isn't registered can still sell standard-rate goods. The line stays category A, because the category describes the product, not the seller, but no VAT is collected on it.

Worked example

One line with amt: 5000.00 and taxcode: 1:

VAT-registered deviceNot registered
CategoryAA
netamount4,237.295,000.00
taxamount762.710.00

Invoice totals

The invoice totals totaltaxexcl and totaltaxincl are the sums of netamount and of netamount + taxamount across every line, rounded to 2 decimal places.

Customer ID types

Values for custidtype.

ValueLabelNotes
1TINExactly 9 digits after non-digit characters are removed.
2Driving Licence
3Voters Number
4Passport
5NIDANational ID.
6NILWalk-in customer, no ID on file. custid must be omitted, blank or the string "null". Any other value is a validation error.

Payment types

Values for paytype.

ValueLabelNotes
1CASH
2CHEQUE
3CCARDCard payment.
4EMONEYMobile money and other e-money.
5INVOICEcustinvoiceno becomes required.

Glossary

Terms used across PowerVFD and these docs.

TermMeaning
TRATanzania Revenue Authority.
VFDVirtual Fiscal Device. Software that signs receipts and submits them to TRA, doing the job of an EFD machine.
EFDElectronic Fiscal Device. A physical fiscal machine at the point of sale.
TINTaxpayer Identification Number. 9 digits.
VRNVAT Registration Number. A device with no VRN, or NOT REGISTERED, doesn't charge VAT.
DeviceA VFD registration in PowerVFD, with its own TIN, TRA certificate, serial number and licence. Referred to by number, such as DV03.
Default deviceThe device used when an invoice doesn't send devicenumber.
InterfaceOne system authorised to submit invoices, identified by fcode and authenticated by fcodetoken.
LicencePowerVFD's per-device licence, checked on every request and bound to the server it was activated on.
rctvcodeReceipt verification code printed on the receipt: the device's receipt code plus its global counter.
rctvnumThe full TRA verification URL for a receipt. The QR code encodes it.
vfdinvoicenumThe TRA running receipt number, also called rctnum.
Global counter (gc)The device's running fiscal counter. Part of rctvcode.
Z report / znumberThe daily summary submitted to TRA. znumber identifies the Z report an invoice was rolled into.
timeserver / lastinvDevice setting for invoice dates. With lastinv, back-dated invoices are accepted as long as they stay in date order.
Unique item modeDevice setting where each product can be sold once. Lines need a prodid and qty of 1.

Try , , or .