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,664 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.