Sample files for API testing
Payloads and attachments for testing REST endpoints that receive, return or transform files.
APIs move files in three ways: as multipart form data, as a raw binary body, or encoded as base64 inside JSON. Each has its own limits and its own failure modes, and a thorough test suite sends the same file through every path the API supports.
Sample JSON and XML files double as request bodies and as mock responses, so they are useful on both sides of an integration.
Recommended files
| File | Size | Why this one | Download |
|---|---|---|---|
| Sample users JSON (array of 50 objects)sample-users.json | 14.3 KB14,668 bytes | A typical response body for mocks | Download JSON |
| 100 KB JSON samplesample-json-100kb.json | 100 KB102,400 bytes | Exactly on a 100 KB body limit | Download JSON |
| 1 MB JSON samplesample-json-1mb.json | 1 MB1,048,576 bytes | Over most default JSON limits | Download JSON |
| 100 KB PDF samplesample-pdf-100kb.pdf | 100 KB102,400 bytes | Small binary attachment | Download PDF |
| Nested JSON with every value typesample-nested-config.json | 829 B829 bytes | Every JSON value type in one file | Download JSON |
Checklist
Send a known-good request
Post a small file and check the status code, the response body and that the stored bytes match the checksum of what you sent.
Check the declared content type
Send a file with the wrong Content-Type header and confirm the API validates content rather than trusting the header.
Exceed the body limit
Send a payload over the documented limit and expect 413, with an error body in the API's normal format.
Send malformed data
Truncate a JSON file and confirm the API answers 400 rather than 500.
Download what you uploaded
Fetch the file back and compare SHA-256 checksums to prove nothing was altered.
Guides
- Using sample files for API testing
Three ways APIs receive files, with curl and fetch examples and the assertions that matter.
- How to test file upload: a complete checklist
A test plan for upload forms and endpoints, with the right sample file for every case.
- How to test MIME types and file type validation
Extensions, Content-Type headers and magic bytes: how to check that type validation cannot be fooled.
Related use cases
Frequently asked questions
- How do I send a sample file with curl?
- For multipart form data use curl -F "file=@sample-pdf-100kb.pdf" followed by the URL. For a raw body use --data-binary @sample-pdf-100kb.pdf with a Content-Type header.
- Why is my base64 upload rejected when the file is under the limit?
- Base64 makes data a third larger. A 5 MB file is about 6.7 MB as a base64 string, and the limit applies to the encoded body.
Test plan architecture and assertion matrix for sample files for api testing
A thorough api testing workflow separates positive functional verification (confirming well-formed inputs succeed and preserve their SHA-256 checksum) from negative boundary verification (confirming oversized, truncated, or mislabelled inputs fail with structured diagnostic codes).
| Test case ID | Scenario in api testing | Input fixture | Expected system outcome |
|---|---|---|---|
| TC-API--01 | Baseline small payload acceptance | 1 KB – 100 KB valid fixture from Formats | HTTP 200/201; stored byte count and SHA-256 match /checksums.txt |
| TC-API--02 | Gateway / reverse-proxy ceiling check | 1 MB, 10 MB, and 20 MB sized fixtures from Sizes | Exact threshold enforced; oversize payload returns HTTP 413 Payload Too Large |
| TC-API--03 | Extension vs. magic-byte mismatch | wrong-extension-png-as-jpg.jpg from Broken Files | Validator detects 89 50 4E 47 PNG header and rejects spoofed .jpg extension |
| TC-API--04 | Truncated stream / unexpected EOF | Truncated PDF or JPEG from Broken Files | Parser catches missing trailer/EOI marker and returns HTTP 422 without leaking stack traces |
Automating api testing in CI/CD pipelines
To keep automated runs deterministic and fast, commit your small sub-100 KB fixtures directly to your repository and synthesize larger 10 MB to 1 GB stress fixtures on demand using our in-browser generator or the reproducible local commands on Methodology. When testing tabular or relational data pipelines during api testing, pair binary container checks with our 100-row and 1,000-row synthetic datasets so you can assert exact row counts and column aggregations after ingestion.