<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Iurii Rogulia</title>
    <description>The latest articles on DEV Community by Iurii Rogulia (@iurii_rogulia).</description>
    <link>https://dev.to/iurii_rogulia</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3561015%2Fd1b53175-2e87-4fa8-9c54-90f6b713141b.jpg</url>
      <title>DEV Community: Iurii Rogulia</title>
      <link>https://dev.to/iurii_rogulia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iurii_rogulia"/>
    <language>en</language>
    <item>
      <title>Google Ads Management: Why % of Spend Is the Wrong Fee</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Mon, 23 Nov 2026 11:01:09 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/google-ads-management-why-of-spend-is-the-wrong-fee-2gc7</link>
      <guid>https://dev.to/iurii_rogulia/google-ads-management-why-of-spend-is-the-wrong-fee-2gc7</guid>
      <description>&lt;p&gt;A percentage-of-spend fee pays the manager more when you spend more, whether or not your results improve. That is the whole argument. The rest is when it matters and what to ask so you can tell.&lt;/p&gt;

&lt;p&gt;If you are paying for Google Ads management as a share of your ad budget, or you are about to, this is not an accusation against the person on the other side. The point is narrower: the fee structure has a built-in lean, and you are the one who has to know which way it leans.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a Percentage-of-Spend Fee Actually Pays For
&lt;/h2&gt;

&lt;p&gt;Take a simple case. You spend €5,000 a month on ads and the manager takes a fixed share of that. The next month you spend €10,000. Nothing about the work has to change for the fee to double. Same account, same campaigns, same weekly check-in – twice the invoice.&lt;/p&gt;

&lt;p&gt;Now flip it. The manager finds that a third of your budget goes to clicks that never turn into anything, cuts it, and the account performs the same on less money. The fee goes down. They did the most valuable thing in the job, and the structure charged them for it.&lt;/p&gt;

&lt;p&gt;That is the mechanism, and it needs no statistic to hold: the fee is tied to the size of the budget, while what you care about is what each result costs you. Those two numbers can move in the same direction. They do not have to.&lt;/p&gt;

&lt;p&gt;I am not saying this makes the manager dishonest. Incentives do not decide what a person does. They decide which choices are easy and which ones feel awkward.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the Incentive and Your Interest Split
&lt;/h2&gt;

&lt;p&gt;Almost every decision in an ad account has a version that raises spend and a version that lowers it. A percentage fee makes one of them free and the other one costly. A few places where that shows up:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Budget recommendations.&lt;/strong&gt; ‘We are leaving volume on the table, I would raise the daily budget’ can be true. It is also the one piece of advice that directly raises the adviser’s own income. When the person recommending it is paid on the spend, you cannot tell which reason is doing the work. You can only ask for the evidence behind it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reach settings.&lt;/strong&gt; Settings that widen who sees your ads can be right for a given business. They also raise the amount that can be spent. If the answer to ‘why this setting?’ is a general principle rather than something you can see in your own search terms or placements, ask for the specific case.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cutting waste.&lt;/strong&gt; Pausing a campaign, tightening keywords, or turning off a placement that eats money is the dull part of the job. Under a percentage, each of those lowers next month’s fee. It can still get done. It just has to get done by someone whose pay is pointing the other way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reporting on the wrong thing.&lt;/strong&gt; A report built around impressions, clicks and spend looks busy and tells you little about whether the account earns its keep. Spend is the number a percentage fee is calculated on. What matters is what you got for it.&lt;/p&gt;

&lt;p&gt;All of these are ‘can’ and ‘tends to’, not ‘does’. I have no sample to back a claim about how often it happens, and I won’t invent one. What I can say is that you are trusting someone with your money in a setup where their income rises when your budget rises. That deserves a few direct questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  When a Percentage Fee Is Still Reasonable
&lt;/h2&gt;

&lt;p&gt;I do not think a percentage is always wrong, and a flat fee is not free of problems.&lt;/p&gt;

&lt;p&gt;A percentage can be reasonable when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The spend is large and the work really scales with it.&lt;/strong&gt; A big account with many campaigns, many markets, constant creative testing and a lot of moving parts takes more time as it grows. A fee that grows with it is not absurd.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;There is a cap or a floor.&lt;/strong&gt; A percentage with a ceiling, or a percentage that steps down as spend grows, softens the pull. You can see where the incentive stops.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Part of the fee is tied to a result you both defined.&lt;/strong&gt; A performance-linked element can work if the result is something you can check independently, and not only something the manager reports.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The terms are written down and you can read them.&lt;/strong&gt; Fee base, what counts as ‘spend’, what is included. No surprises on the invoice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A flat fee has its own weakness. It does not reward growth. If the account is working and the right move is to spend four times as much, a flat-fee manager gets the same money for four times the responsibility, and might be less keen to push for it. A flat fee also fits badly if the scope keeps expanding without anyone resetting the price. You end up with either a manager doing extra work for free or a manager who has quietly stopped.&lt;/p&gt;

&lt;p&gt;So the summary is not ‘flat good, percentage bad’. It is: every fee structure leans somewhere. The question is whether you know where, and whether the lean can hurt you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions to Ask Any Provider Before You Sign
&lt;/h2&gt;

&lt;p&gt;These work whatever the fee structure is. They are more useful on a percentage, because the answers show how the lean is handled.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;What exactly is the fee calculated on?&lt;/strong&gt; Total spend, spend after platform credits, spend across all channels? Is there a minimum, and does it apply even when spend drops?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who owns the account?&lt;/strong&gt; The ad account, the analytics property and the data should be yours, with the provider holding admin access. If you leave, you should not have to rebuild anything or ask permission to see your own history.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What do you do when spend should go down?&lt;/strong&gt; Ask for an example, in their own work, of a time they recommended cutting budget or pausing a campaign. A manager who has done it will answer quickly. Ask what that did to their fee.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is ad spend paid directly to the platform, or through them?&lt;/strong&gt; Paying Google from your own card keeps the fee and the budget separate, and lets you see exactly what was spent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What counts as a result, and who checked it?&lt;/strong&gt; If ‘conversions’ means whatever the account says it means, the reports only prove the account agrees with itself. Measurement has to be right before any fee structure matters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What will I see every week, and every month?&lt;/strong&gt; A short written summary of what was spent, what it produced and what was changed is a reasonable ask. A dashboard login alone is not the same thing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What happens if I want to stop?&lt;/strong&gt; Notice period, who holds what, how handover works.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There is nothing hostile in these. A provider with nothing to hide can answer them in a few minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a Flat Fee Changes, and What It Doesn’t
&lt;/h2&gt;

&lt;p&gt;I run &lt;a href="https://iurii.rogulia.fi/services/paid-ads" rel="noopener noreferrer"&gt;paid ads&lt;/a&gt; for Google Ads, Meta and Reddit on a flat fee: €400 per channel per month, no setup fee, and no percentage of spend. An account with one campaign in one market and one language, at a moderate budget, takes about the same weekly attention whether it spends a little more or a little less. So the price follows the scope: how many channels, markets and languages, not how much you put into the ads. A large account with many moving parts does take more work, as noted earlier.&lt;/p&gt;

&lt;p&gt;What that changes is the direction of the lean. A recommendation to cut spend costs me nothing, and a recommendation to raise it earns me nothing extra. You can still disagree with my advice, but you do not have to guess whether the advice is paying for itself.&lt;/p&gt;

&lt;p&gt;What it does not change:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It does not guarantee results.&lt;/strong&gt; I commit to the work and a written monthly report, not to a cost per lead or a return on ad spend. Anyone promising those in advance is guessing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It does not remove the weakness above.&lt;/strong&gt; If an account takes off and needs much more attention, a flat fee does not rise by itself. That is a conversation about scope, and I would rather have it openly than hide it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ad spend stays with you.&lt;/strong&gt; You pay Google, Meta or Reddit directly, from your own account. The accounts stay yours; I get admin access, not ownership.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What My Own Google Ads Account Taught Me
&lt;/h2&gt;

&lt;p&gt;I should say where I stand on Google Ads for my own offer, because I have run it on my own site.&lt;/p&gt;

&lt;p&gt;For about two months I ran search campaigns for my services. Total spend was €203.78, with 247 clicks and 6,686 impressions, and no real inquiry came out of it. I paused all campaigns on 19 June 2026, and they remain paused. It was my account and my decision to stop, and nobody’s fee depended on my continuing.&lt;/p&gt;

&lt;p&gt;This is not a success story, and it is not evidence that ads do not work. It is one small account, one offer and one person. My services are bought on trust. At that volume, 247 clicks is simply too few to expect a lead from a product like that. The result is unsurprising, and it fits why I do not sell Google Ads as a guaranteed channel.&lt;/p&gt;

&lt;p&gt;It also shaped how I think about the fee question. Small, thin spend on an offer that needs trust to close is a place where no fee structure will rescue the outcome. Some accounts are limited by the offer or the volume, not by who manages them. That is a different problem from the one in this post, and a fee cannot fix it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is This Fee Structure Right for You?
&lt;/h2&gt;

&lt;p&gt;A flat fee per channel suits you if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You already spend, or plan to spend, enough on ads that the question of who benefits from that spend matters to you.&lt;/li&gt;
&lt;li&gt;You want the accounts in your name, a written report each month, and advice you can test.&lt;/li&gt;
&lt;li&gt;You are fine with a defined scope, and happy to revisit the price if the scope grows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Paying anyone to manage Google Ads, on any fee, is probably the wrong move if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Your budget is tiny.&lt;/strong&gt; At very small spend, the management fee can exceed what the ads could plausibly return, and a few hours of learning the basics yourself may serve you better.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You sell something people buy on trust and referral.&lt;/strong&gt; A high-consideration service with a few leads a year does not always generate enough search demand to learn from.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You cannot tell a real inquiry from a click.&lt;/strong&gt; If you have no way to say which leads became customers, no manager can optimise toward that, and no fee structure will help.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are weighing a percentage offer against something else, my post on &lt;a href="https://iurii.rogulia.fi/blog/is-your-software-quote-honest" rel="noopener noreferrer"&gt;reading a software quote&lt;/a&gt; takes a related angle: you judge a seller by how they handle uncertainty and what they are paid for. Read the fee first, then the pitch.&lt;/p&gt;

</description>
      <category>paidads</category>
      <category>business</category>
      <category>pricing</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The File-Integrity Step in Admissions Document Review</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Mon, 23 Nov 2026 11:00:52 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/the-file-integrity-step-in-admissions-document-review-5f63</link>
      <guid>https://dev.to/iurii_rogulia/the-file-integrity-step-in-admissions-document-review-5f63</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published at &lt;a href="https://htpbe.tech/blog/admissions-document-review-file-integrity-step" rel="noopener noreferrer"&gt;htpbe.tech&lt;/a&gt;. The version on htpbe.tech stays in sync with the latest detection algorithm — refer to it for the canonical text.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;An admissions officer opening an application sees a transcript, a degree certificate and a bank letter, all as PDFs. They look right. The grades are plausible, the crest is in the corner, the balance clears the threshold. What the officer cannot see from the page is whether the file in front of them is still the one the institution or the bank produced, or a copy someone edited on the way to the upload form.&lt;/p&gt;

&lt;p&gt;This article is for university admissions and compliance teams, and for the education agents and immigration advisers who assemble application bundles. It covers one narrow step in admissions document review – a PDF file check for evidence of modification – and where it sits beside the credential checks you already run.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the file-integrity step?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; it is a check on the PDF file itself, run at intake, that asks one question: was this file changed after it was created? HTPBE answers it with structural PDF analysis. It reads how the file was built and saved, not the text, grades or figures on the page, and returns one of three verdicts: &lt;code&gt;intact&lt;/code&gt;, &lt;code&gt;modified&lt;/code&gt; or &lt;code&gt;inconclusive&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The step does not replace credential verification. Confirming that an institution awarded a degree, that a transcript matches its records or that funds are held in an account remains the job of the issuing institution, the bank, or an official verification service. The file check runs before and alongside those steps: each file gets a quick file-level result, and the issuer-side checks still run on every document as they always have.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which admissions documents arrive as PDFs?
&lt;/h2&gt;

&lt;p&gt;Most admissions documents now arrive as PDFs, and each route puts the file in different hands first:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Academic transcripts.&lt;/strong&gt; Some institutions send electronic transcripts directly; many applicants download one from a student portal or scan a paper copy, so the applicant usually holds the file before you do.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Degree certificates and diplomas.&lt;/strong&gt; Often scanned or photographed from a paper original, sometimes issued as a PDF. The checks HTPBE runs on this document type are described on the &lt;a href="https://htpbe.tech/use-cases/fake-certificate-detection/fake-diploma-detection" rel="noopener noreferrer"&gt;diploma tamper-detection page&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof-of-funds documents.&lt;/strong&gt; Bank statements and bank letters supporting a student visa application or a deposit. For how UKVI treats bank statements on the immigration side, see &lt;a href="https://htpbe.tech/blog/uk-visa-bank-statement-fraud-ukvi" rel="noopener noreferrer"&gt;what UKVI actually checks&lt;/a&gt;; this article does not repeat those rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent-forwarded bundles.&lt;/strong&gt; An education agent or adviser collects documents from the student and forwards them, sometimes merged into one PDF. One more party has handled every file. A merged bundle is itself a changed file, so it will not come back &lt;code&gt;intact&lt;/code&gt; even when every document in it is unaltered. Where you can, check each document as the student supplied it, before merging, and treat a verdict on the bundle as a routing signal about the bundle, not about any single document.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What a reviewer sees, and what the file shows
&lt;/h2&gt;

&lt;p&gt;A reviewer reads the page, and that catches a lot: a grading scale that does not match the institution, a name spelled two ways. Manual review, helped by OCR where your team uses it, is good at spotting content inconsistencies.&lt;/p&gt;

&lt;p&gt;What that review cannot see is the file’s history. A PDF records how it was put together and saved, and an edit made after the document was created can leave evidence in that structure even when the page looks unaltered. That is the layer HTPBE reads. A transcript can read perfectly and still carry evidence of a later edit. The reverse question – whether what the page says is true – is one the file check cannot answer, because it does not read the content.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which check answers which question?
&lt;/h2&gt;

&lt;p&gt;Admissions review already combines several checks. The file-integrity step fills one gap:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;Who answers it&lt;/th&gt;
&lt;th&gt;What it does not answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Was this PDF changed after it was created?&lt;/td&gt;
&lt;td&gt;File-integrity check (HTPBE)&lt;/td&gt;
&lt;td&gt;Whether the institution issued it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Did the institution issue this document to this student?&lt;/td&gt;
&lt;td&gt;The issuing institution or an official verification service&lt;/td&gt;
&lt;td&gt;Whether the file you hold was later edited&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Does the content meet our entry and eligibility rules?&lt;/td&gt;
&lt;td&gt;Admissions and compliance review&lt;/td&gt;
&lt;td&gt;Whether the figures on the page are real&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The second row stays primary. HTPBE never confirms that an institution issued a document, never checks grades and never confirms that funds exist. The broader picture of how forged diploma and certificate PDFs show up across sectors is on the &lt;a href="https://htpbe.tech/use-cases/fake-certificate-detection" rel="noopener noreferrer"&gt;certificate tamper-detection page&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What each verdict means at the admissions gate
&lt;/h2&gt;

&lt;p&gt;Write what each result does into the review procedure before the first file goes through. Every API result carries a &lt;code&gt;usage_caution&lt;/code&gt; field stating that it is not safe for automated adverse decisions. A verdict describes the file, not the applicant, and it should never be the sole basis for refusing an offer or withdrawing one.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Verdict&lt;/th&gt;
&lt;th&gt;What it means&lt;/th&gt;
&lt;th&gt;What the review step does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;intact&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No modification was detected in the file&lt;/td&gt;
&lt;td&gt;Continue with credential and eligibility review as normal. It is not a confirmation of the document.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;modified&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The file itself carries evidence that it was changed after it was created&lt;/td&gt;
&lt;td&gt;Route to a reviewer with the result and its named markers attached. Ask for an issuer-sent copy.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;inconclusive&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;HTPBE cannot confirm the file as an untouched original – a reason for manual review, not proof of fraud&lt;/td&gt;
&lt;td&gt;Not a rejection. Use the issuer channel you would use anyway, and review the content as you normally would.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;inconclusive&lt;/code&gt; is routine.&lt;/strong&gt; Scanned and photographed pages can never be confirmed &lt;code&gt;intact&lt;/code&gt;, and many perfectly ordinary transcripts and diplomas reach admissions as scans. The result says nothing about the applicant. For &lt;code&gt;inconclusive&lt;/code&gt;, &lt;code&gt;usage_caution.recommended_action&lt;/code&gt; is &lt;code&gt;request_from_issuer&lt;/code&gt;: in admissions that means the channel your team already uses, such as asking the institution to send the transcript directly or confirming the award through an official verification service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;modified&lt;/code&gt; is not a finding of fraud.&lt;/strong&gt; It says the file carries evidence that it was changed after it was created. It does not say who changed it, why, or whether the content is now wrong, and a changed file is not, on its own, proof that anyone acted dishonestly. The result lists named markers describing what was found, so the reviewer sees the reason, not just the verdict. Word the request to the applicant neutrally: you need an issuer-sent copy of this document. Give them the chance to explain before any decision.&lt;/p&gt;

&lt;p&gt;Check your procedure against your own legal and regulatory obligations on adverse decisions before you rely on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the step sits in intake
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;At a university.&lt;/strong&gt; The natural point is where documents are uploaded to the applicant portal or pulled into the admissions system, so a reviewer opening the application sees the verdict next to the document. Credential checks still run on every file; a &lt;code&gt;modified&lt;/code&gt; or &lt;code&gt;inconclusive&lt;/code&gt; result adds an issuer-sent-copy request to that review.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;At an education agency or immigration practice.&lt;/strong&gt; Agents and advisers sit one step earlier. Checking each file as a student hands it over means evidence of a change can surface before your organisation puts its name to a submission. For the immigration-adviser side, including visa and sponsor documents beyond admissions, see the &lt;a href="https://htpbe.tech/use-cases/immigration-document-fraud-detection" rel="noopener noreferrer"&gt;immigration document tamper-detection page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The same step appears in employment screening. The &lt;a href="https://htpbe.tech/blog/right-to-work-i9-document-fraud" rel="noopener noreferrer"&gt;right-to-work and I-9 article&lt;/a&gt; covers it for HR teams, and the &lt;a href="https://htpbe.tech/blog/hr-diploma-verification-pdf-api" rel="noopener noreferrer"&gt;diploma check for HR and ATS pipelines&lt;/a&gt; covers the API integration side.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling student data.&lt;/strong&gt; Transcripts and bank letters carry personal data. Files uploaded through the web may be retained after analysis to improve detection, without being linked to your account. Files submitted through the API are fetched, analysed once and discarded; only the result is kept. With the on-premise deployment, documents stay inside your own infrastructure. For web and API checks, the result is kept for up to three years and includes the filename. Results are private by default, but a public link you enable shows the filename too, so use neutral filenames rather than a student’s name. The &lt;a href="https://htpbe.tech/legal/privacy" rel="noopener noreferrer"&gt;privacy policy&lt;/a&gt; sets out the details.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the file check does not tell you
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Outside the file check:&lt;/strong&gt; the institution, the grades, the funds and the applicant. HTPBE does not read the content of the document, does not contact the institution or the bank, and does not confirm that a degree was awarded or that money is in an account.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The other limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Content that was false from the start.&lt;/strong&gt; The check looks for evidence that a file was changed after it was created, and content that was false from the start carries no evidence of a later edit. The check does not read content, so it cannot judge whether what the document says is true. &lt;code&gt;intact&lt;/code&gt; means no modification was detected, not that the document is genuine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scans and photographs.&lt;/strong&gt; An &lt;code&gt;inconclusive&lt;/code&gt; result on them is routine and is not a mark against the applicant.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Signatures.&lt;/strong&gt; Where a file carries a digital signature, the check does not test the certificate, the certificate chain or the signer’s identity.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does an intact result confirm the university issued the transcript?
&lt;/h3&gt;

&lt;p&gt;No. HTPBE checks the PDF file, not the institution, the grades or the student. An &lt;code&gt;intact&lt;/code&gt; result means no modification was detected in the file, not that the document is genuine. Whether the institution issued the transcript, and whether the grades on it are right, are questions for the issuing institution or an official verification service, which stays the primary check.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is an inconclusive result on a scanned transcript a red flag?
&lt;/h3&gt;

&lt;p&gt;No. An &lt;code&gt;inconclusive&lt;/code&gt; result means HTPBE cannot confirm the file as an untouched original – a reason for manual review, not proof of fraud. Scanned and photographed pages can never be confirmed &lt;code&gt;intact&lt;/code&gt;, so at the admissions gate this result is routine. The next step is the issuer channel your team would use anyway, such as asking the institution to send the document directly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can we reject an applicant because a file came back modified?
&lt;/h3&gt;

&lt;p&gt;Not on that result alone. Every API result carries a &lt;code&gt;usage_caution&lt;/code&gt; field stating it is not safe for automated adverse decisions. A &lt;code&gt;modified&lt;/code&gt; result says the file carries evidence that it was changed after it was created; it does not say who changed it, why, or whether the content is wrong. Route the case to a reviewer, give the applicant a chance to explain or provide an issuer-sent copy, and let your normal admissions and credential checks decide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check a sample file
&lt;/h2&gt;

&lt;p&gt;Start with a file or two your team has already reviewed, and compare the verdicts with what you know about each one. The &lt;a href="https://htpbe.tech/use-cases/fake-certificate-detection" rel="noopener noreferrer"&gt;certificate tamper-detection page&lt;/a&gt; shows what HTPBE checks on diplomas and transcripts. To run a check, upload a PDF on the &lt;a href="https://htpbe.tech/" rel="noopener noreferrer"&gt;home page&lt;/a&gt; or send a file URL through the &lt;a href="https://htpbe.tech/api" rel="noopener noreferrer"&gt;API&lt;/a&gt;. Files uploaded through the web may be retained after analysis, and API submissions are discarded once analysed, so for applicant documents use the API or a file you are free to share.&lt;/p&gt;

</description>
      <category>pdf</category>
      <category>fintech</category>
      <category>webdev</category>
    </item>
    <item>
      <title>What vatnode Logs About Your Account, and How Long</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Mon, 23 Nov 2026 10:00:52 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/what-vatnode-logs-about-your-account-and-how-long-1i6k</link>
      <guid>https://dev.to/iurii_rogulia/what-vatnode-logs-about-your-account-and-how-long-1i6k</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published at &lt;a href="https://vatnode.dev/blog/vatnode-account-security-events-explained" rel="noopener noreferrer"&gt;vatnode.dev&lt;/a&gt;. The version on vatnode.dev is the canonical source — refer to it for the latest content.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;vatnode records account creation, every sign-in, every use of ‘Sign out other devices’, the creation of a live API key and the revocation of a key, and shows the latest 20 of those events on your Security page. For sign-ins recorded with an IP address, the IP and user agent are removed after 30 days, and the rows are deleted after one year.&lt;/p&gt;

&lt;h2&gt;
  
  
  What vatnode records about account activity
&lt;/h2&gt;

&lt;p&gt;Two logs feed the activity view: a security events log for account creation, sign-ins and signing out other devices, and an audit log for API key changes.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Event&lt;/th&gt;
&lt;th&gt;Stored fields&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Account created&lt;/td&gt;
&lt;td&gt;Time only. No IP address, no user agent.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sign-in (every new session)&lt;/td&gt;
&lt;td&gt;Time, IP address, user agent.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Other devices signed out&lt;/td&gt;
&lt;td&gt;Time, IP address, user agent.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Live API key created&lt;/td&gt;
&lt;td&gt;Time, key label, IP address. No user agent.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API key revoked&lt;/td&gt;
&lt;td&gt;Time, IP address. No label, no user agent.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The audit log also records account deletion, billing events such as a cancellation, and changes vatnode support makes on your behalf. Those entries are kept on the same schedule but do not appear in the activity card.&lt;/p&gt;

&lt;p&gt;A sign-in is logged the same way whether you used Google, GitHub or an emailed sign-in link or code.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does not record
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Logouts.&lt;/li&gt;
&lt;li&gt;Failed sign-ins.&lt;/li&gt;
&lt;li&gt;Requests for a sign-in link or code.&lt;/li&gt;
&lt;li&gt;Regenerating the test key. It writes no log row and sends no email.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;API calls are not sign-ins either: a VAT check made with an API key creates no security event. The check stores the client user agent and no IP address.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who can see it
&lt;/h2&gt;

&lt;p&gt;You can, on the &lt;a href="https://vatnode.dev/dashboard/settings" rel="noopener noreferrer"&gt;Security&lt;/a&gt; page of the dashboard, in the ‘Recent activity’ card. It lists the latest 20 events, newest first, with the user agent shortened to something like ‘Chrome 120 on Mac’. It is not the full history.&lt;/p&gt;

&lt;p&gt;The card is backed by &lt;code&gt;GET /v1/me/security-events&lt;/code&gt;, which accepts only a dashboard session cookie. An API key does not work on it. The response looks like this (fictitious values):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"events"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"7c1e5b0a-3f64-4d0e-9a52-1b8f6e2d4c90"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"api_key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"API key created: \"checkout-prod\""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"ip"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"198.51.100.24"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"userAgent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-12T09:41:07.000Z"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"e04a9d27-81c3-4b5f-a6d0-52f7c3b19e68"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"auth"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Sign-in"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"ip"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"203.0.113.58"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"userAgent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 Chrome/120.0.0.0 Safari/537.36"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-12T09:38:52.000Z"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2b96f3c8-d715-4e0a-8c41-9a07d5e6b123"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"auth"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Account created"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"ip"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"userAgent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-03T14:05:19.000Z"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;category&lt;/code&gt; is &lt;code&gt;auth&lt;/code&gt; or &lt;code&gt;api_key&lt;/code&gt;, and &lt;code&gt;ip&lt;/code&gt; is &lt;code&gt;null&lt;/code&gt; when no address was captured. The dashboard shows that case as ‘IP unknown’.&lt;/p&gt;

&lt;p&gt;vatnode support can also read a user’s security events through admin tooling. Access to production systems is limited to authorised personnel, as the privacy policy describes.&lt;/p&gt;

&lt;h2&gt;
  
  
  How long it is kept
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Log&lt;/th&gt;
&lt;th&gt;IP address and user agent&lt;/th&gt;
&lt;th&gt;Rows&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Security events&lt;/td&gt;
&lt;td&gt;Removed after 30 days&lt;/td&gt;
&lt;td&gt;Deleted after one year&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Audit log&lt;/td&gt;
&lt;td&gt;IP removed after 30 days&lt;/td&gt;
&lt;td&gt;Deleted after one year&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For security events, the 30-day removal applies to sign-ins recorded with an IP address. A daily job at 03:00 UTC applies both periods. They cover these two logs only; they are not a general statement about every IP address vatnode ever sees. If you delete your account, the security events and audit entries are de-linked from it when the account record is purged. That happens 30 days after the deletion request, or later if a payment still has to be reconciled first.&lt;/p&gt;

&lt;p&gt;The legal basis is legitimate interests under Art. 6(1)(f) GDPR: account security, fraud prevention, and enabling customers to demonstrate compliance in their own audit trails. The &lt;a href="https://vatnode.dev/legal/privacy" rel="noopener noreferrer"&gt;privacy policy&lt;/a&gt; is the authoritative text. The &lt;a href="https://vatnode.dev/legal/dpa" rel="noopener noreferrer"&gt;DPA&lt;/a&gt; and the &lt;a href="https://vatnode.dev/legal/subprocessors" rel="noopener noreferrer"&gt;subprocessor list&lt;/a&gt; cover the processing side, and rights requests go to &lt;a href="mailto:privacy@vatnode.dev"&gt;privacy@vatnode.dev&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which emails vatnode sends
&lt;/h2&gt;

&lt;p&gt;The new sign-in email has the subject ‘New sign-in to your vatnode account’. It goes out when a sign-in comes from an IP address that does not appear in your account’s sign-ins over the previous 30 days. The lookback matches the retention, so the comparison runs against the addresses vatnode still holds. It is not sent when no earlier sign-in is on record, such as your very first sign-in, where the welcome email goes out instead. The email shows the time in UTC, the IP address and the raw device and browser string, with a button to your API keys.&lt;/p&gt;

&lt;p&gt;Creating a live key or revoking a key also sends an email, with the key’s label, its last four characters and the IP address. That email is covered in &lt;a href="https://vatnode.dev/blog/structuring-api-keys-across-teams" rel="noopener noreferrer"&gt;structuring vatnode API keys across teams&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do about an unexpected event
&lt;/h2&gt;

&lt;p&gt;vatnode has no passwords. Whoever controls your email inbox, or your Google or GitHub account, can sign in as you, so start there.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Secure the inbox and the Google or GitHub account you sign in with.&lt;/li&gt;
&lt;li&gt;On the &lt;a href="https://vatnode.dev/dashboard/settings" rel="noopener noreferrer"&gt;Security&lt;/a&gt; page, press ‘Sign out other devices’. It ends every other session and keeps the one you are using, whereas signing out normally ends only the browser you are in. Then write to &lt;a href="mailto:mail@vatnode.dev"&gt;mail@vatnode.dev&lt;/a&gt; with the event you saw.&lt;/li&gt;
&lt;li&gt;Open &lt;a href="https://vatnode.dev/dashboard/api-keys" rel="noopener noreferrer"&gt;API keys&lt;/a&gt; and revoke any live key you did not create. Live keys are stored as hashes and shown in full only once, at creation, so keys you created earlier cannot be read back from the dashboard.&lt;/li&gt;
&lt;li&gt;List your webhooks with &lt;code&gt;GET /v1/webhooks&lt;/code&gt;, using one of your own live keys (test keys are not accepted there), and delete any you did not add, or whose URL you did not set, with &lt;code&gt;DELETE /v1/webhooks/{id}&lt;/code&gt;. The VAT monitoring page shows only one webhook, so one added later does not appear there.&lt;/li&gt;
&lt;li&gt;Check your &lt;a href="https://vatnode.dev/dashboard/vat-monitoring" rel="noopener noreferrer"&gt;VAT monitoring&lt;/a&gt; subscriptions and the alert email address there.&lt;/li&gt;
&lt;li&gt;Check the requester VAT in &lt;a href="https://vatnode.dev/dashboard/account" rel="noopener noreferrer"&gt;Account details&lt;/a&gt;, and your plan and billing details.&lt;/li&gt;
&lt;li&gt;Regenerate the test key.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Using this in a vendor review
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Reviewer question&lt;/th&gt;
&lt;th&gt;Answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Are sign-ins and key changes logged?&lt;/td&gt;
&lt;td&gt;Yes, see the first table.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Are failed sign-ins and logouts logged?&lt;/td&gt;
&lt;td&gt;No. Neither are requests for a sign-in link or code.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can the customer see the log?&lt;/td&gt;
&lt;td&gt;Yes, the latest 20 events on the Security page. vatnode support can read it too.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can the log be exported or scripted?&lt;/td&gt;
&lt;td&gt;Not through the API. The endpoint accepts a dashboard session only, and API keys do not work on it. A copy of your personal data, including these logs, can be requested from &lt;a href="mailto:privacy@vatnode.dev"&gt;privacy@vatnode.dev&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Is the customer alerted?&lt;/td&gt;
&lt;td&gt;Yes, by email for a sign-in from an IP address not seen in the previous 30 days, for a new live key and for a revoked key.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;How long are IP addresses kept?&lt;/td&gt;
&lt;td&gt;In these two logs, 30 days; rows are deleted after one year.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What happens on account deletion?&lt;/td&gt;
&lt;td&gt;Security events and audit entries are de-linked when the account record is purged, 30 days after the request or later if a payment is still being reconciled.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Passwords?&lt;/td&gt;
&lt;td&gt;None. Sign-in is Google, GitHub or an emailed link or code, so account security rests on those.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Legal basis and processors?&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://vatnode.dev/legal/privacy" rel="noopener noreferrer"&gt;Privacy policy&lt;/a&gt;, &lt;a href="https://vatnode.dev/legal/dpa" rel="noopener noreferrer"&gt;DPA&lt;/a&gt;, &lt;a href="https://vatnode.dev/legal/subprocessors" rel="noopener noreferrer"&gt;subprocessors&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Where is VAT check evidence?&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://vatnode.dev/blog/exporting-vat-check-history-for-audit" rel="noopener noreferrer"&gt;Exporting VAT check history for audit&lt;/a&gt;, &lt;a href="https://vatnode.dev/guides/vat-audit-trail" rel="noopener noreferrer"&gt;VAT audit trail&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For how check data is stored, see &lt;a href="https://vatnode.dev/blog/gdpr-vat-data-storage" rel="noopener noreferrer"&gt;GDPR and VAT data storage&lt;/a&gt;. Every vatnode account has the Security page, Free included. After you &lt;a href="https://vatnode.dev/register" rel="noopener noreferrer"&gt;register&lt;/a&gt;, the ‘Recent activity’ card shows your account creation and first sign-in straight away. How keys are issued and sent is in the &lt;a href="https://vatnode.dev/docs/authentication" rel="noopener noreferrer"&gt;authentication docs&lt;/a&gt;, and &lt;a href="https://vatnode.dev/pricing" rel="noopener noreferrer"&gt;pricing&lt;/a&gt; lists how many keys each plan allows.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What does vatnode log about my account activity?
&lt;/h3&gt;

&lt;p&gt;Account creation, every sign-in, every use of ‘Sign out other devices’, the creation of a live API key and the revocation of a key. Sign-ins and sign-outs of other devices store the time, IP address and user agent. Key events store the IP address, and a creation also stores the key label. Logouts, failed sign-ins and requests for a sign-in link or code are not recorded.&lt;/p&gt;

&lt;h3&gt;
  
  
  How long do vatnode’s account activity logs keep IP addresses and user agents?
&lt;/h3&gt;

&lt;p&gt;For sign-ins recorded with an IP address, the IP and user agent are removed after 30 days, and the event row itself is deleted after one year. In the audit log that holds API key changes, the IP is removed after 30 days and the rows are deleted after one year. These periods apply to those two logs only.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does vatnode send an email when someone signs in from a new device?
&lt;/h3&gt;

&lt;p&gt;It sends one when a sign-in comes from an IP address that has not appeared in your account sign-ins during the previous 30 days. The trigger is the IP address, not the device, so the same browser on a new network triggers it and a new browser on a known network does not. It is not sent when no earlier sign-in is on record, such as your very first sign-in.&lt;/p&gt;

&lt;h3&gt;
  
  
  What should I do if I see a sign-in I don’t recognise?
&lt;/h3&gt;

&lt;p&gt;Secure the email inbox and the Google or GitHub account you sign in with, because vatnode has no passwords, then press ‘Sign out other devices’ on the &lt;a href="https://vatnode.dev/dashboard/settings" rel="noopener noreferrer"&gt;Security&lt;/a&gt; page and write to &lt;a href="mailto:mail@vatnode.dev"&gt;mail@vatnode.dev&lt;/a&gt;. Revoke any live API key you did not create, delete webhooks you did not add or whose URL you did not set, check monitoring subscriptions and the alert email address, the requester VAT and your plan and billing details, and regenerate the test key.&lt;/p&gt;

</description>
      <category>tax</category>
      <category>tutorial</category>
      <category>api</category>
      <category>webdev</category>
    </item>
    <item>
      <title>One API Key or Many? Structuring vatnode Access</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Sat, 21 Nov 2026 10:00:48 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/one-api-key-or-many-structuring-vatnode-access-59lo</link>
      <guid>https://dev.to/iurii_rogulia/one-api-key-or-many-structuring-vatnode-access-59lo</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published at &lt;a href="https://vatnode.dev/blog/structuring-api-keys-across-teams" rel="noopener noreferrer"&gt;vatnode.dev&lt;/a&gt;. The version on vatnode.dev is the canonical source — refer to it for the latest content.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Short answer: use one live key per service and environment, give each a descriptive label, and treat the key list as an inventory you can revoke from one entry at a time. That gives you attribution and clean rotation, but not isolation: every key on an account shares the same permissions, quota and billing.&lt;/p&gt;

&lt;p&gt;The Free plan includes one live key and the test key, so you can &lt;a href="https://vatnode.dev/register" rel="noopener noreferrer"&gt;register&lt;/a&gt; and try the layout before you pick a plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  One key per service, and what that buys you
&lt;/h2&gt;

&lt;p&gt;A vatnode account can hold several live keys (&lt;code&gt;vat_live_…&lt;/code&gt;), and the number depends on your plan. Splitting them by service, such as checkout, back office and a nightly job, gives you three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Independent revocation.&lt;/strong&gt; If one key leaks or a service is retired, you revoke that key and nothing else stops.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rotation without downtime.&lt;/strong&gt; You can create the replacement, deploy it and only then revoke the old key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attribution.&lt;/strong&gt; Every check in your history records the label of the key that ran it, so a surprising spike in usage points at a service, not just an account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keys are sent as a bearer token, as described in &lt;a href="https://vatnode.dev/docs/authentication" rel="noopener noreferrer"&gt;authentication&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.vatnode.dev/v1/vat/&lt;span class="o"&gt;{&lt;/span&gt;vatId&lt;span class="o"&gt;}&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Authorization: Bearer vat_live_YOUR_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;{vatId}&lt;/code&gt; with a real VAT number. A live key runs a real check, so it rejects the &lt;code&gt;XX&lt;/code&gt; test numbers with &lt;code&gt;400 INVALID_FORMAT&lt;/code&gt;, and that uses no quota.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a key is in vatnode and what’s shared across the account
&lt;/h2&gt;

&lt;p&gt;A live key is a credential plus a label. It is shown in full once, when you create it, and vatnode stores only a hash of it. The dashboard keeps the label, the last four characters, the creation date and a ‘Last used’ date, which is updated on every authenticated request.&lt;/p&gt;

&lt;p&gt;Everything else belongs to the account:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Per key&lt;/th&gt;
&lt;th&gt;Account-wide&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The secret itself&lt;/td&gt;
&lt;td&gt;Monthly quota and overage (one pool for all live keys)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Label&lt;/td&gt;
&lt;td&gt;Plan and billing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Created date and ‘Last used’&lt;/td&gt;
&lt;td&gt;Requester VAT, when set, applied to every live check&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Revocation&lt;/td&gt;
&lt;td&gt;Webhooks and VAT monitoring subscriptions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Label on each check in the history&lt;/td&gt;
&lt;td&gt;Check history and bulk jobs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So a key is a handle, not a boundary. Anything one live key creates, every other live key on the account can see and change.&lt;/p&gt;

&lt;h2&gt;
  
  
  What separate keys do not give you
&lt;/h2&gt;

&lt;p&gt;People coming from a team-oriented setup usually assume otherwise:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There are no scopes or permissions. Every live key can do everything the API allows for the account, including creating, listing and deleting webhooks and monitoring subscriptions, and listing, reading and cancelling any bulk job on the account, even one submitted with a different key.&lt;/li&gt;
&lt;li&gt;There are no per-key quotas, spending caps or rate limits. All live keys draw from the same monthly quota.&lt;/li&gt;
&lt;li&gt;There are no seats, roles, organizations or SSO. An account belongs to one user. Email, social sign-in and passkeys are ways for that user to sign in, not extra seats.&lt;/li&gt;
&lt;li&gt;Keys do not expire, and they are not rotated automatically.&lt;/li&gt;
&lt;li&gt;Labels cannot be renamed after creation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So separate keys are the right tool for ‘which service did this, and can I switch it off’, and the wrong tool for ‘this contractor may only run checks’. If you need the second, keep every key, the test key included, out of that person’s hands. Let them call your own service, and let that service hold the vatnode key.&lt;/p&gt;

&lt;h2&gt;
  
  
  A labeling pattern that survives the audit export
&lt;/h2&gt;

&lt;p&gt;A label is set once, at creation, and has to be 1 to 100 characters. It cannot be renamed, and labels are not unique, so nothing stops you from creating two keys called &lt;code&gt;api&lt;/code&gt;. Pick the label as if it were permanent, because it lands in every history row and every export.&lt;/p&gt;

&lt;p&gt;A pattern that holds up is &lt;code&gt;service-environment&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;checkout-prod&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;backoffice-prod&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nightly-reconcile-prod&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;checkout-staging&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The label travels with the check. When you export your history, each row has a &lt;code&gt;keyLabel&lt;/code&gt; column, so ‘which service ran this validation’ is answered by a column rather than by memory. The export itself is covered in &lt;a href="https://vatnode.dev/blog/exporting-vat-check-history-for-audit" rel="noopener noreferrer"&gt;exporting VAT check history for audit&lt;/a&gt;. If a service moves or gets renamed, create a new key with the new label and revoke the old one. Past checks keep the old label, which is what an audit trail should do.&lt;/p&gt;

&lt;h2&gt;
  
  
  A worked layout: one key per service and environment
&lt;/h2&gt;

&lt;p&gt;A layout for a small company that validates VAT numbers at checkout, in a back-office tool and in a nightly job might look like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Where it runs&lt;/th&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Checkout service, prod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;checkout-prod&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Back-office tool, prod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;backoffice-prod&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nightly job, prod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;nightly-reconcile-prod&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Local development and CI&lt;/td&gt;
&lt;td&gt;the account test key&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The test key (&lt;code&gt;vat_test_…&lt;/code&gt;) works differently. There is exactly one per account, created at signup. It runs checks only against the reserved &lt;code&gt;XX&lt;/code&gt; fixture numbers, makes no VIES call, uses no quota and writes nothing to your history. Webhooks and subscriptions reject it with &lt;code&gt;403 TEST_KEY_NOT_ALLOWED&lt;/code&gt;, and it does not count against your live key limit. It still authenticates as your account, so it is not a throwaway value. Regenerating it kills the old one immediately, with no overlap. The fixtures are listed in &lt;a href="https://vatnode.dev/docs/test-mode" rel="noopener noreferrer"&gt;test mode&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.vatnode.dev/v1/vat/XX0000001 \
  -H &lt;span class="s2"&gt;"Authorization: Bearer vat_test_YOUR_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Treat it like any other credential. A few rules apply to every key, test or live:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Never put a key in browser or client-side code. Anything shipped to a browser can be read by anyone who opens the page. Call vatnode from your server.&lt;/li&gt;
&lt;li&gt;Load keys from environment variables or a secret manager.&lt;/li&gt;
&lt;li&gt;In CI, store the test key as a masked secret, not in the pipeline file or a shared &lt;code&gt;.env&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Keep keys out of source control, logs, error trackers and support tickets.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Rotating a key without downtime
&lt;/h2&gt;

&lt;p&gt;With a spare slot, rotation is four steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new key with a label that makes the generation clear, for example &lt;code&gt;checkout-prod-2&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Deploy it to the service.&lt;/li&gt;
&lt;li&gt;Open the key list and check that the new key shows a recent ‘Last used’ date and the old one has gone quiet.&lt;/li&gt;
&lt;li&gt;Revoke the old key.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you are rotating because a key leaked, skip the overlap: revoke it first and accept the short gap.&lt;/p&gt;

&lt;p&gt;On the Free plan, which allows one live key, there is no spare slot. Rotation there is revoke-then-create, and requests fail in the short gap between the two. If that matters, time it for a quiet moment. A plan with more than one live key removes the gap.&lt;/p&gt;

&lt;p&gt;Once revoked, a key answers &lt;code&gt;401 INVALID_API_KEY&lt;/code&gt;. The dashboard button is labeled ‘Delete’ and the key disappears from the list, but the checks it already ran stay in your history with their &lt;code&gt;keyLabel&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Revoking has one more effect. A bulk job running under that key is stopped and marked &lt;code&gt;cancelled&lt;/code&gt; with the error code &lt;code&gt;API_KEY_REVOKED&lt;/code&gt;. Positions that were already answered remain readable with another live key on the same account, and positions that never ran are never charged. If you rotate while a large job is in flight, either wait for it to finish or accept a partial result. The submit-and-poll flow is described in &lt;a href="https://vatnode.dev/docs/bulk-vat-validation" rel="noopener noreferrer"&gt;bulk VAT validation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How many keys your plan allows
&lt;/h2&gt;

&lt;p&gt;The limit applies to active live keys, and it differs by plan. See &lt;a href="https://vatnode.dev/pricing" rel="noopener noreferrer"&gt;pricing&lt;/a&gt; for the current numbers. Creating a key past the limit returns &lt;code&gt;422 KEY_LIMIT_REACHED&lt;/code&gt;. Revoking a key frees its slot straight away, so the limit counts keys that currently work, not keys you ever made. The test key is not counted.&lt;/p&gt;

&lt;p&gt;If you hit the limit, you can merge two low-traffic services onto one key, which costs you attribution between those two and nothing else, or move to a plan with more keys.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create and revoke are logged
&lt;/h2&gt;

&lt;p&gt;Creating or revoking a live key sends a security email to the account address with the key’s label, its last four characters and the IP address the action came from. The same events appear in the security events list in the dashboard. If you get an email for a key you did not create or delete, treat it as unauthorized access to your login and secure the login first. Then revoke any key you do not recognize, regenerate the test key, and check your webhooks and monitoring subscriptions for endpoints you did not add.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting it up
&lt;/h2&gt;

&lt;p&gt;Create a labeled key for each service in &lt;a href="https://vatnode.dev/dashboard/api-keys" rel="noopener noreferrer"&gt;your dashboard&lt;/a&gt;, deploy it, and watch ‘Last used’ confirm it is live. If you do not have an account yet, &lt;a href="https://vatnode.dev/register" rel="noopener noreferrer"&gt;register&lt;/a&gt;: the test key is created at signup.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Should I use one API key or several?
&lt;/h3&gt;

&lt;p&gt;Several, one per service and environment, as long as your plan allows it. Separate keys give you independent revocation, rotation without downtime, and a label on every check in your history. They do not give you separate permissions, quotas or billing, because all of that belongs to the account.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I limit a key to certain actions or a quota?
&lt;/h3&gt;

&lt;p&gt;No. Every live key can do everything the API allows for the account, and all live keys draw from the same monthly quota. There are no per-key scopes, quotas, caps or rate limits.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I know which key made a check?
&lt;/h3&gt;

&lt;p&gt;Each check in your history carries the label of the key that ran it, in the keyLabel column of the history and of the CSV export. The Last used date on each key in the dashboard shows which keys are still active.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens to running bulk jobs when I revoke a key?
&lt;/h3&gt;

&lt;p&gt;Jobs submitted with that key stop with the status cancelled and the error code API_KEY_REVOKED. Positions already answered stay readable with another live key on the same account, and positions that were never answered are never charged.&lt;/p&gt;

</description>
      <category>tax</category>
      <category>webdev</category>
      <category>api</category>
    </item>
    <item>
      <title>GA4 Consent Mode Gap: Counting Sales It Hides</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Fri, 20 Nov 2026 11:01:17 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/ga4-consent-mode-gap-counting-sales-it-hides-30hd</link>
      <guid>https://dev.to/iurii_rogulia/ga4-consent-mode-gap-counting-sales-it-hides-30hd</guid>
      <description>&lt;p&gt;Short answer: you cannot measure the GA4 consent gap from inside GA4, but you can measure it from Stripe. Every succeeded checkout PaymentIntent is a real paid order. If you write the analytics identifiers onto the PaymentIntent metadata at checkout, you can replay your own ‘was this sent to GA4?’ rule over those orders and count how many fell out. No GA4 Data API, no read credentials for Google.&lt;/p&gt;

&lt;p&gt;I did this for pi-pi.ee, a Next.js and Stripe store whose analytics I built. The tool is a one-off, read-only script. This article walks through the method, the code and, mostly, the ways the output can mislead you. The article contains no results from the script; what the numbers look like depends entirely on your traffic and your banner.&lt;/p&gt;

&lt;p&gt;My earlier post on &lt;a href="https://iurii.rogulia.fi/blog/server-side-tracking-ga4-meta" rel="noopener noreferrer"&gt;server-side tracking for GA4 and Meta&lt;/a&gt; describes the Pikkuna platform, a different system. This one is about a setup where server-side sending exists but is deliberately limited.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the gap is invisible inside GA4
&lt;/h2&gt;

&lt;p&gt;Google Consent Mode has two implementations. Per Google’s &lt;a href="https://support.google.com/analytics/answer/9976101" rel="noopener noreferrer"&gt;Analytics Help page on consent mode&lt;/a&gt;, in the advanced one Google tags load before the consent dialog and send cookieless pings when consent is declined, and behavioural modelling can fill gaps. In the basic one tags are blocked until consent is granted, so nothing is collected before that.&lt;/p&gt;

&lt;p&gt;This store is set up like the basic one. The inline default sets &lt;code&gt;analytics_storage&lt;/code&gt; and the ad signals to &lt;code&gt;denied&lt;/code&gt; and loads nothing from Google; &lt;code&gt;gtag.js&lt;/code&gt; is injected only after the visitor grants a category. For a buyer who grants nothing there is no &lt;code&gt;_ga&lt;/code&gt; cookie, no server-side &lt;code&gt;purchase&lt;/code&gt; either (more on that below), and no cookieless ping. The order exists in Stripe and nowhere in GA4, and GA4 has no row that says ‘one order missing here’.&lt;/p&gt;

&lt;p&gt;One edge case: the banner callback loads &lt;code&gt;gtag.js&lt;/code&gt; when either analytics or marketing is granted. A visitor who grants marketing but declines analytics therefore loads gtag with &lt;code&gt;analytics_storage&lt;/code&gt; still denied, which can behave like the advanced setup. The script counts that buyer as unmeasured, because the ids are empty, even though Google may have received pings from them.&lt;/p&gt;

&lt;p&gt;There is a second layer. In this store the GA4 &lt;code&gt;purchase&lt;/code&gt; event is not sent from the browser at all: it goes out only from the Stripe webhook, through the GA4 Measurement Protocol. So the sender’s rule is the only route a purchase has into GA4, and it returns early when there is no GA identity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// sendMpEvent() in mp.ts, trimmed&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clientId&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;sessionId&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Skipping MP event: no analytics consent"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Skipping the server-side send for those buyers is a deliberate decision in this codebase, not an oversight. It means the server-side send covers only buyers who already have a GA identity, and buyers without one stay invisible to GA4 by design. That is why you measure them against something else. For the consent background itself, see &lt;a href="https://iurii.rogulia.fi/blog/privacy-first-analytics-gdpr" rel="noopener noreferrer"&gt;GDPR analytics without a cookie banner&lt;/a&gt;; I will not repeat it, and nothing here is a legal conclusion either way.&lt;/p&gt;

&lt;h2&gt;
  
  
  The method: replay the gate
&lt;/h2&gt;

&lt;p&gt;The two identifiers are read in the browser at checkout and only when analytics consent is stored:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;extractClientId()&lt;/code&gt; returns &lt;code&gt;""&lt;/code&gt; unless analytics consent is stored and a parseable &lt;code&gt;_ga&lt;/code&gt; cookie exists.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;extractSessionId()&lt;/code&gt; does the same for the per-property session cookie.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both values go to the server with the checkout request, and the order-preparation code stamps them onto the PaymentIntent metadata next to the attribution fields:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// prepare-order.ts, metadata (trimmed)&lt;/span&gt;
&lt;span class="n"&gt;gaClientId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;gaClientId&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;gaSessionId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;gaSessionId&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;attrSource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;attribution&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;attribution&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the same condition that decides whether the server sends to GA4 is persisted on the payment. That gives a clean equivalence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;measured in GA4  &amp;lt;=&amp;gt;  gaClientId !== "" &amp;amp;&amp;amp; gaSessionId !== ""
unmeasured       &amp;lt;=&amp;gt;  otherwise
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You do not need to ask Google anything. You re-evaluate the gate against the ground truth.&lt;/p&gt;

&lt;h2&gt;
  
  
  The script
&lt;/h2&gt;

&lt;p&gt;It is read-only: it lists PaymentIntents and never writes. It prefers a live Stripe key and falls back to &lt;code&gt;STRIPE_SECRET_KEY&lt;/code&gt;. The window is &lt;code&gt;--days=N&lt;/code&gt; (default 30) or &lt;code&gt;--month=YYYY-MM&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The gate, copied over from the sender:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isMeasured&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Stripe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;PaymentIntent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gaClientId&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gaSessionId&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;pi&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;stripe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;paymentIntents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;created&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;gte&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;win&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gte&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;win&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lt&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;"succeeded"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// A real order always carries an orderNumber (stamped at PaymentIntent creation).&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;orderNumber&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customerEmail&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="no"&gt;SKIP_EMAILS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customerEmail&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;measured&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;isMeasured&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;gross&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount_received&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;attrSource&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;"direct"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// ...add to the total bucket and the per-source bucket&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three filters decide what counts as an order: status &lt;code&gt;succeeded&lt;/code&gt;, a non-empty &lt;code&gt;orderNumber&lt;/code&gt; in the metadata (so stray PaymentIntents from other flows are excluded), and a small set of internal test emails whose test checkouts would otherwise skew the ratio. &lt;code&gt;for await&lt;/code&gt; over &lt;code&gt;list()&lt;/code&gt; lets the Stripe SDK paginate for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading the output
&lt;/h2&gt;

&lt;p&gt;The script prints to stderr, in three blocks:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Block&lt;/th&gt;
&lt;th&gt;What it reports&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Totals&lt;/td&gt;
&lt;td&gt;Paid orders, how many have both ids, how many do not, gross amount of the unmeasured ones&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;By traffic source&lt;/td&gt;
&lt;td&gt;Per &lt;code&gt;attrSource&lt;/code&gt; bucket: paid, measured, unmeasured, share unmeasured&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Closing line&lt;/td&gt;
&lt;td&gt;The paid-to-measured ratio, as a multiplier for the purchases GA4 can have received&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;It also handles the edge cases: no paid orders in the window prints a message, and zero measured orders prints that none of the paid orders carry a GA identity for the period instead of dividing by zero.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations: how the number can mislead
&lt;/h2&gt;

&lt;p&gt;I would rather you distrust the output in the right places than trust it in the wrong ones.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;‘Measured’ is an upper bound.&lt;/strong&gt; Non-empty ids only mean the Measurement Protocol send was attempted. The sender swallows fetch errors with a warning, never checks the response, and returns early if the API secret is missing. An order can be ‘measured’ here and absent in GA4.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ad blockers count as unmeasured.&lt;/strong&gt; A consenting buyer whose blocker stops gtag also has empty ids. The script cannot tell ‘declined consent’ from ‘blocked gtag’; the bucket is ‘no GA identity at checkout’.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Amounts are gross.&lt;/strong&gt; The script sums &lt;code&gt;amount_received&lt;/code&gt;. Refunds are not subtracted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The window uses &lt;code&gt;created&lt;/code&gt;.&lt;/strong&gt; The filter is on PaymentIntent creation time, not on when it succeeded. An intent created just before a boundary and paid just after lands in the earlier window.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The per-source table is a consent artefact.&lt;/strong&gt; Attribution is stored and read only with marketing consent: &lt;code&gt;readAttribution()&lt;/code&gt; returns &lt;code&gt;null&lt;/code&gt; otherwise, and the &lt;code&gt;pp_attr&lt;/code&gt; cookie is in the marketing cookie list. So &lt;code&gt;attrSource&lt;/code&gt; is empty without marketing consent, and the script buckets every empty value as ‘direct’. The ‘direct’ row therefore mixes truly direct buyers with buyers who gave no marketing consent. A buyer with analytics consent but no marketing consent is measured, yet shows up as direct. Read the by-source table as a picture of consent, not of channels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The multiplier is crude.&lt;/strong&gt; The closing line scales the measured purchases (the ones GA4 can have received) by paid divided by measured. That assumes unmeasured buyers behave like measured ones, and there is no reason to believe that: people who decline tracking may differ in what they buy and how they arrived. Use it for orders of magnitude, not for reporting.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do with the number
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Treat Stripe as the revenue and order count.&lt;/strong&gt; Use GA4 for behaviour of the sample it can see. The script tells you how big that sample is relative to paid orders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Re-run it after you change the banner or the consent defaults.&lt;/strong&gt; The ratio is a property of your consent setup and traffic mix, so a change in either is a new measurement.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do not backfill GA4 from the unmeasured set.&lt;/strong&gt; In this codebase that is exactly what the skip prevents. Whether to change that is a policy question for you and your advisers; the number does not settle it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reconcile any second counter against Stripe too.&lt;/strong&gt; In this codebase the &lt;code&gt;purchase&lt;/code&gt; event is also sent server-side to a separate Umami instance, without the gate the Measurement Protocol sender has. I have not reconciled those counts against Stripe, so I do not treat them as measured. The privacy-first article above covers Umami for site traffic.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Adapting it to another stack
&lt;/h2&gt;

&lt;p&gt;The pattern is portable; the field names are not:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;At checkout, write every identifier your analytics gate depends on onto the payment object (Stripe metadata, or the equivalent on your processor). Write empty strings, not omissions, so ‘absent’ is explicit.&lt;/li&gt;
&lt;li&gt;Keep a single shared definition of ‘would this be sent?’. If the sender and the report disagree, the report is fiction. Ideally import the same function.&lt;/li&gt;
&lt;li&gt;Mark real orders with something you control (here, an order number) so you can exclude test and unrelated payments.&lt;/li&gt;
&lt;li&gt;Record only what you need. Stripe metadata is limited, and none of this requires personal data beyond what the checkout already holds.&lt;/li&gt;
&lt;li&gt;If your payment events arrive by webhook, the same metadata is available there. The &lt;a href="https://iurii.rogulia.fi/blog/stripe-webhooks-production" rel="noopener noreferrer"&gt;Stripe webhook article&lt;/a&gt; covers making that pipeline reliable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The store this came from is described in the &lt;a href="https://iurii.rogulia.fi/projects/pi-pi-b2b-ecommerce" rel="noopener noreferrer"&gt;pi-pi.ee case study&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;
  slug="e-commerce"&lt;br&gt;
  text="Not sure how many orders your analytics never sees? I keep Stripe the source of truth and measure tracking gaps instead of guessing."&lt;br&gt;
/&amp;gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Further reading:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://iurii.rogulia.fi/blog/server-side-tracking-ga4-meta" rel="noopener noreferrer"&gt;GA4 Server-Side Tracking + Meta CAPI in Next.js&lt;/a&gt; – server-side sending on a different system&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://iurii.rogulia.fi/blog/privacy-first-analytics-gdpr" rel="noopener noreferrer"&gt;GDPR Analytics Without a Cookie Banner: 4 Tools Compared&lt;/a&gt; – the consent background&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://iurii.rogulia.fi/blog/stripe-webhooks-production" rel="noopener noreferrer"&gt;Stripe Webhooks: Idempotency, Retries, and Queue Setup&lt;/a&gt; – getting payment events reliably&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://iurii.rogulia.fi/projects/pi-pi-b2b-ecommerce" rel="noopener noreferrer"&gt;pi-pi.ee – B2B E-commerce for Waterless Urinal Systems&lt;/a&gt; – the project&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nextjs</category>
      <category>typescript</category>
      <category>node</category>
      <category>stripe</category>
    </item>
    <item>
      <title>Checking PDFs in a Private S3 or R2 Bucket via Presigned URLs</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Fri, 20 Nov 2026 11:00:52 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/checking-pdfs-in-a-private-s3-or-r2-bucket-via-presigned-urls-4nna</link>
      <guid>https://dev.to/iurii_rogulia/checking-pdfs-in-a-private-s3-or-r2-bucket-via-presigned-urls-4nna</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published at &lt;a href="https://htpbe.tech/blog/check-pdf-private-bucket-presigned-url-tamper-detection" rel="noopener noreferrer"&gt;htpbe.tech&lt;/a&gt;. The version on htpbe.tech stays in sync with the latest detection algorithm — refer to it for the canonical text.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Your users upload loan applications and onboarding documents into a private bucket. The &lt;a href="https://htpbe.tech/api" rel="noopener noreferrer"&gt;HTPBE API&lt;/a&gt; takes a URL, not a file upload. So what do you send it without making the bucket public?&lt;/p&gt;

&lt;p&gt;Presign a &lt;code&gt;GET&lt;/code&gt; for the object, send that URL as &lt;code&gt;url&lt;/code&gt; in &lt;code&gt;POST /v1/analyze&lt;/code&gt;, and read the verdict with &lt;code&gt;GET /v1/result/{id}&lt;/code&gt;. The API downloads the file once, during the &lt;code&gt;POST&lt;/code&gt;, so the link only has to live for a few minutes. Below: what the URL has to satisfy, how long it should live, what each failure looks like and how to retry without paying twice or getting a &lt;code&gt;422&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For a full client in a specific language, the &lt;a href="https://htpbe.tech/blog/pdf-verification-nodejs-integration-guide" rel="noopener noreferrer"&gt;Node.js integration guide&lt;/a&gt; has a presign helper in Step 5, and the &lt;a href="https://htpbe.tech/blog/pdf-tamper-detection-python-tutorial" rel="noopener noreferrer"&gt;Python tutorial&lt;/a&gt; and &lt;a href="https://htpbe.tech/blog/pdf-verification-go-integration-guide" rel="noopener noreferrer"&gt;Go guide&lt;/a&gt; cover the same API end to end.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the API needs from the URL
&lt;/h2&gt;

&lt;p&gt;A presigned URL is an ordinary &lt;code&gt;https&lt;/code&gt; URL with the signature in the query string. The API treats it like any other URL, so nothing special is needed on your side, and the same general rules apply:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Downloadable without authentication headers.&lt;/strong&gt; You cannot pass headers for the download, so access has to come from the URL itself – which is exactly what the query-string signature does.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;http&lt;/code&gt; or &lt;code&gt;https&lt;/code&gt;.&lt;/strong&gt; Both are accepted. Use &lt;code&gt;https&lt;/code&gt;: the signature travels in the URL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No credentials in the URL.&lt;/strong&gt; A &lt;code&gt;user:pass@host&lt;/code&gt; URL is rejected with &lt;code&gt;400&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No redirects.&lt;/strong&gt; A &lt;code&gt;3xx&lt;/code&gt; response is not followed. Submit the final URL, not one that bounces.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;At most 10&amp;nbsp;MB.&lt;/strong&gt; Larger files return &lt;code&gt;413 file_too_large&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Downloaded within 30 seconds&lt;/strong&gt;, connection and full body together.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Content-Type does not matter.&lt;/strong&gt; S3’s default &lt;code&gt;application/octet-stream&lt;/code&gt; is fine. What matters is that the body is a PDF; anything else returns &lt;code&gt;422 invalid_pdf&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Presigning a GET for S3 and R2
&lt;/h2&gt;

&lt;p&gt;Keep it to the object you want checked and a short expiry. With the AWS SDK for JavaScript v3:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;S3Client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;GetObjectCommand&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@aws-sdk/client-s3'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;getSignedUrl&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@aws-sdk/s3-request-presigner'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// The bucket's own region – a mismatch sends S3 into a redirect or an error&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;S3Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;AWS_REGION&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'3f6c1e2a-8b4d-4c1f-9a7e-5d2b0c9e4f17.pdf'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;getSignedUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;GetObjectCommand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Bucket&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'my-private-docs'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;expiresIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With boto3, setting SigV4 explicitly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;botocore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Config&lt;/span&gt;

&lt;span class="n"&gt;s3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"s3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"eu-west-1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# the bucket's region&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signature_version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"s3v4"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_presigned_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"get_object"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;Params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Bucket"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"my-private-docs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"3f6c1e2a-8b4d-4c1f-9a7e-5d2b0c9e4f17.pdf"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;ExpiresIn&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Cloudflare R2&lt;/strong&gt; uses the same SDKs against its S3-compatible endpoint, &lt;code&gt;https://&amp;lt;ACCOUNT_ID&amp;gt;.r2.cloudflarestorage.com&lt;/code&gt;, with region &lt;code&gt;"auto"&lt;/code&gt; (the SDK needs a value, but R2 ignores it):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;r2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;S3Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'auto'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;endpoint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`https://${process.env.R2_ACCOUNT_ID}.r2.cloudflarestorage.com`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;accessKeyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;R2_ACCESS_KEY_ID&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;secretAccessKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;R2_SECRET_ACCESS_KEY&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// then presign exactly as above:&lt;/span&gt;
&lt;span class="c1"&gt;// getSignedUrl(r2, new GetObjectCommand({ Bucket, Key }), { expiresIn: 300 })&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In boto3 the equivalent is &lt;code&gt;endpoint_url=...&lt;/code&gt; plus &lt;code&gt;region_name="auto"&lt;/code&gt;; the &lt;code&gt;Config&lt;/code&gt; line above is for S3. One R2 detail: presigned URLs work on the S3 API domain only, not on a custom domain you attached to the bucket.&lt;/p&gt;

&lt;p&gt;Then send the URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// One key per signed URL: reuse it only if you resend that exact URL&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;randomUUID&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'https://api.htpbe.tech/v1/analyze'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'POST'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`Bearer ${process.env.HTPBE_API_KEY}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'Content-Type'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'application/json'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'Idempotency-Key'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;original_filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'bank-statement.pdf'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;AbortSignal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;60_000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// download up to 30 s, plus analysis; on abort, retry with the same key&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`HTPBE ${res.status} ${err?.code ?? 'unknown'}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// don't log the URL&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// then GET https://api.htpbe.tech/v1/result/{id}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;POST&lt;/code&gt; returns &lt;code&gt;201&lt;/code&gt; with the check &lt;code&gt;id&lt;/code&gt; and a &lt;code&gt;Location&lt;/code&gt; header. The analysis has already run by then; the verdict itself comes from &lt;code&gt;GET /v1/result/{id}&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How long should the link live?
&lt;/h2&gt;

&lt;p&gt;The API fetches the file once, inside the &lt;code&gt;POST&lt;/code&gt;, and never goes back for it. The download must finish within 30 seconds, so the link only has to outlive one request. We recommend about &lt;strong&gt;five minutes&lt;/strong&gt;: enough for the request and a retry or two with the same URL, and short enough that a leaked copy stops working soon. The API itself sets no minimum.&lt;/p&gt;

&lt;p&gt;A presigned URL is a bearer link. Anyone who holds it can fetch the object until it expires, without any other credential. A short expiry does not make the link private, and you cannot revoke it early short of deleting the object, denying access to it, or disabling the credential that signed it. It limits how long a leaked copy keeps working – in a log line, an error report, a browser history. That is the main reason not to presign for an hour ‘just in case’.&lt;/p&gt;

&lt;p&gt;Presign right before the call, not when the file is uploaded. A link signed at upload time and used from a backlog hours later fails with &lt;code&gt;400 download_failed&lt;/code&gt; (&lt;code&gt;HTTP 403: Forbidden&lt;/code&gt;). If you sign with temporary credentials (an IAM role on Lambda or ECS), the link also stops working when those credentials expire, even if &lt;code&gt;expiresIn&lt;/code&gt; is longer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the object key and filename neutral
&lt;/h2&gt;

&lt;p&gt;The URL path is visible to whoever handles the link, and the filename ends up in your check history – and on the result page, if you ever switch on a share link for that check. A few habits keep personal data out of the object key and the filename, and keep the link itself contained:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use an unguessable object key&lt;/strong&gt;, such as a UUID. Not &lt;code&gt;applicants/jane-doe/payslip-march.pdf&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pass a neutral &lt;code&gt;original_filename&lt;/code&gt;.&lt;/strong&gt; It is stored and returned as &lt;code&gt;filename&lt;/code&gt; in &lt;code&gt;GET /v1/result/{id}&lt;/code&gt; and &lt;code&gt;GET /v1/checks&lt;/code&gt;. Without it, the API uses the last path segment if it ends in &lt;code&gt;.pdf&lt;/code&gt;, otherwise &lt;code&gt;document.pdf&lt;/code&gt;. The query string is never used. Don’t put applicant names, other personal data, secrets or URLs in it; a document type like &lt;code&gt;bank-statement.pdf&lt;/code&gt; or your own internal reference is enough.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sign with a read-only credential, and don’t log the link.&lt;/strong&gt; The process that presigns only needs read access to the upload bucket or prefix: an IAM policy with &lt;code&gt;s3:GetObject&lt;/code&gt; on that prefix, or an R2 API token with Object Read only. Log the object key and the check &lt;code&gt;id&lt;/code&gt;, never the presigned URL itself.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What fails, and what to do
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What happened&lt;/th&gt;
&lt;th&gt;Response&lt;/th&gt;
&lt;th&gt;What to do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Link expired, signature invalid, or the signing credentials cannot read the object&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;400 download_failed&lt;/code&gt;, details &lt;code&gt;HTTP 403: Forbidden&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Re-sign and resend with a new &lt;code&gt;Idempotency-Key&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Object does not exist&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;400 download_failed&lt;/code&gt;, details &lt;code&gt;HTTP 404: Not Found&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Check the bucket and key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Presigned against the wrong region or endpoint&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;400 download_failed&lt;/code&gt;, typically &lt;code&gt;HTTP 3xx: redirects are not followed&lt;/code&gt; or another &lt;code&gt;HTTP 4xx&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Presign against the bucket’s own region (R2: the account endpoint)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Download took longer than 30&amp;nbsp;s&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;400 download_failed&lt;/code&gt;, details &lt;code&gt;Download timed out&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Retry once with the same URL and key while the link is valid; if it keeps timing out, check that the endpoint responds promptly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Host unreachable&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;400 download_failed&lt;/code&gt;, details &lt;code&gt;Network error&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Check the endpoint&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typo in the host, or a URL the API cannot accept&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;400 download_failed&lt;/code&gt; or &lt;code&gt;400 invalid_url_format&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Fix the URL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;File over 10&amp;nbsp;MB&lt;/td&gt;
&lt;td&gt;&lt;code&gt;413 file_too_large&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The file cannot be checked as sent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sent with a test key (&lt;code&gt;htpbe_test_…&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;403 test_url_required&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Test keys accept only the documented test URLs; a presigned URL needs a live key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Body is not a PDF&lt;/td&gt;
&lt;td&gt;&lt;code&gt;422 invalid_pdf&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Check what is actually stored under that key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Same key resent while the first request is still running&lt;/td&gt;
&lt;td&gt;&lt;code&gt;409 idempotency_key_in_progress&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Wait, then retry with the same key&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Apart from a timeout or a network error, treat both &lt;code&gt;400&lt;/code&gt; codes the same way in code: the URL or its endpoint needs fixing before you retry. Don’t branch on the difference between them.&lt;/p&gt;

&lt;p&gt;None of these costs anything. From the API reference: ‘A request that ends in an error and returns no result uses nothing.’ An expired link, a &lt;code&gt;404&lt;/code&gt; or an oversized file returns no result, so it uses no credit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Retrying without a 422
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;Idempotency-Key&lt;/code&gt; header protects you from paying twice when a connection drops mid-request. The key is bound to the &lt;code&gt;url&lt;/code&gt; it was first sent with, and a presigned URL changes every time you sign it. The API reference is explicit: the same key with a &lt;strong&gt;different&lt;/strong&gt; &lt;code&gt;url&lt;/code&gt; is rejected with &lt;code&gt;422 idempotency_key_fingerprint_mismatch&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reuse the key only when you resend the exact same URL string&lt;/strong&gt; – a timeout or dropped connection while the link is still valid. You get the original &lt;code&gt;id&lt;/code&gt; back if the first attempt completed, a &lt;code&gt;409 idempotency_key_in_progress&lt;/code&gt; if it is still running (wait and retry with the same key – a new key would start a second, separately charged analysis), and a normal new analysis if it failed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;After re-signing, send a new key.&lt;/strong&gt; The failed attempt returned no result and used nothing, so there is nothing to protect. Reusing the old key with the new URL only buys you a &lt;code&gt;422&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A new key always means a new analysis, and the docs spell out the cost:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Submitting the file again&lt;/strong&gt; – with no &lt;code&gt;Idempotency-Key&lt;/code&gt; or with a new one – is a new analysis. It may use another credit or quota unit under the same rules as the first, including when the earlier result was &lt;code&gt;analysis_incomplete&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So if a check came back &lt;code&gt;inconclusive&lt;/code&gt; with &lt;code&gt;status_reason: "analysis_incomplete"&lt;/code&gt;, sending it again with a fresh link and key is a second analysis that may use another credit, not a free retry. To avoid re-checking a file you already have a result for, store the check &lt;code&gt;id&lt;/code&gt; against your object key and read the result back instead. Reading a result never uses a credit. For queue workers, keys per job and dedup of the same file arriving twice, see &lt;a href="https://htpbe.tech/blog/batch-pdf-verification-queue-async" rel="noopener noreferrer"&gt;running checks from a queue&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The natural place for all of this is the upload event itself: object created → presign → analyse → store the &lt;code&gt;id&lt;/code&gt;. The &lt;a href="https://htpbe.tech/blog/pdf-verification-webhook-event-driven-integration" rel="noopener noreferrer"&gt;event-driven integration post&lt;/a&gt; walks through that pipeline.&lt;/p&gt;

&lt;h2&gt;
  
  
  What HTPBE keeps from the URL
&lt;/h2&gt;

&lt;p&gt;For an external URL like a presigned link, we keep the host, not the path or the signature. The URL is not returned in any API response. The filename is stored – the &lt;code&gt;original_filename&lt;/code&gt; you send, or the last path segment if you don’t – which is why both should be neutral. If your vendor assessment needs more than that, the &lt;a href="https://htpbe.tech/blog/pdf-fraud-api-data-handling-security-review" rel="noopener noreferrer"&gt;questions a security review asks of a PDF fraud API&lt;/a&gt; are worth working through.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading the result
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;status&lt;/code&gt; is &lt;code&gt;intact&lt;/code&gt;, &lt;code&gt;modified&lt;/code&gt; or &lt;code&gt;inconclusive&lt;/code&gt;. Route &lt;code&gt;modified&lt;/code&gt; to human review, never to automatic rejection. &lt;code&gt;inconclusive&lt;/code&gt; means the available evidence cannot support a conclusive result; it is not an adverse signal and must not trigger an automatic rejection. &lt;code&gt;usage_caution.recommended_action&lt;/code&gt; is &lt;code&gt;request_from_issuer&lt;/code&gt; for every &lt;code&gt;inconclusive&lt;/code&gt; result, and &lt;code&gt;usage_caution.safe_for_automated_adverse_decision&lt;/code&gt; is always &lt;code&gt;false&lt;/code&gt;. &lt;code&gt;intact&lt;/code&gt; means no structural modification was detected; it is not proof that the contents are true. &lt;a href="https://htpbe.tech/blog/handling-pdf-verification-verdicts-in-code" rel="noopener noreferrer"&gt;Handling verdicts in code&lt;/a&gt; covers the branches in full.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to go next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Building the client: &lt;a href="https://htpbe.tech/blog/pdf-verification-nodejs-integration-guide" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt;, &lt;a href="https://htpbe.tech/blog/pdf-tamper-detection-python-tutorial" rel="noopener noreferrer"&gt;Python&lt;/a&gt;, &lt;a href="https://htpbe.tech/blog/pdf-verification-go-integration-guide" rel="noopener noreferrer"&gt;Go&lt;/a&gt;; see also &lt;a href="https://htpbe.tech/blog/pdf-verification-rust-integration-guide" rel="noopener noreferrer"&gt;Rust&lt;/a&gt;, &lt;a href="https://htpbe.tech/blog/pdf-verification-ruby-on-rails-integration-guide" rel="noopener noreferrer"&gt;Rails&lt;/a&gt; and &lt;a href="https://htpbe.tech/blog/pdf-tamper-detection-nextjs-api-routes" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Large files in Node without buffering them whole: &lt;a href="https://htpbe.tech/blog/node-large-pdfs-without-unbounded-buffering" rel="noopener noreferrer"&gt;Large PDFs in Node.js&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Many files at once: &lt;a href="https://htpbe.tech/blog/batch-pdf-verification-queue-async" rel="noopener noreferrer"&gt;running checks from a queue&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HTPBE checks whether a PDF’s structure shows signs of modification. It sits alongside your upload and review workflow and your KYC, not in place of them. Read the &lt;a href="https://htpbe.tech/api" rel="noopener noreferrer"&gt;API reference&lt;/a&gt;; live keys are created from your dashboard after sign-up.&lt;/p&gt;

&lt;p&gt;Related FAQ: &lt;a href="https://htpbe.tech/faq/how-long-does-pdf-analysis-take" rel="noopener noreferrer"&gt;How long does PDF analysis take?&lt;/a&gt; · &lt;a href="https://htpbe.tech/faq/what-happens-to-uploaded-pdf-file" rel="noopener noreferrer"&gt;What happens to my uploaded PDF file after analysis?&lt;/a&gt;&lt;/p&gt;

</description>
      <category>pdf</category>
      <category>tutorial</category>
      <category>api</category>
      <category>webdev</category>
    </item>
    <item>
      <title>AI Translation Pipeline: Validators Around a gpt-4o Call</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Wed, 18 Nov 2026 11:01:06 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/ai-translation-pipeline-validators-around-a-gpt-4o-call-27cd</link>
      <guid>https://dev.to/iurii_rogulia/ai-translation-pipeline-validators-around-a-gpt-4o-call-27cd</guid>
      <description>&lt;p&gt;An AI translation pipeline needs checks that can say ‘no’ more than it needs a better prompt. In the script that fills the 27 target languages of &lt;a href="https://iurii.rogulia.fi/projects/pi-pi-b2b-ecommerce" rel="noopener noreferrer"&gt;pi-pi.ee&lt;/a&gt;, the model call is one request per batch, and two sets of gates surround it. At write time: a diff of missing keys, a check on whether the reply was cut off, an ICU and plural validator that must pass before a string is written, and exit code 1 with a list of what was left out. At commit time: &lt;code&gt;i18n:check&lt;/code&gt; and &lt;code&gt;glossary:check&lt;/code&gt;, which run as part of &lt;code&gt;npm run lint&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Below is that code as it stands, the real defects behind some of the gates, and a section on what the gates still do not catch. Routing, hreflang and formatting are in &lt;a href="https://iurii.rogulia.fi/blog/nextjs-i18n-30-languages" rel="noopener noreferrer"&gt;Next.js i18n with 30 Languages&lt;/a&gt;; I will not repeat them.&lt;/p&gt;

&lt;h2&gt;
  
  
  One good prompt is not a pipeline
&lt;/h2&gt;

&lt;p&gt;The shop has a Russian source file and 27 generated locales. The first version of any such script sends strings to a model and saves the reply. It works on the first run and fails later, quietly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A valid-looking string with a broken shape.&lt;/strong&gt; A placeholder renamed, a tag dropped, an ICU plural missing a branch the target language needs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Batches that disagree.&lt;/strong&gt; Each batch decides again what to call the product, and one locale ends up with several words for it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A cut-off reply.&lt;/strong&gt; A long answer hits the output limit and the JSON is truncated.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overwritten work.&lt;/strong&gt; A script that retranslates everything also replaces the text a person fixed last week.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A prompt is a request, and these are hard to ask a model to detect in its own output. Code that runs after the call and is allowed to refuse is a better place for them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Diff, do not retranslate
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;translate.py&lt;/code&gt; never translates a whole file. It computes the keys that exist in &lt;code&gt;ru.json&lt;/code&gt; and not in the target, and sends only those:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Simplified from get_missing_keys() in scripts/translate.py&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;missing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;missing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;get_missing_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;current_path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An existing translated string is never retranslated. That is the property that lets a person edit a locale file by hand and have it survive the next run. Keys that exist in a locale file but not in the source are removed on every run, except the dotted paths listed in &lt;code&gt;scripts/locale-overrides.json&lt;/code&gt;; hand-written, locale-specific content has to be registered there or the next run deletes it.&lt;/p&gt;

&lt;p&gt;The same diff powers &lt;code&gt;--dry-run&lt;/code&gt;: it prints missing, obsolete and invalid keys per locale, with no API call, no writes and no API key. It also validates the strings already in the files, so it checks the current state as well as previewing the next run.&lt;/p&gt;

&lt;p&gt;The cost of diffing is a rule people have to follow. &lt;code&gt;translate.py&lt;/code&gt; only fills missing keys, so an edit to an existing Russian string leaves the other locales stale until the documented procedure is followed: delete that key from every other locale and rerun. That is a procedure, not an enforced check, and it comes back in the last section.&lt;/p&gt;

&lt;h2&gt;
  
  
  Validate before you write
&lt;/h2&gt;

&lt;p&gt;Every string the model returns goes through a validator before it is placed in a file. The validator is &lt;code&gt;scripts/i18n-check.ts&lt;/code&gt;, the same code that &lt;code&gt;npm run i18n:check&lt;/code&gt; runs over the whole catalogue at commit time, called by the Python script in &lt;code&gt;--validate&lt;/code&gt; mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Simplified from translate_batch() in scripts/translate.py&lt;/span&gt;
&lt;span class="n"&gt;invalid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"key"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;validate_translations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;candidates&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;candidate&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;candidates&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;candidate&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"key"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;invalid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;failures&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{key}: {invalid[key]}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;all_translated&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;candidate&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"target"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using one implementation for both means the write-time check and the commit-time check cannot drift apart: there is one ICU parser and one source of plural data.&lt;/p&gt;

&lt;p&gt;For each source and target pair the validator runs these checks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified from validate() in scripts/i18n-check.ts&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;shapeOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;got&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;shapeOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// a parse error is returned as a failure&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;got&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`arguments differ from source`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;got&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`tags differ from source`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pluralErrors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;got&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The target must parse as ICU. It must use the same &lt;code&gt;{arguments}&lt;/code&gt; and the same &lt;code&gt;&amp;lt;tags&amp;gt;&lt;/code&gt; as the source. And every &lt;code&gt;plural&lt;/code&gt; must contain the required CLDR categories of the target language, which come from &lt;code&gt;Intl.PluralRules&lt;/code&gt;: &lt;code&gt;other&lt;/code&gt; always, and for example &lt;code&gt;one&lt;/code&gt;, &lt;code&gt;few&lt;/code&gt; and &lt;code&gt;many&lt;/code&gt; for Russian. In French, Italian, Spanish and Portuguese &lt;code&gt;many&lt;/code&gt; is treated as optional. A model copying the source structure can get this wrong. One exception: strings containing raw HTML tags, such as FAQ answers, skip this ICU check; more on that below.&lt;/p&gt;

&lt;p&gt;A failing string is not written. The other strings in the batch that passed are written, the file is saved, and at the end the run prints the list of keys that were left out and exits with code 1. Because those keys are still missing, the next run picks them up through the same diff. Nothing marks a failure as ‘done’.&lt;/p&gt;

&lt;p&gt;The validator also feeds the prompt. Before a request, the script asks it for the target locale’s plural categories with sample numbers and writes them into the system prompt. The model is told the rule that will be enforced afterwards. That should help the first pass; the validator is what stops a miss from being written.&lt;/p&gt;

&lt;h2&gt;
  
  
  Truncation loses the whole batch
&lt;/h2&gt;

&lt;p&gt;Batches are cut at 50 strings or about 10,000 characters. The character limit exists because the reply is capped at the model’s output limit: if it is reached mid-object you do not get 40 good strings and 10 missing ones, you get a broken JSON object and lose the whole batch. A long HTML answer should not share a call with 49 other strings.&lt;/p&gt;

&lt;p&gt;The script checks &lt;code&gt;finish_reason&lt;/code&gt; on every response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Simplified from translate_batch()&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;finish_reason&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"length"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;failures&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{key}: API response truncated at the output limit"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A truncated reply fails the batch with its key list; it is not parsed ‘as far as it goes’. An empty reply, an unparseable one and a key missing from a valid reply are each reported separately. The call is &lt;code&gt;gpt-4o&lt;/code&gt; at temperature 0.3. That makes output steadier, not reproducible, which is another reason the gates sit after the call. The cost side of production model calls is &lt;a href="https://iurii.rogulia.fi/blog/openai-cost-control-production" rel="noopener noreferrer"&gt;a separate topic&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A glossary that is injected and checked in two directions
&lt;/h2&gt;

&lt;p&gt;Batching creates the glossary problem. The shop sells two products: waterless urinals and waterless outdoor sinks. Each batch re-decides what to call them in the target language. Over a few runs, one locale ends up with several words, and some of them mean something else. The defects I documented in review:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Locale&lt;/th&gt;
&lt;th&gt;The model produced&lt;/th&gt;
&lt;th&gt;What it actually means&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;et&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;uriin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;urine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lv&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;urīns&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;urine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;hr&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;vodokotlić&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;toilet cistern&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pl&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;zlew&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;kitchen sink&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;uk&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;писуар&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;misspelling of &lt;code&gt;пісуар&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A person found these by reading the output in review; the pipeline did not catch them. Afterwards I turned each one into a check.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;scripts/glossary.json&lt;/code&gt; holds one entry per locale: the approved term for each product, the qualifier that term needs, forbidden terms with a plain statement of what each one really is, the script, the way to address the reader, and the title separator. It records established usage, counted in the files; it does not invent a terminology policy.&lt;/p&gt;

&lt;p&gt;The glossary is used in two places. At write time, &lt;code&gt;translate.py&lt;/code&gt; renders the locale’s entry into the system prompt, last, so it overrides looser hints above it. It does not check the glossary on the returned strings. That happens at commit time: &lt;code&gt;glossary:check&lt;/code&gt; scans every message file, as part of &lt;code&gt;npm run lint&lt;/code&gt;. Two kinds of check run there.&lt;/p&gt;

&lt;p&gt;The negative check is the obvious one: a forbidden stem, or text in the wrong alphabet, fails. A stem also matches up to four inflection letters, so &lt;code&gt;zlew&lt;/code&gt; catches &lt;code&gt;zlewy&lt;/code&gt; but not an unrelated word that merely starts the same way.&lt;/p&gt;

&lt;p&gt;The negative check has a hole, and I fell into it. A forbidden list only knows the words someone already listed. On 20 September 2026 it was green while six locales carried the kitchen-sink word on the sink product’s H1: &lt;code&gt;fregadero&lt;/code&gt; (es), &lt;code&gt;sudoper&lt;/code&gt; (hr), &lt;code&gt;drez&lt;/code&gt; (sk), &lt;code&gt;mosogató&lt;/code&gt; (hu), &lt;code&gt;gootsteen&lt;/code&gt; (nl) and &lt;code&gt;lavello&lt;/code&gt; (it). Nobody had listed them. I found them by dumping that one key across all 28 locales and reading the column.&lt;/p&gt;

&lt;p&gt;So the check now also runs in the opposite direction, on what I call identity surfaces: strings that should name the product, matched by key path, so no language parsing is needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified from scripts/glossary.ts&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;IDENTITY_SURFACES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="o"&gt;/^&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sinks&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;urinals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="o"&gt;/^&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sinks&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;urinals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seo&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="o"&gt;/^&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sinks&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;urinals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hero&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;header&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="o"&gt;/^&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sinks&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;urinals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;products&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;header&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;slot&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;mentionsTerm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;terms&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;slot&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Tier-1 surface does not use an approved ${slot} term`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;failures&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On those paths the check fails unless the string contains an approved term for the slot (matched by stem, or by compound head). Two more rules are narrower than they sound. A sink noun needs its qualifier (‘garden’, ‘outdoor’ and so on) only where the page does not already set the category: the check passes automatically for anything under &lt;code&gt;sinks.*&lt;/code&gt;, for &lt;code&gt;.name&lt;/code&gt; labels, and for a string that also contains the urinal noun. In practice that leaves strings outside the sink subtree, such as the homepage catalogue header. And for &lt;code&gt;seo.title&lt;/code&gt; the check flags a dash or pipe that differs from the locale’s recorded separator; it does not require a separator to be present, and the SEO prompt itself asks for none. The key path says which product slot a string belongs to, which keeps false positives low; a rule that fires on legitimate copy gets ignored.&lt;/p&gt;

&lt;h2&gt;
  
  
  The keyword spec per locale
&lt;/h2&gt;

&lt;p&gt;Strings that drive search results are not translated like button labels. Keys matching patterns such as &lt;code&gt;.seo.&lt;/code&gt;, &lt;code&gt;.header&lt;/code&gt;, the homepage hero and FAQ entries get a different prompt, with the locale’s keyword spec: a file per locale with Tier 1 terms from Keyword Planner volumes, negative lists and disambiguation rules. The loader raises if a spec has no ‘Tier 1’ section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Simplified from load_locale_seo_spec()&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"Tier 1"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{path.name}: no Tier 1 section found — the spec format changed"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same idea, small scale: if someone reformats the spec and the parser silently finds nothing, every SEO key is translated without keywords and no error. A locale with no spec file is allowed, but the run prints a warning.&lt;/p&gt;

&lt;h2&gt;
  
  
  The review pass is separate, and it is not verification
&lt;/h2&gt;

&lt;p&gt;All of the above checks shape and terminology. None of it can tell whether a sentence sounds like a person wrote it.&lt;/p&gt;

&lt;p&gt;That is a separate pass that I run; &lt;code&gt;translate.py&lt;/code&gt; does not call it. It uses two Claude Code agent roles defined in the repository, &lt;code&gt;localization-reviewer&lt;/code&gt; and &lt;code&gt;proofreader&lt;/code&gt;. The reviewer compares the translation with the source and checks buyer terminology; the proofreader does the final language pass. A loop limit stops them bouncing a text back and forth: it goes back once, and then the reviewer’s linguistic verdict is final or the disagreement comes to me. The project procedure also asks for a manual spot-check of a few major languages after a run. The output of the agents is a model’s judgement, not automated verification.&lt;/p&gt;

&lt;p&gt;The validators do not prove fluency or tone. They remove mistakes that should never need a reader’s attention, so the attention goes to what only a reader can find. A reviewing agent is a second opinion, not a guarantee.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this does not catch
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Wrong meaning in the right shape.&lt;/strong&gt; A string with intact placeholders, tags and plural branches passes validation even if it says the wrong thing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fluency and tone.&lt;/strong&gt; Nothing in the scripts measures them. That is the review pass, with the limits described above.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Raw HTML bodies.&lt;/strong&gt; &lt;code&gt;i18n-check.ts&lt;/code&gt; skips the ICU, placeholder and tag checks for strings that contain HTML tags, such as FAQ answers, because they are rendered as HTML and not as ICU. Those get key parity only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bad words outside the identity surfaces.&lt;/strong&gt; Positive checks apply to the key paths in &lt;code&gt;IDENTITY_SURFACES&lt;/code&gt;. Elsewhere the only automated guard is the forbidden list, which knows only what someone has added.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A wrong word that became the norm.&lt;/strong&gt; The glossary records established usage. If a mistake is already the dominant form in a locale, it gets pinned. A reader still has to catch that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt-only rules.&lt;/strong&gt; Title length (50–60 characters) and description length (150–158) are instructions in the SEO prompt. In the scripts I read, no check enforces them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stale translations after a source edit.&lt;/strong&gt; &lt;code&gt;translate.py&lt;/code&gt; only fills missing keys. An edited Russian string leaves the other locales stale until the delete-and-rerun procedure is followed, and I found no check in these scripts that detects it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source quality.&lt;/strong&gt; The pipeline translates what &lt;code&gt;ru.json&lt;/code&gt; says.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That limits what I claim. The write-time gates stop strings that are broken in shape from being written; the commit-time checks flag known-wrong and missing product terms. Neither makes a translation good.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build it, or buy a TMS
&lt;/h2&gt;

&lt;p&gt;A translation management system offers review workflows, translation memory and a place for translators, which this script lacks. I did not evaluate one for this shop, so this is not an argument against them. The reason to write the gates yourself is narrower: they are written in the shop’s own terms (key paths, product slots, the words that mean the wrong thing) and the commit-time ones run with the rest of the project’s lint. For a few hundred strings in two languages, a script like this is more than you need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A prompt asks; a validator after the call can say no, and it should run before the write.&lt;/li&gt;
&lt;li&gt;Keep write-time gates (shape, truncation) apart from commit-time checks (terminology) and know which is which.&lt;/li&gt;
&lt;li&gt;Translate only the diff, and protect what people wrote.&lt;/li&gt;
&lt;li&gt;Check &lt;code&gt;finish_reason&lt;/code&gt;, and size batches so one truncation cannot take everything.&lt;/li&gt;
&lt;li&gt;A forbidden list catches words you already know. Pair it with positive checks on the surfaces that must say the right thing.&lt;/li&gt;
&lt;li&gt;Say what the checks do not prove, and keep a person for fluency.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
  slug="ai-integration"&lt;br&gt;
  text="Adding a model call to a content or data flow? I design what it is allowed to write: validators, refusals and a review step that is honest about its scope."&lt;br&gt;
/&amp;gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Further reading:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://iurii.rogulia.fi/blog/nextjs-i18n-30-languages" rel="noopener noreferrer"&gt;Next.js i18n with 30 Languages: Production Setup Guide&lt;/a&gt; – routing, hreflang and formatting for multilingual sites&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://iurii.rogulia.fi/blog/i18n-linter-address-register" rel="noopener noreferrer"&gt;Du for the Owner, Sie for the Client: An i18n Linter That Checks Register Per Audience&lt;/a&gt; – a separate check for how a locale addresses its reader&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://iurii.rogulia.fi/blog/openai-cost-control-production" rel="noopener noreferrer"&gt;How to Reduce OpenAI API Costs in Production (2026 Guide)&lt;/a&gt; – the cost side of production model calls&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>typescript</category>
      <category>nextjs</category>
      <category>ai</category>
    </item>
    <item>
      <title>Document Fraud Detection Vendor: Questions to Ask</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Wed, 18 Nov 2026 11:00:52 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/document-fraud-detection-vendor-questions-to-ask-3gdi</link>
      <guid>https://dev.to/iurii_rogulia/document-fraud-detection-vendor-questions-to-ask-3gdi</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published at &lt;a href="https://htpbe.tech/blog/document-fraud-detection-vendor-evaluation-checklist" rel="noopener noreferrer"&gt;htpbe.tech&lt;/a&gt;. The version on htpbe.tech stays in sync with the latest detection algorithm — refer to it for the canonical text.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You have a shortlist, a trial window and a meeting where someone will ask which tool to buy. A convincing demo does not show how a tool handles your files. This checklist is for the part after the demo: what the tool’s output means, what happens when it is wrong, and what it costs to find out.&lt;/p&gt;

&lt;p&gt;One scoping note first. These questions cover tools that do structural analysis to check whether a file was modified after it was created. Identity verification, issuer verification and checking whether the content is true are different jobs, done by different tools and processes. Structural analysis of the file complements them; it does not replace any of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;p&gt;Judge a document fraud detection vendor on three things before the headline features: what its verdict proves and what it does not, how it reports the cases it cannot decide, and whether you can test it on files where you already know the answer. Then check that its data handling and pricing are written down plainly enough to put in a contract. If you are still deciding whether to buy at all, &lt;a href="https://htpbe.tech/blog/build-vs-buy-pdf-tamper-detection" rel="noopener noreferrer"&gt;the build-vs-buy question&lt;/a&gt; comes first.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does the verdict prove, and what does it not?
&lt;/h2&gt;

&lt;p&gt;Every tool returns a result. The question is what that result is a claim about. A check on the file can tell you whether the file shows evidence of change after it was made. It cannot tell you whether the person is honest or whether the figures on the page are real.&lt;/p&gt;

&lt;p&gt;Ask each vendor:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What exactly does a ‘clean’ result claim, in one sentence?&lt;/li&gt;
&lt;li&gt;What can produce a clean result even though the document is not genuine?&lt;/li&gt;
&lt;li&gt;Does a flagged result say what was found, or only that something was?&lt;/li&gt;
&lt;li&gt;Is the result phrased as a statement about the file or about the person?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A vendor that answers the second question without hesitating is telling you something useful. A reasonable standard for that answer: content that was false from the start carries no evidence of a later edit, so a file check cannot catch it. And &lt;code&gt;intact&lt;/code&gt; means no modification was detected, not that the document is genuine. You want every vendor’s documentation to draw that line as clearly, whatever words it uses.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does it report the cases it cannot decide?
&lt;/h2&gt;

&lt;p&gt;Some files cannot be judged by a given method. A document made in ordinary office software has no original to compare against. A scan or a filled form can be redone from scratch. Sometimes the file’s history simply cannot be established, and sometimes the analysis does not finish. A tool that forces each of these into ‘pass’ or ‘fail’ is hiding a limit, not removing it.&lt;/p&gt;

&lt;p&gt;Ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is there a separate result for ‘cannot decide’, or does every file get a yes or no?&lt;/li&gt;
&lt;li&gt;Does that result say why: the kind of file, missing history, or an analysis that did not finish?&lt;/li&gt;
&lt;li&gt;Does the documentation say what to do next for each reason?&lt;/li&gt;
&lt;li&gt;Is an undecided result described as an honest limit, or as a warning sign about the person?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last question matters for your own process. An undecided result should lead to a defined step, such as asking the issuer for a fresh copy, not to a rejection. If you want a worked example of reason-based handling, see &lt;a href="https://htpbe.tech/blog/what-inconclusive-means-pdf-verification-results" rel="noopener noreferrer"&gt;what an inconclusive result means&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How are false positives reviewed?
&lt;/h2&gt;

&lt;p&gt;Any automated check will sometimes flag a legitimate file. A vendor that claims otherwise is making a claim you cannot test. What you can test is what happens next.&lt;/p&gt;

&lt;p&gt;Ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does each flag come with a named reason that a reviewer can read?&lt;/li&gt;
&lt;li&gt;Are those reason names stable, so you can build your own handling on them?&lt;/li&gt;
&lt;li&gt;Who reviews a disputed result: your team, the vendor, or both? Is that route written down?&lt;/li&gt;
&lt;li&gt;When the detection changes, can you see which version produced an old result?&lt;/li&gt;
&lt;li&gt;Does the vendor tell you not to use the verdict as the sole basis for an adverse decision?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Treat any confidence label as a description of the evidence, not a guarantee. If a person can be refused on the strength of the result, your own process needs a human review and a way for that person to contest the outcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which files stay with the vendor, and for how long?
&lt;/h2&gt;

&lt;p&gt;Ask for the answer in writing, separately for each way files reach the vendor:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Are file bytes stored after analysis? Does that differ between a web upload and an API call?&lt;/li&gt;
&lt;li&gt;Are customer files used to train or improve the product?&lt;/li&gt;
&lt;li&gt;What is stored about each check, and for how long?&lt;/li&gt;
&lt;li&gt;How do you request deletion, and how quickly is it done?&lt;/li&gt;
&lt;li&gt;Can you delete your data yourself, or only by request?&lt;/li&gt;
&lt;li&gt;Who are the subprocessors, and where do they process data?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your security team will have its own questionnaire. For a worked example of the answers a reviewer should expect, see &lt;a href="https://htpbe.tech/blog/pdf-fraud-api-data-handling-security-review" rel="noopener noreferrer"&gt;data handling in a PDF fraud API&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can you test it on your own known cases?
&lt;/h2&gt;

&lt;p&gt;This is the step that tells you most. Build a small set of files where you already know the answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;documents you approved in the past and have no reason to doubt;&lt;/li&gt;
&lt;li&gt;files you know were edited, from past cases or made by your own team for the test;&lt;/li&gt;
&lt;li&gt;legitimate files that went through ordinary handling, such as being re-saved, merged or signed. Label these by what happened to the file, not by whether it is legitimate: a tool that reports modification may correctly flag an honest re-save or merge.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run them all and record agreement case by case, not as a single percentage. Score each file against what happened to it, not against whether you trust it. Look hardest at the disagreements and at how each one was explained. Keep part of the set back and run it only once, after any settings have been agreed, so you are not simply tuning the trial to your sample.&lt;/p&gt;

&lt;p&gt;Ask whether the trial runs real analysis. A sandbox that returns fixed sample results is good for testing your integration, but it tells you nothing about detection on your files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is pricing readable before you sign?
&lt;/h2&gt;

&lt;p&gt;You should be able to work out next month’s bill from the price page. Ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What exactly is billed: a file, a page, a check, a seat?&lt;/li&gt;
&lt;li&gt;What happens to errors, timeouts and retries? Are they charged?&lt;/li&gt;
&lt;li&gt;What happens when you run out: are checks refused, or charged at a different rate?&lt;/li&gt;
&lt;li&gt;Are there minimum terms, setup fees or credits that expire?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A one-page scorecard
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;A good answer includes&lt;/th&gt;
&lt;th&gt;Ask for as evidence&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;What does a clean result claim?&lt;/td&gt;
&lt;td&gt;A one-sentence limit, including what it cannot catch&lt;/td&gt;
&lt;td&gt;The wording in the API or product docs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;How are undecided cases reported?&lt;/td&gt;
&lt;td&gt;A separate result with a stated reason and a next step&lt;/td&gt;
&lt;td&gt;The list of reasons and their meanings&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What does a flag say?&lt;/td&gt;
&lt;td&gt;Named, stable reasons a reviewer can read&lt;/td&gt;
&lt;td&gt;Sample results and the reason catalogue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;How are disputed results reviewed?&lt;/td&gt;
&lt;td&gt;A written route, and who owns it&lt;/td&gt;
&lt;td&gt;The terms and any review procedure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What is kept, and for how long?&lt;/td&gt;
&lt;td&gt;Per-channel retention, training use and deletion process&lt;/td&gt;
&lt;td&gt;Privacy policy, DPA, subprocessor list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can we test on our own files?&lt;/td&gt;
&lt;td&gt;Real analysis on your files during the trial&lt;/td&gt;
&lt;td&gt;Trial terms, and what the sandbox does&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can we predict the bill?&lt;/td&gt;
&lt;td&gt;Billing unit, retry rules, behaviour when credits run out&lt;/td&gt;
&lt;td&gt;Price page and the billing terms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Apply these questions to us too
&lt;/h2&gt;

&lt;p&gt;HTPBE does structural PDF tamper detection. Here are our answers, limits included.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;HTPBE’s answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;What does it prove?&lt;/td&gt;
&lt;td&gt;Whether the file shows evidence of modification. &lt;code&gt;intact&lt;/code&gt; means no modification was detected, not that the document is genuine; content that was false from the start carries no evidence of a later edit. It does not judge whether the content is true. Scans and screenshots never come back &lt;code&gt;intact&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Undecided cases&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;inconclusive&lt;/code&gt;, with the reason in &lt;code&gt;status_reason&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;False positives&lt;/td&gt;
&lt;td&gt;Our terms say false positives will occur. Every result carries &lt;code&gt;usage_caution.safe_for_automated_adverse_decision&lt;/code&gt;, always &lt;code&gt;false&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Disputes&lt;/td&gt;
&lt;td&gt;No self-serve dispute or review flow. Our terms require your own process to give an affected person a way to contest a decision.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retention&lt;/td&gt;
&lt;td&gt;Website uploads may be retained and used to improve detection. Through the API, the file is analysed once and its bytes are not stored. For both, the check record (verdict, findings and metadata, including the filename) is kept for up to 3 years under our &lt;a href="https://htpbe.tech/legal/privacy" rel="noopener noreferrer"&gt;Privacy Policy&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deletion&lt;/td&gt;
&lt;td&gt;Email &lt;a href="mailto:privacy@htpbe.tech"&gt;privacy@htpbe.tech&lt;/a&gt;; processed within 30 days, subject to legal retention duties. A retained web copy already used in evaluation may not be individually retrievable. No self-serve deletion.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Testing&lt;/td&gt;
&lt;td&gt;Test keys return synthetic results, so they test integration, not detection. Your own files need live credits: new accounts get 5 welcome credits, then pay-per-check.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Running out&lt;/td&gt;
&lt;td&gt;Checks are refused until credits are added, the plan is upgraded or its monthly quota resets. An &lt;code&gt;inconclusive&lt;/code&gt; result marked &lt;code&gt;analysis_incomplete&lt;/code&gt; uses a credit; a request that ends in an error uses none, and a retry with the same idempotency key is not charged again. Reading a result again is free.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you are comparing specific vendors, our side-by-side pages are here: &lt;a href="https://htpbe.tech/compare/inscribe-alternative" rel="noopener noreferrer"&gt;Inscribe alternative&lt;/a&gt;, &lt;a href="https://htpbe.tech/compare/ocrolus-alternative" rel="noopener noreferrer"&gt;Ocrolus alternative&lt;/a&gt; and &lt;a href="https://htpbe.tech/compare/bynn-alternative" rel="noopener noreferrer"&gt;Bynn alternative&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Should we ask a vendor for its accuracy figure?
&lt;/h3&gt;

&lt;p&gt;Ask, but do not let one number decide. A rate measured on someone else’s files tells you little about yours. A trial on your own known cases, scored case by case, tells you more than any headline figure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can a document fraud detection tool replace identity or issuer checks?
&lt;/h3&gt;

&lt;p&gt;No. A tool that checks whether a file was modified answers a question about the file. Whether the person is who they claim to be, or whether the issuer actually produced the document, are separate checks that still need to run.&lt;/p&gt;

&lt;h3&gt;
  
  
  What should happen to a file the tool cannot decide on?
&lt;/h3&gt;

&lt;p&gt;It should go to a defined next step, such as a fresh copy from the issuer or a manual review. An undecided result is an honest limit of the check, not a finding against the person who sent the file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is a free trial enough to judge detection quality?
&lt;/h3&gt;

&lt;p&gt;Only if the trial runs real analysis on your own files. A sandbox that returns fixed sample results tests your integration, not the detection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run your own known cases
&lt;/h2&gt;

&lt;p&gt;If you are evaluating an integration, the &lt;a href="https://htpbe.tech/api" rel="noopener noreferrer"&gt;API documentation&lt;/a&gt; covers the request, the result fields and the test keys. To run your known cases, see &lt;a href="https://htpbe.tech/pricing" rel="noopener noreferrer"&gt;pricing&lt;/a&gt; for credits and plans, or check files through the website on pay-per-check.&lt;/p&gt;

</description>
      <category>pdf</category>
      <category>fintech</category>
      <category>fraud</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Submit and Poll an Async VAT Bulk Validation Job in Node.js</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Wed, 18 Nov 2026 10:00:52 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/submit-and-poll-an-async-vat-bulk-validation-job-in-nodejs-ajf</link>
      <guid>https://dev.to/iurii_rogulia/submit-and-poll-an-async-vat-bulk-validation-job-in-nodejs-ajf</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published at &lt;a href="https://vatnode.dev/blog/vat-bulk-api-submit-and-poll" rel="noopener noreferrer"&gt;vatnode.dev&lt;/a&gt;. The version on vatnode.dev is the canonical source — refer to it for the latest content.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A bulk VAT ID check should be a job you submit, not a loop you babysit. &lt;code&gt;POST /v1/vat/bulk&lt;/code&gt; takes up to 50,000 IDs and returns a job id straight away; you poll for the outcome. This post builds a bulk VAT number checker in Node.js that survives retries, outages and a restart of your own process. Scope is the EU-27 plus Northern Ireland (&lt;code&gt;XI&lt;/code&gt;), and the &lt;a href="https://vatnode.dev/docs/bulk-vat-validation" rel="noopener noreferrer"&gt;bulk validation reference&lt;/a&gt; has the full request and response shapes. For the revalidation use case, see &lt;a href="https://vatnode.dev/blog/bulk-revalidate-customer-vat-ids" rel="noopener noreferrer"&gt;how to bulk re-validate customer VAT IDs&lt;/a&gt;; this post is the client underneath it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The flow in four calls
&lt;/h2&gt;

&lt;p&gt;All calls need &lt;code&gt;Authorization: Bearer &amp;lt;key&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Call&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;th&gt;Returns&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST /v1/vat/bulk&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Submit the list&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;202&lt;/code&gt; with &lt;code&gt;jobId&lt;/code&gt;, &lt;code&gt;status&lt;/code&gt;, &lt;code&gt;totalItems&lt;/code&gt;, &lt;code&gt;duplicatesDropped&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /v1/vat/bulk/{jobId}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Read status and counters&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;status&lt;/code&gt;, &lt;code&gt;processedItems&lt;/code&gt;, &lt;code&gt;summary&lt;/code&gt;, &lt;code&gt;expiresAt&lt;/code&gt;, &lt;code&gt;errorCode&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /v1/vat/bulk/{jobId}/results&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Page through the positions&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;items&lt;/code&gt;, &lt;code&gt;total&lt;/code&gt;, &lt;code&gt;page&lt;/code&gt;, &lt;code&gt;pages&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST /v1/vat/bulk/{jobId}/cancel&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ask a job to stop at its next position&lt;/td&gt;
&lt;td&gt;the job, usually still &lt;code&gt;queued&lt;/code&gt; or &lt;code&gt;processing&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;No call spends quota by itself. Quota is spent per position, by the job, as each position is answered. Polling, reading results, cancelling and listing jobs (&lt;code&gt;GET /v1/vat/bulk&lt;/code&gt;) are free. Nothing is validated during the submit request either; it only records the batch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dry run first: a test key and the XX fixtures
&lt;/h2&gt;

&lt;p&gt;Every account gets a &lt;code&gt;vat_test_&lt;/code&gt; key on first sign-in (see &lt;a href="https://vatnode.dev/docs/test-mode" rel="noopener noreferrer"&gt;test mode&lt;/a&gt; and &lt;a href="https://vatnode.dev/blog/vat-api-test-keys" rel="noopener noreferrer"&gt;the test keys post&lt;/a&gt;). With it the job is real, with real ids and the same polling contract, but nothing is billed and VIES is not called. Every position must start with &lt;code&gt;XX&lt;/code&gt;, otherwise it answers &lt;code&gt;INVALID_FORMAT&lt;/code&gt;. If you have no key yet, &lt;a href="https://vatnode.dev/register" rel="noopener noreferrer"&gt;create a free account&lt;/a&gt;; the dry run below costs nothing.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;VAT ID&lt;/th&gt;
&lt;th&gt;Test-mode answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;XX0000001&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;valid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;XX0000002&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;valid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;XX0000003&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;invalid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;XX0000004&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;error &lt;code&gt;VIES_UNAVAILABLE&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;XX0000005&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;error &lt;code&gt;VIES_ERROR&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;any other &lt;code&gt;XX…&lt;/code&gt;, e.g. &lt;code&gt;XX1234567&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;invalid (&lt;code&gt;valid: false&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This is how a failed fixture position looks in the results. &lt;code&gt;valid&lt;/code&gt; is &lt;code&gt;null&lt;/code&gt;, never &lt;code&gt;false&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"position"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"vatId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"XX0000004"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"done"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"valid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"consultationNumber"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"checkId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"VIES_UNAVAILABLE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"VIES service is temporarily unavailable"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"processedAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-11T09:00:03.000Z"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Submit with an idempotency key you can safely retry
&lt;/h2&gt;

&lt;p&gt;A single &lt;code&gt;GET /v1/vat/{vatId}&lt;/code&gt; is safe to repeat (&lt;a href="https://vatnode.dev/blog/vat-api-idempotency-retries" rel="noopener noreferrer"&gt;the idempotency post&lt;/a&gt; covers that). A bulk submit is not: if the connection drops before the &lt;code&gt;202&lt;/code&gt; arrives, you cannot tell whether the batch was accepted, and a blind retry could buy it twice.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Idempotency-Key&lt;/code&gt; header fixes that. The rules, as implemented:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The key is optional, matches &lt;code&gt;^[A-Za-z0-9._-]{8,200}$&lt;/code&gt;, and is scoped to your account.&lt;/li&gt;
&lt;li&gt;Same key, same list: &lt;code&gt;202&lt;/code&gt; with the same job, in whatever state it has reached. No second job, no second charge.&lt;/li&gt;
&lt;li&gt;Mint the key once per batch, persist it before the first attempt, and resend it verbatim on every retry. A key generated inside the retry loop defeats the point.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Every error branch on submit
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;400 INVALID_REQUEST&lt;/code&gt;&lt;/strong&gt; rejects the whole POST and records nothing. It covers an empty array, more than 50,000 entries, a non-array, a non-string entry, and any single entry whose raw length is under 4 or over 20 characters. The length is checked before normalisation, so pre-filter your list for raw length 4 to 20 yourself; one stray cell would otherwise sink the batch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;INVALID_FORMAT&lt;/code&gt; on a position&lt;/strong&gt; is different. An entry that passes the length check but fails its country’s format is accepted, and that position answers &lt;code&gt;INVALID_FORMAT&lt;/code&gt;. It is not billed, and the job carries on.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;400 IDEMPOTENCY_KEY_INVALID&lt;/code&gt;&lt;/strong&gt;: the header does not match the pattern. It is rejected, not ignored.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;409 IDEMPOTENCY_KEY_CONFLICT&lt;/code&gt;&lt;/strong&gt;: the key was used with a different list. The fingerprint covers the normalised, de-duplicated list in submit order, so the same IDs reordered also conflict. The original job is untouched. Use a new key only when the list really is a new batch.&lt;/li&gt;
&lt;li&gt;A missing or invalid API key is rejected before any of this; see &lt;a href="https://vatnode.dev/docs/authentication" rel="noopener noreferrer"&gt;authentication&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Entries are normalised on intake (trimmed, uppercased, spaces, &lt;code&gt;-&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; removed) and then de-duplicated, keeping first-seen order. &lt;code&gt;duplicatesDropped&lt;/code&gt; tells you how many went, so &lt;code&gt;totalItems&lt;/code&gt; can be smaller than what you sent. One position is one quota unit. Retry the same request with the same key on network errors, timeouts and 5xx. Do not retry 4xx; they will answer the same way. Error bodies are always &lt;code&gt;{ "error": { "code", "message", "requestId" } }&lt;/code&gt;, and the full list is in the &lt;a href="https://vatnode.dev/docs/errors" rel="noopener noreferrer"&gt;error reference&lt;/a&gt; and &lt;a href="https://vatnode.dev/blog/handling-vies-errors-in-code" rel="noopener noreferrer"&gt;handling VIES errors in code&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Poll until a terminal status
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;status&lt;/code&gt; is one of &lt;code&gt;queued&lt;/code&gt;, &lt;code&gt;processing&lt;/code&gt;, &lt;code&gt;finished&lt;/code&gt;, &lt;code&gt;cancelled&lt;/code&gt; or &lt;code&gt;failed&lt;/code&gt;. The last three are terminal, and a client has to branch on all of them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;finished&lt;/code&gt;: every position has an answer, error answers included. It does not mean everything is valid. Read &lt;code&gt;summary&lt;/code&gt; (&lt;code&gt;valid&lt;/code&gt;, &lt;code&gt;invalid&lt;/code&gt;, &lt;code&gt;errors&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cancelled&lt;/code&gt;: you cancelled it, or the API key was revoked (&lt;code&gt;errorCode&lt;/code&gt; is &lt;code&gt;API_KEY_REVOKED&lt;/code&gt;, and &lt;code&gt;cancelRequestedAt&lt;/code&gt; may be &lt;code&gt;null&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;failed&lt;/code&gt;: &lt;code&gt;errorCode&lt;/code&gt; says why. Branch on it even if you never see it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On &lt;code&gt;cancelled&lt;/code&gt; and &lt;code&gt;failed&lt;/code&gt;, positions that were answered keep their answers and positions that were not reached stay &lt;code&gt;pending&lt;/code&gt; forever, unbilled.&lt;/p&gt;

&lt;p&gt;The docs say to poll every few seconds and publish no ETA; duration depends on cache hits and VIES health. The interval in the client (2&amp;nbsp;s growing to 15&amp;nbsp;s) is our suggestion, not a documented rate. The client also tolerates a few failed polls in a row, since a transient 5xx on a read says nothing about the job, and enforces a deadline you choose.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read results while the job runs
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;GET /v1/vat/bulk/{jobId}/results?page=1&amp;amp;limit=100&lt;/code&gt; returns &lt;code&gt;items&lt;/code&gt;, &lt;code&gt;total&lt;/code&gt;, &lt;code&gt;page&lt;/code&gt; and &lt;code&gt;pages&lt;/code&gt;. &lt;code&gt;limit&lt;/code&gt; is 1 to 100 and defaults to 20, so ask for 100. Positions come in submit order, numbered from 0 after de-duplication, and a pending position flips to &lt;code&gt;done&lt;/code&gt; in place.&lt;/p&gt;

&lt;p&gt;To use answers early, re-read from the first page that still held a pending position and key what you keep by &lt;code&gt;position&lt;/code&gt;. Positions are not necessarily answered in order, so later pages can already hold done ones. &lt;code&gt;readResults&lt;/code&gt; below returns that first page and stores done items in a &lt;code&gt;Map&lt;/code&gt;. The script calls it once, after the job is terminal. To consume early, call it between polls and pass the page it returned as &lt;code&gt;startPage&lt;/code&gt; next time. Test &lt;code&gt;valid === true&lt;/code&gt; and &lt;code&gt;valid === false&lt;/code&gt;; &lt;code&gt;valid&lt;/code&gt; is &lt;code&gt;null&lt;/code&gt; for pending and failed positions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resubmit retryable positions as a new job
&lt;/h2&gt;

&lt;p&gt;A failed position has &lt;code&gt;valid: null&lt;/code&gt;, &lt;code&gt;checkId: null&lt;/code&gt; and an &lt;code&gt;error&lt;/code&gt;. HTTP stays 2xx whatever the position outcomes are. Retrying means collecting those VAT IDs and submitting them as a new job with a new key:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;VIES_UNAVAILABLE&lt;/code&gt;, &lt;code&gt;UPSTREAM_TIMEOUT&lt;/code&gt;, &lt;code&gt;AUDIT_WRITE_FAILED&lt;/code&gt;: retry later.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;RATE_LIMITED&lt;/code&gt;: retry after upgrading or after the quota resets.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;INVALID_REQUESTER&lt;/code&gt;: usually means VIES rejected your requester VAT. Fix it in &lt;a href="https://vatnode.dev/dashboard/account" rel="noopener noreferrer"&gt;Account details&lt;/a&gt; first. The requester is read there only, at submit time, and stays with the job.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;INVALID_FORMAT&lt;/code&gt;: fix the source data.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;VIES_ERROR&lt;/code&gt; is a catch-all that includes blocked VAT IDs or IPs, which a retry repeats, so this client does not retry it automatically. Review those positions and resubmit them once, on purpose. &lt;code&gt;INTERNAL_ERROR&lt;/code&gt; goes to the same pile.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The consultation number is the VIES &lt;code&gt;requestIdentifier&lt;/code&gt;. A position carries one only on a valid verdict checked live against VIES, and only if a requester VAT was set when the job was submitted. If VIES returns a valid verdict without one, the position is withheld as &lt;code&gt;VIES_ERROR&lt;/code&gt; and not billed.&lt;/p&gt;

&lt;p&gt;Bulk positions carry no company name or address. A sole trader’s VAT number identifies a person, and in some countries it is built on their personal ID number, so treat stored results as personal data.&lt;/p&gt;

&lt;h2&gt;
  
  
  404 and the 30-day window
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;expiresAt&lt;/code&gt; is 30 days after submission. After that the job and its positions are removed by the next daily cleanup and reads return &lt;code&gt;404 NOT_FOUND&lt;/code&gt;, as they do for an unknown job or one from another account. A malformed &lt;code&gt;jobId&lt;/code&gt; is a &lt;code&gt;400 INVALID_REQUEST&lt;/code&gt;. The checks themselves stay in your check history under their &lt;code&gt;checkId&lt;/code&gt;, on that history’s own retention. Store the &lt;code&gt;jobId&lt;/code&gt; with your batch record and copy results out well inside the window.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exact quota accounting
&lt;/h2&gt;

&lt;p&gt;Quota is spent per position as it is answered, the same as for &lt;code&gt;GET /v1/vat/{vatId}&lt;/code&gt;; nothing is reserved up front.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Billed:&lt;/strong&gt; a position that ends with a &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; verdict. Without a requester set, it can come from VIES, a national source or the cache. With one set, the cache is skipped and a valid verdict needs a consultation number.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not billed:&lt;/strong&gt; duplicates, &lt;code&gt;INVALID_FORMAT&lt;/code&gt;, upstream errors (&lt;code&gt;VIES_UNAVAILABLE&lt;/code&gt;, &lt;code&gt;UPSTREAM_TIMEOUT&lt;/code&gt;, &lt;code&gt;VIES_ERROR&lt;/code&gt;, &lt;code&gt;INVALID_REQUESTER&lt;/code&gt;; any charge is refunded), &lt;code&gt;INTERNAL_ERROR&lt;/code&gt;, &lt;code&gt;AUDIT_WRITE_FAILED&lt;/code&gt;, a missing consultation number when a requester is set, &lt;code&gt;RATE_LIMITED&lt;/code&gt;, positions never reached after a cancel or revocation, and all of test mode.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you run out mid-job on a plan with overage, the remaining positions are billed at the overage rate. On a hard-capped plan every remaining position answers &lt;code&gt;RATE_LIMITED&lt;/code&gt;, and the job still finishes. The free plan is 100 requests a month, no card; rates are on &lt;a href="https://vatnode.dev/pricing" rel="noopener noreferrer"&gt;/pricing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One edge to know about: if the API process is interrupted between charging a position and recording its answer, that position is answered again when the job resumes and charged twice. A job runs five checks at a time, so the worst case is a handful of quota units, not a repeated batch.&lt;/p&gt;

&lt;h2&gt;
  
  
  The full client
&lt;/h2&gt;

&lt;p&gt;Node.js 18 or newer, server-side only; the key never goes in browser code. Save as &lt;code&gt;bulk.mjs&lt;/code&gt; and run &lt;code&gt;VATNODE_API_KEY=vat_test_... node bulk.mjs&lt;/code&gt;. The batch key is written to &lt;code&gt;./batch.key&lt;/code&gt; before the first request; delete the file when you start a different batch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;randomUUID&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'node:crypto'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;writeFileSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'node:fs'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'https://api.vatnode.dev'&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;VATNODE_API_KEY&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="no"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Set VATNODE_API_KEY'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;TERMINAL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'finished'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'cancelled'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'failed'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;RETRYABLE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'VIES_UNAVAILABLE'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'UPSTREAM_TIMEOUT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'AUDIT_WRITE_FAILED'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sleep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;backoff&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ceiling&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30_000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ceiling&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ceiling&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ApiError&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${status} ${e.code ?? 'UNKNOWN'}: ${e.message ?? ''} (requestId ${e.requestId ?? '-'})`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Network errors, timeouts (TimeoutError) and 5xx are transient.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;isTransient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nc"&gt;ApiError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${BASE}${path}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nc"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`Bearer ${KEY}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'Content-Type'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'application/json'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;AbortSignal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15_000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;envelope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;envelope&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ApiError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;envelope&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;rawLengthOk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'string'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;

&lt;span class="c1"&gt;// Same request, same key, on every attempt.&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;submitJob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vatIds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maxAttempts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'POST'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'/v1/vat/bulk'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;vatIds&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'Idempotency-Key'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nc"&gt;ApiError&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;409&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="sb"&gt;`${err.message}. ./batch.key holds a key already used with a different list. If the list really changed, delete ./batch.key and rerun; if not, restore the original list.`&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;isTransient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;maxAttempts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;backoff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;pollJob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jobId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;deadlineMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60_000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;deadlineMs&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt; &lt;span class="c1"&gt;// our suggestion, not a documented rate&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;failures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;deadline&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'GET'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sb"&gt;`/v1/vat/bulk/${jobId}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;failures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;TERMINAL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nc"&gt;ApiError&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Job not found: expired (30 days) or not from this account'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;isTransient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;failures&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15_000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Job ${jobId} not terminal before the deadline; it keeps running`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Stores answered positions by position number; returns the first page that&lt;/span&gt;
&lt;span class="c1"&gt;// still has a pending position (null when none), so you can resume from there.&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;readResults&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jobId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;startPage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;firstPendingPage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;startPage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pages&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s1"&gt;'GET'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="sb"&gt;`/v1/vat/bulk/${jobId}/results?page=${page}&amp;amp;limit=100`&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'done'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;position&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;firstPendingPage&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;firstPendingPage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;firstPendingPage&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sortResults&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;valid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;invalid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;retry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fixData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;other&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;valid&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;valid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vatId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;valid&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;invalid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vatId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;RETRYABLE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;retry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vatId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'INVALID_FORMAT'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fixData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vatId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;other&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${item.vatId} ${item.error?.code}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// never treat null as false&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Main: dry run on a test key.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;vatIds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'XX0000001'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'XX0000002'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'XX0000003'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'XX0000004'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'XX0000005'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'xx 0000001'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;vatIds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;every&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rawLengthOk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Fix entries with raw length outside 4-20 first'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;keyFile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'./batch.key'&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;keyFile&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;keyFile&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'utf8'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;randomUUID&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;keyFile&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// persisted before the first attempt&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;submitted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;submitJob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vatIds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="sb"&gt;`job ${submitted.jobId}: ${submitted.totalItems} positions, ${submitted.duplicatesDropped} duplicate(s) dropped`&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;pollJob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;submitted&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jobId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;errorCode&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;answered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;stillPending&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;readResults&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jobId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stillPending&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'some positions were never answered (cancelled or failed job)'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sortResults&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the fixtures above, the last line prints two valid IDs, one invalid, &lt;code&gt;XX0000004&lt;/code&gt; under &lt;code&gt;retry&lt;/code&gt; and &lt;code&gt;XX0000005&lt;/code&gt; under &lt;code&gt;other&lt;/code&gt;. The sixth entry, &lt;code&gt;xx 0000001&lt;/code&gt;, normalises to a duplicate of the first, so &lt;code&gt;totalItems&lt;/code&gt; is 5 and &lt;code&gt;duplicatesDropped&lt;/code&gt; is 1.&lt;/p&gt;

&lt;p&gt;Rerun the script unchanged and the same key hands back the same job: no new job, no new charge. Edit the list without deleting &lt;code&gt;batch.key&lt;/code&gt; and you get the &lt;code&gt;409&lt;/code&gt;; that is the safeguard working. To resubmit &lt;code&gt;retry&lt;/code&gt;, call &lt;code&gt;submitJob(retry, randomUUID())&lt;/code&gt; with a fresh key persisted the same way.&lt;/p&gt;

&lt;p&gt;Read the &lt;a href="https://vatnode.dev/docs/bulk-vat-validation" rel="noopener noreferrer"&gt;bulk validation reference&lt;/a&gt;, &lt;a href="https://vatnode.dev/register" rel="noopener noreferrer"&gt;get a free API key&lt;/a&gt; and run the whole flow on the test key before switching to a live one.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What happens if I POST the same VAT ID list twice to the VAT bulk API?
&lt;/h3&gt;

&lt;p&gt;It depends on the Idempotency-Key header. With the same key and the same list you get a 202 pointing at the same job, with no second job and no second charge. With the same key and a different list, including the same IDs in another order, you get 409 &lt;code&gt;IDEMPOTENCY_KEY_CONFLICT&lt;/code&gt;. Without a key, two POSTs create two jobs.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I know a bulk VAT validation job is finished?
&lt;/h3&gt;

&lt;p&gt;Poll GET /v1/vat/bulk/:jobId until status is finished, cancelled or failed. Those three are terminal. finished means every position has an answer, including error answers, so it does not mean every number is valid. Read the summary counters and the per-position results.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which bulk VAT positions do I pay for?
&lt;/h3&gt;

&lt;p&gt;A position that ends with a valid true or false verdict counts against your quota. Duplicates, &lt;code&gt;INVALID_FORMAT&lt;/code&gt; positions, upstream errors, &lt;code&gt;RATE_LIMITED&lt;/code&gt; positions, positions never reached after a cancel, and everything in test mode are not billed. Quota is spent per position as it is answered, not reserved for the whole batch.&lt;/p&gt;

&lt;h3&gt;
  
  
  How long can I read the results of a bulk VAT job?
&lt;/h3&gt;

&lt;p&gt;For 30 days after submission. The job carries an expiresAt timestamp; after it the job and its positions are deleted and reads return 404 &lt;code&gt;NOT_FOUND&lt;/code&gt;. Each check also stays in your check history under its checkId. Copy what you need into your own system before then.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I test a bulk VAT job without using quota?
&lt;/h3&gt;

&lt;p&gt;Yes. A &lt;code&gt;vat_test_&lt;/code&gt; key runs a real job with the same contract, but every position must start with XX, nothing is billed and VIES is not called. The fixtures XX0000001 to XX0000005 return valid, valid, invalid, &lt;code&gt;VIES_UNAVAILABLE&lt;/code&gt; and &lt;code&gt;VIES_ERROR&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>tax</category>
      <category>webdev</category>
    </item>
    <item>
      <title>What Multilingual SEO Needs That a Translated Site Lacks</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Mon, 16 Nov 2026 11:01:05 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/what-multilingual-seo-needs-that-a-translated-site-lacks-5c59</link>
      <guid>https://dev.to/iurii_rogulia/what-multilingual-seo-needs-that-a-translated-site-lacks-5c59</guid>
      <description>&lt;p&gt;A translated site is not a multilingual SEO setup. Each market you sell in needs its own keyword research, its own URLs, hreflang annotations that stay correct as pages change, metadata written for that market, and a named person who keeps all of it current. Translation covers the words on the page. It covers none of the other five.&lt;/p&gt;

&lt;p&gt;One definition before the rest. When I say local SEO services here, I mean search work done per market: each country and language you sell in. I do not mean a Google Business Profile listing for a shop in one city. That is a different job, and I come back to it below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why an English Playbook Fails When You Translate It
&lt;/h2&gt;

&lt;p&gt;Keywords are not translatable. An English page is built around the phrase buyers type in English. Translate that phrase word for word and you get a phrase the target market may never use: a different term for the same product, a different level of formality, a different thing entirely.&lt;/p&gt;

&lt;p&gt;Demand differs too. Search demand in Finland, Germany and Spain is not the same list translated three times. A product that has ten ways to be searched for in one country may have two in another, and a competitor you never heard of may own the results there.&lt;/p&gt;

&lt;p&gt;So the English playbook breaks at its first step. If the keyword research was done once, in English, and every other language inherits it by translation, the other languages are optimized for queries nobody in those markets types.&lt;/p&gt;

&lt;p&gt;I ran into this directly at Pikkuna, a Finnish manufacturer, where I was Head of Development from 2024 to 2026. The localization pipeline there did not translate the English page and hope. The translation step took a per-market keyword spec as input, and tests enforced title length limits. The mechanism is described on the &lt;a href="https://iurii.rogulia.fi/projects/pikkuna-ai-localization-pipeline" rel="noopener noreferrer"&gt;localization pipeline page&lt;/a&gt;. I am describing the process here, not a ranking result, because I have no search data from that project to show you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keyword Research Per Market, Not Translated Keywords
&lt;/h2&gt;

&lt;p&gt;In practice this means three steps for every market you want to be found in:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find what people in that country actually search for, in their language.&lt;/li&gt;
&lt;li&gt;Map each term to the intent behind it: someone comparing, someone ready to buy, someone looking for information.&lt;/li&gt;
&lt;li&gt;Map that to a real page on your site, or to a page that has to be written.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The decision that belongs to you, not to the person doing the research, is how far to go in each market. There are roughly three levels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Full build.&lt;/strong&gt; Category pages, product or service pages, blog content, all in the local language, researched for that market.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thin presence.&lt;/strong&gt; The core pages only: what you sell, who it is for, how to buy. Enough to exist and to be correct.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No translation.&lt;/strong&gt; Some pages are not worth translating. A news post about a local event, a page about a regulation that applies in one country, a long guide whose audience is in one market. Translating them adds pages to maintain and no reader.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Choosing a level per market is a budget decision. A market with real demand and a working delivery or support setup earns a full build. A market where you have one customer a year earns a thin presence at most. A good plan says which is which before any translation starts.&lt;/p&gt;

&lt;h2&gt;
  
  
  URLs and hreflang Are Hygiene, Not a One-Time Task
&lt;/h2&gt;

&lt;p&gt;Two technical things change when a site has more than one language, and both are easy to get quietly wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;URL structure.&lt;/strong&gt; You choose between language folders on one domain (&lt;code&gt;/fi/&lt;/code&gt;, &lt;code&gt;/de/&lt;/code&gt;), a separate domain per country, or subdomains. For most businesses one domain with folders is the simplest to run, but that depends on your situation, and I will say which I would pick after looking at yours. What matters for you: choose early. Changing structure later means every URL moves, and that is expensive and visible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;hreflang.&lt;/strong&gt; This is the annotation that tells a search engine which version of a page is meant for which language or region. Google treats it as a hint, not a command, and it does not boost rankings by itself. What it does is help the right version show up for the right reader instead of the wrong one. The rules are mechanical:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"alternate"&lt;/span&gt; &lt;span class="na"&gt;hreflang&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"fi"&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://example.com/fi/"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"alternate"&lt;/span&gt; &lt;span class="na"&gt;hreflang&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"de"&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://example.com/de/"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"alternate"&lt;/span&gt; &lt;span class="na"&gt;hreflang&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"x-default"&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://example.com/en/"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every version must list every other version and itself. The codes must be valid. Only versions that actually exist may be listed. That is all, and it is also why it breaks: add a page in three languages but not the fourth, delete a page in one language, or rename a URL, and the set stops being reciprocal. Nothing shows an error on the page. The annotations are simply wrong, and you find out later or never.&lt;/p&gt;

&lt;p&gt;At Pikkuna I implemented this for the storefront: hreflang across 30 languages, language-prefixed URLs, and a sitemap with locale alternates. On my own side project Wrongulator, a calculator site in 17 languages, the alternates are generated from one function, so they come from a single place. If you are an engineer and want the code, the &lt;a href="https://iurii.rogulia.fi/blog/nextjs-i18n-30-languages" rel="noopener noreferrer"&gt;Next.js i18n article&lt;/a&gt; and the &lt;a href="https://iurii.rogulia.fi/blog/wrongulator-programmatic-seo" rel="noopener noreferrer"&gt;hreflang-for-17-languages article&lt;/a&gt; cover it. This piece is for the person deciding whether it is being done.&lt;/p&gt;

&lt;h2&gt;
  
  
  Metadata and Page Content in Each Language
&lt;/h2&gt;

&lt;p&gt;The title and description of a page are what a searcher reads before deciding to click. They have to be written for the market, not carried over.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Length differs by language.&lt;/strong&gt; Title and description length budgets differ per language and per script, so they have to be tested per language, not assumed from English.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structured data has to follow the language.&lt;/strong&gt; On a store, price, currency and availability data must be correct for each market. The project page for the Pikkuna storefront describes structured data surviving the i18n layer as ‘the most common place schema breaks on multilingual sites’. My own reasoning for why: the values pass through a translation layer. I implemented localized Product markup there, with the values per language.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Untested machine translation is a risk, not a saving.&lt;/strong&gt; The Pikkuna pipeline used AI translation in three stages, with tests on placeholders and length. I describe that as a design that catches certain mistakes. I am not claiming the output matches a native writer, and you should be wary of anyone who does without showing you their checks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want pages in a language where nobody on your side can read the result, that is the point to stop and decide who reviews it. A page that is wrong in a language you cannot read still gets indexed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other Markets Use Other Engines and Channels
&lt;/h2&gt;

&lt;p&gt;Do not assume Google is the whole picture everywhere. Several markets have search engines of their own: Yandex, Seznam and Naver are among the engines that take part in IndexNow, as I describe in the &lt;a href="https://iurii.rogulia.fi/blog/indexnow-for-developers" rel="noopener noreferrer"&gt;IndexNow article&lt;/a&gt;. I am not giving you market-share numbers, because I have no verified ones and a made-up percentage helps nobody.&lt;/p&gt;

&lt;p&gt;Treat this as a prompt to check. Before building a market, find out which search engines and which other channels your buyers there actually use: marketplaces, social platforms, local directories. If the answer is not just Google, the plan changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Local Means: Per Market, Not a Map Listing
&lt;/h2&gt;

&lt;p&gt;Back to the definition. Most people searching for local SEO services want help with a Google Business Profile, map results and citations for a business in one place. I do not offer that, and I would rather say so here than let you find out on a call.&lt;/p&gt;

&lt;p&gt;What does apply to a multilingual, multi-market site:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local phrasing.&lt;/strong&gt; The way people search for the same thing changes by country and sometimes by region. That belongs to the per-market research above.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Near-me behavior.&lt;/strong&gt; Searches tied to a physical place work in some markets for businesses that have a physical place. If you have a shop or an office customers visit, local structured data (LocalBusiness) is worth adding. If you sell online only, it does not apply and I will not add it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What is not included.&lt;/strong&gt; Google Business Profile management, citation building and review generation are not part of what I do. If you need those for one shop in one city, this is not the service, and a local agency will serve you better.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Who Maintains It
&lt;/h2&gt;

&lt;p&gt;A multilingual site is not finished when it launches. Every new page becomes as many pages as you have languages. Every change to the original has to reach the others, or the versions drift apart. And each page that is added, removed or moved has to be reflected in the hreflang set and in the sitemap alternates.&lt;/p&gt;

&lt;p&gt;That upkeep is the part that gets dropped, for the same reason reports get dropped: nobody owns it. I wrote about why in &lt;a href="https://iurii.rogulia.fi/blog/seo-audit-never-implemented" rel="noopener noreferrer"&gt;the article on SEO reports that never get implemented&lt;/a&gt;, and the multilingual version is the same problem multiplied by the number of languages.&lt;/p&gt;

&lt;p&gt;My monthly &lt;a href="https://iurii.rogulia.fi/services/seo-geo-optimization" rel="noopener noreferrer"&gt;SEO &amp;amp; AI Search Optimization&lt;/a&gt; service covers per-market and per-language keyword research, the technical layer including hreflang, per-market expansion for multilingual sites, and content in the languages your markets use, with a written report each month. Languages on one site are within scope. A second domain is quoted separately. The text in each target language needs a reviewer: your own translators, or a translation pipeline whose output your native speakers check. I do not claim fluency in your markets’ languages. The service costs €1,200 a month for the first six months and €800 a month after that, with no minimum term; you can end it at the end of any month and everything built stays yours. First measurable movement usually takes 2–4 months and longer in competitive markets, and I do not promise positions.&lt;/p&gt;

&lt;p&gt;
  slug="seo-geo-optimization"&lt;br&gt;
  text="Selling in more than one country? Per-market SEO, hreflang and content, monthly, no minimum term."&lt;br&gt;
/&amp;gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Who Should Not Buy This
&lt;/h2&gt;

&lt;p&gt;This is the wrong purchase if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You sell in one language in one market.&lt;/strong&gt; Nothing here applies to you, and the general SEO pages will serve you better.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You need Google Business Profile or map-pack work for one location.&lt;/strong&gt; That is local-agency work and I do not do it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You want guaranteed rankings.&lt;/strong&gt; I do not sell that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You do not want to publish each language properly.&lt;/strong&gt; If there is no one to review translations and no intent to maintain the versions, more languages will cost more than they return.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You have several domains and expect one price.&lt;/strong&gt; The scope is one site. A second domain is quoted separately.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Next Step
&lt;/h2&gt;

&lt;p&gt;Take the market you care about most. Check three things: whether its keyword research was done in that language, whether the hreflang set on your site is complete and reciprocal, and who is named as responsible for keeping both current.&lt;/p&gt;

&lt;p&gt;If you cannot answer one of those, &lt;a href="https://iurii.rogulia.fi/contact" rel="noopener noreferrer"&gt;write to me&lt;/a&gt; with the site and the markets, and I will tell you what is missing and whether it needs monthly work or a one-off fix. If the honest answer is that you should stay in fewer languages, I will say that too.&lt;/p&gt;

</description>
      <category>seo</category>
      <category>business</category>
      <category>i18n</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to Read a Fraud Rate: Denominators, Samples, Flagged Shares</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Mon, 16 Nov 2026 11:00:50 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/how-to-read-a-fraud-rate-denominators-samples-flagged-shares-7h0</link>
      <guid>https://dev.to/iurii_rogulia/how-to-read-a-fraud-rate-denominators-samples-flagged-shares-7h0</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published at &lt;a href="https://htpbe.tech/blog/how-to-read-pdf-fraud-statistics-denominators-samples" rel="noopener noreferrer"&gt;htpbe.tech&lt;/a&gt;. The version on htpbe.tech stays in sync with the latest detection algorithm — refer to it for the canonical text.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Someone hands you a number. A vendor deck puts a share on applications carrying an altered document. A survey says fraud is rising. An industry report puts a percentage on edited bank statements. You are about to put that number in a board paper, a business case or a risk-appetite memo. Before you do, find out what the number is a fraction of.&lt;/p&gt;

&lt;p&gt;This guide is for fraud operations and risk leads at lenders and fintechs, and for analysts and journalists who cite fraud figures. It also applies to our own &lt;a href="https://htpbe.tech/blog/pdf-integrity-report-september-2026" rel="noopener noreferrer"&gt;monthly integrity reports&lt;/a&gt;, and we use those as the worked examples, because we know exactly what went into them.&lt;/p&gt;

&lt;h2&gt;
  
  
  A rate is a ratio
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; every fraud rate is a numerator divided by a denominator. Before you cite one, ask five things. What was counted (the denominator)? Who supplied the items (the sample)? What does the label in the numerator actually mean? Over what period, with what method in force? And how large is the base? If any of the five is missing or has changed, the figure cannot carry the weight you want to put on it.&lt;/p&gt;

&lt;p&gt;None of this makes a statistic useless. The five questions tell you what the statistic is about, which is usually narrower than the headline suggests.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is in the denominator
&lt;/h2&gt;

&lt;p&gt;The same pipeline can produce different denominators depending on what you choose to count:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Checks&lt;/strong&gt; – every analysis that ran, including the same file submitted twice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unique documents&lt;/strong&gt; – each distinct file counted once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Users or applications&lt;/strong&gt; – each person or case counted once, however many files they sent.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These answer different questions. ‘What share of applications included an altered file’ is not the same question as ‘what share of analyses returned a flag’, and the two can differ a lot.&lt;/p&gt;

&lt;p&gt;Our own reports show how much the denominator matters. The &lt;a href="https://htpbe.tech/blog/pdf-integrity-report-february-2026" rel="noopener noreferrer"&gt;February&lt;/a&gt; and &lt;a href="https://htpbe.tech/blog/pdf-integrity-report-march-2026" rel="noopener noreferrer"&gt;March&lt;/a&gt; reports covered checks submitted through the website only. February reported 418 checks, of which 169 (40.4%) were flagged as modified. March reported 866 checks and 420 flagged (48.5%). From &lt;a href="https://htpbe.tech/blog/pdf-integrity-report-may-2026" rel="noopener noreferrer"&gt;May&lt;/a&gt; onwards, the reports covered checks from both the website and the API, so the base itself changed shape.&lt;/p&gt;

&lt;p&gt;From &lt;a href="https://htpbe.tech/blog/pdf-integrity-report-july-2026" rel="noopener noreferrer"&gt;July&lt;/a&gt; the reports state the denominator up front, in a section that comes before any number. It is all processed checks – completed analyses, not unique documents or unique users – and it includes our own internal and automated runs, plus retries. It is not deduplicated. The same file submitted twice counts twice.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://htpbe.tech/blog/pdf-integrity-report-april-2026" rel="noopener noreferrer"&gt;April&lt;/a&gt; is the extreme case. An internal test batch entered the dataset that month, and it was large enough to swamp the organic submissions. The report published no headline file count at all, because the total would have described mostly our own testing. Its shares were computed on the same mixed base, so they carry the same caveat: dropping a count does not repair the ratio built on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who is in the sample
&lt;/h2&gt;

&lt;p&gt;A denominator can be defined perfectly and still describe a skewed group. Selection effects decide who ends up in the sample, and in document fraud they are strong.&lt;/p&gt;

&lt;p&gt;People rarely run a check on a file they have no doubts about. They check the bank statement that looks slightly off, the invoice from a new supplier, the offer letter with an odd font. Developers testing an integration often send files they already know are edited, because that is how you confirm the integration returns a flag. So the files that reach any tamper-detection tool lean towards the doubtful before a single analysis runs.&lt;/p&gt;

&lt;p&gt;This is not peculiar to us. The same logic applies to every source:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;vendor’s&lt;/strong&gt; figure describes the files its customers chose to send it, from the segments those customers serve.&lt;/li&gt;
&lt;li&gt;An &lt;strong&gt;insurer’s&lt;/strong&gt; figure describes the claims that reached its investigation unit, which were often referred because something looked wrong.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;survey&lt;/strong&gt; describes the people who answered it, and respondents who have had a fraud problem may be keener to reply.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every sample is selected somehow, so whether one is biased is the wrong question. Ask which way the selection pushes, and whether the source tells you.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a ‘flagged’ share is and is not
&lt;/h2&gt;

&lt;p&gt;In our reports, a flagged share is the share of checks that HTPBE returned as structurally modified – the file shows evidence that it was changed after it was created. That is all it is.&lt;/p&gt;

&lt;p&gt;It is &lt;strong&gt;not&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;a fraud rate or prevalence&lt;/strong&gt; – it does not tell you how often documents in circulation are altered, only what share of the checks run through HTPBE were returned as modified;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;accuracy, precision, recall or a false-positive rate&lt;/strong&gt; – those can only be measured against files whose true status is already known, and a production share has no such labels;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;a detection rate&lt;/strong&gt; – you cannot say what share of altered files were found without knowing how many altered files there were.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A higher or lower share says nothing on its own about how good a detector is. A tool that flagged every file would top any share chart and be worthless.&lt;/p&gt;

&lt;p&gt;Two more distinctions matter. First, &lt;code&gt;modified&lt;/code&gt; is not the same as fraudulent. A modification is a fact about the file; it does not establish intent, and many edits are harmless – an issuer correcting a typo, a redaction, several documents combined into one file. Second, the other outcomes are not ‘pass’ results. &lt;code&gt;intact&lt;/code&gt; means no modification was detected, not that the document is genuine. &lt;code&gt;inconclusive&lt;/code&gt; is a separate outcome: the evidence in the file cannot rule modification in or out. It is not a mark against the document, and it is not a softer version of &lt;code&gt;modified&lt;/code&gt;. Our guide to &lt;a href="https://htpbe.tech/blog/what-inconclusive-means-pdf-verification-results" rel="noopener noreferrer"&gt;what inconclusive means&lt;/a&gt; covers it in more detail.&lt;/p&gt;

&lt;p&gt;Watch for buckets that merge outcomes. The February report’s figure for files not returned as modified, 249, combined 211 &lt;code&gt;intact&lt;/code&gt; and 38 &lt;code&gt;inconclusive&lt;/code&gt;. Read as one number, it looks like 249 files with nothing to report. It was two different results.&lt;/p&gt;

&lt;p&gt;Keep &lt;strong&gt;prevalence&lt;/strong&gt; and &lt;strong&gt;conditional shares&lt;/strong&gt; apart as well. The July report gave two figures for a single structural property: how many of all processed checks carried it (about one in ten) and how many of those were flagged (almost all). ‘Almost all of these were flagged’ and ‘about one in ten checks carried this property’ answer different questions. Quoting the first as if it were the second turns a narrow observation into a sweeping one.&lt;/p&gt;

&lt;p&gt;Small bases need the same care. In February only 11 files were digitally signed, and 3 of them had been changed after signing. The report itself treats that as an observation, not a rate. On a base that small, a single file changing category moves the percentage sharply.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing months or sources
&lt;/h2&gt;

&lt;p&gt;When a share moves between two periods, two things can have changed: the population and the ruler.&lt;/p&gt;

&lt;p&gt;The population is what came in. The ruler is the method that classified it. In our case the ruler moves often – between eight and twenty-nine algorithm versions shipped each month from March to September, with May’s twenty-nine the heaviest. The March report said plainly that its month-to-month changes mix the two effects and that it does not separate them. The July report described its figures as a blend of ‘a moving population and a moving ruler’. The label set itself changed as well: in March, the three-outcome model was in force only from 8 March, and earlier checks that month were reported only as modified or not flagged.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://htpbe.tech/blog/pdf-integrity-report-june-2026" rel="noopener noreferrer"&gt;June report&lt;/a&gt; is the clearest example. May’s flagged share was roughly seven in ten; June’s was just under half. The June report attributes the difference almost entirely to traffic composition – about four in five June checks came through the website, while May had leaned heavily towards the API. In its own words: ‘Same engine, same thresholds, a very different headline number.’ That is the report’s reading, not a controlled test: the ruler did not stand still either, with sixteen algorithm versions shipping in June.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://htpbe.tech/blog/pdf-integrity-report-august-2026" rel="noopener noreferrer"&gt;August&lt;/a&gt; report marks one of its comparisons as directional only, because no significance test was run. That caution applies widely: a small difference between two periods may simply be noise.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://htpbe.tech/blog/pdf-integrity-report-september-2026" rel="noopener noreferrer"&gt;September report&lt;/a&gt; goes further and says it is not directly comparable with August, because the intake differed and parts of the measurement and classification changed within the month.&lt;/p&gt;

&lt;p&gt;So when two figures from different months or different sources disagree, the first question is not ‘what happened in the world?’ It is ‘what changed in the intake, and what changed in the method?’&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading industry figures
&lt;/h2&gt;

&lt;p&gt;Most document-fraud figures in circulation come from one of three types of source. Each measures something real, and none measures ‘how much fraud exists’.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complaint and incident registries&lt;/strong&gt; count reported cases. They depend on victims knowing they were defrauded, knowing where to report it and bothering to do so. A rise can mean more fraud, more awareness, or an easier reporting form. Ask: who reports here, and what changed about reporting?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vendor customer samples&lt;/strong&gt; describe what reached that vendor’s customers. They reflect the vendor’s market segments, its customers’ intake and its own definitions of ‘fraud’ or ‘suspect’. Ask: what is the denominator, which customers are included, and what exactly does the label mean?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Market-research estimates and forecasts&lt;/strong&gt; are modelled. They combine assumptions, survey inputs and extrapolation. Ask: what are the inputs, what is assumed, and is this a measurement or a projection?&lt;/p&gt;

&lt;p&gt;For the external loss figures themselves, with sources, see our &lt;a href="https://htpbe.tech/blog/document-fraud-statistics-2026" rel="noopener noreferrer"&gt;document fraud statistics roundup&lt;/a&gt;. Read each one with the questions above.&lt;/p&gt;

&lt;h2&gt;
  
  
  Five questions to ask before citing any rate
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What is the denominator?&lt;/strong&gt; Checks, documents, users or applications – and are retries, duplicates and internal runs included?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who is in the sample?&lt;/strong&gt; How did items get there, and which way does that selection push the figure?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What does the label mean?&lt;/strong&gt; ‘Fraud’, ‘suspect’, ‘flagged’ and ‘modified’ are different claims. Does the source define its terms?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What period and what method?&lt;/strong&gt; Did the population or the method change during the period, or between the periods being compared?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How large is the base, and was anything tested?&lt;/strong&gt; A share on eleven items, or a difference with no significance test, is an observation, not a finding.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If a source cannot answer these, quote it with that caveat attached, or do not quote it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where our figures live
&lt;/h2&gt;

&lt;p&gt;Our running aggregate is on the &lt;a href="https://htpbe.tech/statistics" rel="noopener noreferrer"&gt;statistics page&lt;/a&gt;, which shows the date it was last updated; each monthly integrity report describes one month’s dataset. Both cover what reached HTPBE and how HTPBE classified it, not rates of fraud in the world. Each report sets out its own sample and its own limits – from July onwards, with the denominator stated before any number. If you cite them, cite the update date or the month, and carry the caveat with the number.&lt;/p&gt;

&lt;p&gt;If what you need is a structural signal on your own documents rather than a statistic about other people’s, the &lt;a href="https://htpbe.tech/api" rel="noopener noreferrer"&gt;API&lt;/a&gt; returns &lt;code&gt;intact&lt;/code&gt;, &lt;code&gt;modified&lt;/code&gt; or &lt;code&gt;inconclusive&lt;/code&gt; for each PDF you send. It reports whether the file shows structural evidence of change after it was created. It does not tell you whether the content is true.&lt;/p&gt;

</description>
      <category>pdf</category>
      <category>fraud</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why Some EU VAT Numbers Belong to a Person, Not a Company</title>
      <dc:creator>Iurii Rogulia</dc:creator>
      <pubDate>Mon, 16 Nov 2026 10:00:50 +0000</pubDate>
      <link>https://dev.to/iurii_rogulia/why-some-eu-vat-numbers-belong-to-a-person-not-a-company-187k</link>
      <guid>https://dev.to/iurii_rogulia/why-some-eu-vat-numbers-belong-to-a-person-not-a-company-187k</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally published at &lt;a href="https://vatnode.dev/blog/vat-numbers-for-individuals-vs-companies" rel="noopener noreferrer"&gt;vatnode.dev&lt;/a&gt;. The version on vatnode.dev is the canonical source — refer to it for the latest content.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A VAT-registered sole trader is a taxable person and holds a VAT number the same way a company does. In some countries that number is built from the person’s national ID. Either way, if the holder is a natural person, the number is personal data. To see what a specific number returns, paste it into the &lt;a href="https://vatnode.dev/check" rel="noopener noreferrer"&gt;free checker&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is general information about how EU VAT numbers relate to personal data, not legal or tax advice. How the GDPR and national rules apply to your processing depends on your setup and the countries you operate in; confirm it with qualified counsel.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can an individual have an EU VAT number?
&lt;/h2&gt;

&lt;p&gt;Yes, if they are VAT-registered. Article 9(1) of the VAT Directive (2006/112/EC) defines a taxable person as ‘any person who, independently, carries out in any place any economic activity’. Legal form is not a criterion, so a natural person qualifies. Article 214 has member states identify taxable persons with an individual number, and Article 215 adds a country prefix (Greece may use &lt;code&gt;EL&lt;/code&gt;). A sole trader who is VAT-registered has a number; depending on national small-business rules, some have none.&lt;/p&gt;

&lt;p&gt;For B2B rules, legal form is irrelevant: a sole trader acting as a taxable person is treated like a company. A valid number is still a presumption, not a guarantee. Under Article 18(1) of Implementing Regulation (EU) 282/2011, unless the supplier has information to the contrary, it may treat a customer as a taxable person if the customer communicated a VAT number and the supplier obtained confirmation of its validity and of the name and address that go with it. Under Article 19, services received exclusively for private use count as received by a non-taxable person, unless the supplier can treat them as business use because the customer gave its VAT number and nothing points the other way, such as the nature of the services. What applies to a given transaction is a question for your tax adviser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which VAT numbers are built from a personal ID
&lt;/h2&gt;

&lt;p&gt;The EU fixes only the prefix. The rest is national, and in some countries a sole trader’s national ID goes straight in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sweden.&lt;/strong&gt; According to Skatteverket, the VAT number is &lt;code&gt;SE&lt;/code&gt;, ten digits and &lt;code&gt;01&lt;/code&gt;. For an enskild firma (sole trader) the ten digits are the personnummer; for a company or association, the organisationsnummer. An organisationsnummer’s third digit is always at least 2, to avoid confusion with a personnummer, which starts with year and month so its third digit is 0 or 1. The last digit of a personnummer is a modulus-10 check digit (weights 1 and 2). Legal form cannot be read from an organisationsnummer. See &lt;a href="https://vatnode.dev/blog/validate-swedish-vat-number-nodejs" rel="noopener noreferrer"&gt;validating Swedish VAT numbers in Node.js&lt;/a&gt; and the &lt;a href="https://vatnode.dev/vat-api/se" rel="noopener noreferrer"&gt;Sweden VAT API&lt;/a&gt; page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spain.&lt;/strong&gt; According to the AEAT, the VAT number is &lt;code&gt;ES&lt;/code&gt; plus the NIF. For natural persons the NIF is a DNI (eight digits and a control letter), a NIE (X, then Y or Z, seven digits and a letter), or a K, L or M form (K for Spaniards under 14 resident in Spain, L for Spaniards resident abroad, M for foreigners without an NIE). Legal persons and entities get a letter showing the legal form (for example A sociedad anónima, B sociedad limitada, G asociaciones, H comunidades de propietarios, P, Q and S public bodies, N foreign entities, W permanent establishments), seven digits and a control character. An autónomo’s NIF is their DNI or NIE. A Spanish business also needs an ROI registration (Registro de Operadores Intracomunitarios) for its NIF to work as an intra-EU VAT number in VIES, and not every autónomo has one. See &lt;a href="https://vatnode.dev/blog/validate-spanish-vat-number-nodejs" rel="noopener noreferrer"&gt;Spanish VAT numbers in Node.js&lt;/a&gt; and the &lt;a href="https://vatnode.dev/vat-api/es" rel="noopener noreferrer"&gt;Spain VAT API&lt;/a&gt; page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Czech Republic.&lt;/strong&gt; The DIČ is &lt;code&gt;CZ&lt;/code&gt; plus a stem. For natural persons the stem is the rodné číslo (birth number). According to the GFŘ, the Czech tax administration, a natural person can since 1 January 2021 apply for an identifier assigned by the tax administrator instead, and it replaces the stem. So a Czech individual’s DIČ is often, not always, built on the rodné číslo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Netherlands&lt;/strong&gt; went the other way. From 1 January 2020 a Dutch sole trader’s btw-id (&lt;code&gt;NL&lt;/code&gt;, nine digits, &lt;code&gt;B&lt;/code&gt;, two digits) no longer contains the BSN. The BSN-based omzetbelastingnummer is for dealings with the Belastingdienst only, and entering it instead of the btw-id is a common reason for a VIES ‘invalid’ result. See &lt;a href="https://vatnode.dev/blog/validate-dutch-vat-number-nodejs" rel="noopener noreferrer"&gt;validating Dutch VAT numbers&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to tell a person from a company by the number
&lt;/h2&gt;

&lt;p&gt;Sweden and Spain let you guess from the string:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Country&lt;/th&gt;
&lt;th&gt;Natural person&lt;/th&gt;
&lt;th&gt;Legal person or entity&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sweden&lt;/td&gt;
&lt;td&gt;10-digit block with third digit 0 or 1 (personnummer or samordningsnummer shape)&lt;/td&gt;
&lt;td&gt;third digit 2 or higher&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Spain&lt;/td&gt;
&lt;td&gt;NIF starts with a digit, or K, L, M, X, Y, Z&lt;/td&gt;
&lt;td&gt;NIF starts with A–H, J, N, P–S, U, V or W&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In other countries the number does not reliably show it, and the holder may still be a person:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Poland.&lt;/strong&gt; A sole trader’s VAT number is &lt;code&gt;PL&lt;/code&gt; plus the NIP. Polish law (art. 3(2) of the act on registering and identifying taxpayers) says the NIP may not carry a meaning describing the taxpayer’s features. Natural persons who are neither VAT-registered nor in business use their PESEL as the tax identifier; a VAT-registered sole trader uses a NIP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Italy.&lt;/strong&gt; A sole trader’s partita IVA is an 11-digit number, separate from their 16-character personal codice fiscale.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;France.&lt;/strong&gt; An entrepreneur individuel gets a SIREN like a company; the VAT number is &lt;code&gt;FR&lt;/code&gt;, a key and the SIREN.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Germany.&lt;/strong&gt; The USt-IdNr comes from the BZSt and is separate from the Steuernummer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Greece.&lt;/strong&gt; The ΑΦΜ is nine digits, and there is no reliable way to tell individuals from entities.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Format describes how an identifier is built; it never proves VIES registration, and a ‘this is a person’ guess from format stays a guess. See &lt;a href="https://vatnode.dev/blog/vat-id-format-vs-valid" rel="noopener noreferrer"&gt;format vs valid&lt;/a&gt;. Or run a number through the &lt;a href="https://vatnode.dev/check" rel="noopener noreferrer"&gt;free checker&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the API response tells you, and what it doesn’t
&lt;/h2&gt;

&lt;p&gt;The endpoint is &lt;code&gt;GET https://api.vatnode.dev/v1/vat/{vatId}&lt;/code&gt; with &lt;code&gt;Authorization: Bearer &amp;lt;key&amp;gt;&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.vatnode.dev/v1/vat/SE820115123401 \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $VATNODE_API_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response is trimmed and illustrative. The number is fictitious: it fails the national check digit, so it cannot be issued, and a real call with it would not come back valid. A successful check has this shape, trimmed to the identifier fields:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"valid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"vatId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"SE820115123401"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"countryCode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"SE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"registryCode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"registryCodeName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"taxId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"taxIdName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;There is no field for the type of holder.&lt;/strong&gt; &lt;code&gt;valid&lt;/code&gt; works the same regardless of legal form.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Null identifier fields don’t mean nothing personal is there.&lt;/strong&gt; For a Swedish number whose ten-digit block has a third digit of 0 or 1, &lt;code&gt;registryCode&lt;/code&gt;, &lt;code&gt;registryCodeName&lt;/code&gt;, &lt;code&gt;taxId&lt;/code&gt; and &lt;code&gt;taxIdName&lt;/code&gt; are all &lt;code&gt;null&lt;/code&gt;. The same holds for a Czech suffix of 9 or 10 digits and a Bulgarian 10-digit suffix. &lt;code&gt;vatId&lt;/code&gt; still carries the full number.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other numbers come back as they appear.&lt;/strong&gt; For Spain &lt;code&gt;taxId&lt;/code&gt; is the NIF exactly as it follows &lt;code&gt;ES&lt;/code&gt;, person or entity, with &lt;code&gt;taxIdName&lt;/code&gt; &lt;code&gt;Número de Identificación Fiscal&lt;/code&gt;. &lt;code&gt;ES87654321A&lt;/code&gt; (fictitious, fails the DNI letter) comes back, on a live result, with &lt;code&gt;"valid": false&lt;/code&gt; and still &lt;code&gt;"taxId": "87654321A"&lt;/code&gt;, so a populated &lt;code&gt;taxId&lt;/code&gt; does not mean the number is valid. Greek and Polish numbers work the same way. For an organisation-shaped Swedish number such as &lt;code&gt;SE556123456801&lt;/code&gt; (also fictitious, and it fails the check digit), &lt;code&gt;registryCode&lt;/code&gt; and &lt;code&gt;taxId&lt;/code&gt; are &lt;code&gt;NNNNNN-NNNN&lt;/code&gt;, named &lt;code&gt;organisationsnummer&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Name and address can be personal.&lt;/strong&gt; &lt;code&gt;companyName&lt;/code&gt; and &lt;code&gt;companyAddress&lt;/code&gt; can contain a person’s own name and address when the holder is a sole trader.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test keys won’t show it.&lt;/strong&gt; A &lt;code&gt;vat_test_&lt;/code&gt; key accepts only &lt;code&gt;XX&lt;/code&gt; fixture numbers and returns &lt;code&gt;taxId: null&lt;/code&gt;, so the difference is visible only with a live key. The &lt;a href="https://vatnode.dev/register" rel="noopener noreferrer"&gt;free plan&lt;/a&gt; includes live checks and needs no card. The field is covered in &lt;a href="https://vatnode.dev/blog/national-tax-id-from-vat-number" rel="noopener noreferrer"&gt;national tax ID inside an EU VAT number&lt;/a&gt;, and per-country behaviour in the &lt;a href="https://vatnode.dev/docs/coverage" rel="noopener noreferrer"&gt;coverage reference&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What changes when the holder is a person
&lt;/h2&gt;

&lt;p&gt;When the holder is a natural person, the VAT number relates to an identified or identifiable individual, so it is personal data under Article 4(1) GDPR whatever its format. That includes a partita IVA, a SIREN-based French number and a Dutch btw-id that is not derived from the BSN. Where the holder is unknown, it may be personal data. A company’s VAT number is generally not.&lt;/p&gt;

&lt;p&gt;Some sole traders’ numbers also contain a national identification number: a Swedish personnummer, a Spanish DNI or NIE, a Czech rodné číslo. Article 87 GDPR lets each member state set specific conditions for processing one, so the national rule applies on top of the GDPR. In Sweden, for example, Lag (2018:218) med kompletterande bestämmelser till EU:s dataskyddsförordning, 3 kap. 10 §, allows personnummer and samordningsnummer to be processed without consent only where clearly justified by the purpose, the importance of secure identification or another significant reason. That is not an EU-wide rule. A Greek ΑΦΜ or a Polish NIP is a tax number rather than a national ID number. Whether a country’s Article 87 rules reach it is a question for local counsel. Either way, an individual’s tax number identifies them, so it is personal data too.&lt;/p&gt;

&lt;p&gt;Where an invoice has to show the customer’s VAT number, for example under reverse charge (Article 226(4) of the VAT Directive), keeping it on that invoice is generally a matter of legal obligation (Article 6(1)(c) GDPR). Not every invoice must carry it. Other uses of the same number, such as onboarding checks or monitoring, need their own basis, which is part of your own analysis.&lt;/p&gt;

&lt;p&gt;None of the following is a specific legal requirement. They are common ways to apply data minimisation (Article 5(1)(c)), data protection by design (Article 25) and security of processing (Article 32):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep the number with the customer or invoice record it belongs to. There is rarely a reason to copy it, or a personal ID parsed out of it, into separate columns, logs, analytics events, URLs, search indexes or support exports.&lt;/li&gt;
&lt;li&gt;Consider masking it in internal UIs where staff don’t need the full number.&lt;/li&gt;
&lt;li&gt;Invoice-bound numbers follow invoice retention. Numbers from checks that never led to an invoice (prospects, abandoned sign-ups, typos) have no invoice obligation and need their own, usually shorter, justification; the period is jurisdiction-specific, so confirm it with counsel.&lt;/li&gt;
&lt;li&gt;Where you can’t tell person from company, treat the record as potentially personal.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Retention and erasure are covered in &lt;a href="https://vatnode.dev/blog/gdpr-vat-data-storage" rel="noopener noreferrer"&gt;storing VAT data under GDPR&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Assuming every sole trader has a VAT number, or that a valid number always means reverse charge.&lt;/li&gt;
&lt;li&gt;Reading person vs company from the string in countries that don’t encode it.&lt;/li&gt;
&lt;li&gt;Reading a null &lt;code&gt;taxId&lt;/code&gt; as ‘nothing personal here’.&lt;/li&gt;
&lt;li&gt;Logging the whole API response, including &lt;code&gt;companyName&lt;/code&gt; and &lt;code&gt;companyAddress&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can a sole trader have an EU VAT number?
&lt;/h3&gt;

&lt;p&gt;Yes, if the sole trader is VAT-registered. EU VAT law defines a taxable person by the economic activity carried out, not by legal form, so a natural person qualifies and is identified with an individual VAT number like a company. Depending on national small-business rules, some sole traders have no VAT number at all. This is general information, not tax advice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is an EU VAT number personal data under GDPR?
&lt;/h3&gt;

&lt;p&gt;When the holder is a natural person, yes. The number relates to an identified or identifiable individual, so it is personal data under Article 4(1) GDPR whatever its format. A company’s VAT number is generally not personal data, and where you cannot tell who the holder is, it may be. This is general information, not legal advice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is a Swedish VAT number the same as a personnummer?
&lt;/h3&gt;

&lt;p&gt;Not in general. A Swedish VAT number is SE, ten digits and 01. For a sole trader (enskild firma) the ten digits are the personnummer, so the VAT number contains it. For a company or association they are the organisationsnummer instead. Where the VAT number contains a personnummer, it is personal data and Swedish rules on national identification numbers apply on top of the GDPR. This is general information, not legal advice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is the Spanish NIF of a freelancer (autónomo) their DNI?
&lt;/h3&gt;

&lt;p&gt;Yes. An autónomo’s NIF is their DNI, or their NIE if they are a foreigner, and the Spanish VAT number is ES followed by it. To use the number in intra-EU trade, a Spanish business also needs an ROI registration, and not every autónomo has one, so a correctly built number does not prove VIES registration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I tell from a VAT number whether it belongs to a person or a company?
&lt;/h3&gt;

&lt;p&gt;Sometimes, by format. Spanish numbers starting with a digit or K, L, M, X, Y, Z are natural persons, and a Swedish 10-digit block whose third digit is 0 or 1 has the shape of a personnummer or samordningsnummer. In Poland the law bars the NIP from carrying such a meaning; in Italy, France, Germany and Greece the number does not reliably show it. Format describes how the number is built, so a guess from format is only a guess.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does the vatnode API say whether a VAT number belongs to a person?
&lt;/h3&gt;

&lt;p&gt;No. The response has no field for the type of holder. valid works the same regardless of legal form, and companyName and companyAddress can contain a sole trader’s own name and address. A null taxId does not mean the response holds no personal number, because vatId carries the full number. You can see what a given number returns with a free key or the free checker.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Check a number, then decide what to keep
&lt;/h3&gt;

&lt;p&gt;Run any VAT number through the &lt;a href="https://vatnode.dev/check" rel="noopener noreferrer"&gt;free checker&lt;/a&gt;, or &lt;a href="https://vatnode.dev/register" rel="noopener noreferrer"&gt;get a free API key&lt;/a&gt; (no card) and read the response fields from your own code. The request and response are in the &lt;a href="https://vatnode.dev/docs" rel="noopener noreferrer"&gt;API docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is general information about how EU VAT numbers relate to personal data, not legal or tax advice. How the GDPR and national rules apply to your processing depends on your setup and the countries you operate in; confirm it with qualified counsel.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>tax</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
