Forms / IRS
Fill Form W-8BEN programmatically
Form W-8BEN — Certificate of Foreign Status of Beneficial Owner (Individuals). Official IRS PDF, 1 page, 23 fields read automatically.
The moment a platform pays people outside the US, every one of them owes it a W-8BEN before the first payout. It is one page, but it is one page per contractor, forever — and the contractor filling it is the person least likely to know what a Chapter 3 treaty claim is. Platforms end up collecting the answers in their own onboarding UI anyway; the form itself should be produced by code.
What you send
Real field names, straight from the PDF — the excerpt shows the first 5 of 23. The full list is in the table below, and the template hands you the complete JSON schema to copy.
{
"data": {
"topmostSubform[0].Page1[0].f_1[0]": "string",
"topmostSubform[0].Page1[0].f_2[0]": "string",
"topmostSubform[0].Page1[0].f_3[0]": "string",
"topmostSubform[0].Page1[0].f_4[0]": "string",
"topmostSubform[0].Page1[0].f_5[0]": "string"
}
}
// …plus 17 more fields, all listed belowWhat you get back
The completed Form W-8BEN, streamed back as the response — or delivered to your webhook, HMAC-signed.
curl -X POST https://www.doc2api.co/api/v1/templates/<ID>/fill \ -H "X-Api-Key: d2a_live_…" \ -H "Content-Type: application/json" \ -d @payload.json -o filled.pdf # → the completed Form W-8BEN as a PDF. # With a webhook configured, the reply is JSON and the # document arrives at your endpoint as a signed URL.
Or skip the mapping entirely: embed the actual form on your site and let the person it belongs to fill and sign it — you receive the values as JSON and the finished PDF.
Every field on Form W-8BEN
Extracted automatically from the official PDF — this table is generated by the same code that reads your uploads. In the editor, each of these is highlighted on the page itself, so you never map a name blind.
| Field name | Type | Notes |
|---|---|---|
| topmostSubform[0].Page1[0].f_1[0] | text | |
| topmostSubform[0].Page1[0].f_2[0] | text | |
| topmostSubform[0].Page1[0].f_3[0] | text | |
| topmostSubform[0].Page1[0].f_4[0] | text | |
| topmostSubform[0].Page1[0].f_5[0] | text | |
| topmostSubform[0].Page1[0].f_6[0] | text | |
| topmostSubform[0].Page1[0].f_7[0] | text | |
| topmostSubform[0].Page1[0].f_8[0] | text | |
| topmostSubform[0].Page1[0].f_9[0] | text | max 11 chars |
| topmostSubform[0].Page1[0].f_10[0] | text | |
| topmostSubform[0].Page1[0].c1_01[0] | checkbox | |
| topmostSubform[0].Page1[0].f_11[0] | text | |
| topmostSubform[0].Page1[0].f_12[0] | text | max 10 chars |
| topmostSubform[0].Page1[0].f_13[0] | text | |
| topmostSubform[0].Page1[0].f_14[0] | text | |
| topmostSubform[0].Page1[0].f_15[0] | text | |
| topmostSubform[0].Page1[0].f_16[0] | text | |
| topmostSubform[0].Page1[0].f_17[0] | text | |
| topmostSubform[0].Page1[0].f_18[0] | text | |
| topmostSubform[0].Page1[0].c1_02[0] | checkbox | |
| topmostSubform[0].Page1[0].f_20[0] | signature | |
| topmostSubform[0].Page1[0].Date[0] | text | max 10 chars |
| topmostSubform[0].Page1[0].f_21[0] | text |
One page, but the dates are picky
The W-8BEN wants its date signed as MM-DD-YYYY, which is exactly the kind of rule that survives in a wiki until the day it doesn't. Per-field logic lets you compute and validate values server-side before they reach the PDF, so the format lives next to the field it governs rather than in your application code.
Questions people ask
- Can the contractor fill it themselves?
- Yes — embed the real PDF on your onboarding page with the SDK. You can prefill what you already know (name, country), lock those fields read-only with a form profile, and leave the contractor the parts only they can answer, including the signature.
- What about W-8BEN-E for companies?
- Upload it the same way — any fillable PDF works. The gallery lists the forms we ship demo pages for, not the limit of what the API accepts.
See your Form W-8BEN pipeline working in the next five minutes
The button uploads the official PDF into the editor as a live template with an API key — no account, nothing to cancel. Trial documents are watermarked and kept for 24 hours; sign up to keep your work.
Doc2api is not affiliated with the Internal Revenue Service. Form W-8BEN is a public government work; the copy here is the official revision, refreshed from irs.gov. Nothing on this page is tax or legal advice — how a completed form may be signed, filed or retained is defined by the issuing agency.
Weighing this against another tool
Each comparison opens with where the other product is the better choice, because you are going to make the comparison anyway.
- Doc2api vs DocSpring
A PDF-filling API. You upload a PDF, map its fields in their editor, and POST data to generate a filled document.
- Doc2api vs Anvil
A document-workflow platform: PDF filling, multi-step workflows, and Etch e-signature packets, with a dashboard as well as an API.
- Doc2api vs PDFMonkey
A PDF generator built around templates you design in HTML, CSS and Liquid, rendered to PDF from JSON you post.
- Doc2api vs Documint
A document generator with its own drag-and-drop template designer, driven by an API or by integrations.
- Doc2api vs Formstack Documents
Document generation inside the wider Formstack suite, alongside their forms and e-signature products.
- Doc2api vs Api2Pdf
A pay-as-you-go rendering API. You send HTML or a URL and it returns a PDF, billed on bandwidth and compute rather than per document.
Documents you design, rather than ones you were handed
Form W-8BEN is a PDF the IRS laid out, and the API reproduces it exactly. The same account builds documents from nothing — these are the ones that tend to come up alongside it.
- Generate invoice PDFs from JSON
The vendor you just onboarded sends you an invoice — that one you design yourself.
- Generate receipt PDFs from JSON
And the payout confirmation that goes back to them once it clears.