The Postman Collection v2.1 format, explained
The Postman Collection format is the closest thing API clients have to a shared file format. Postman exports it, and Requestarium, Insomnia, Bruno, Hoppscotch and most other clients import it. Knowing what's inside helps when an import goes wrong, when you review a collection in a pull request, or when you generate one from code.
The smallest valid collection
{
"info": {
"name": "Users API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Get user",
"request": {
"method": "GET",
"url": "{{baseUrl}}/users/{{userId}}"
}
}
]
}info.schema says which version the file follows. Importers read it to decide how to parse the rest. info._postman_id is often there too; it's an id, not content.
Folders and requests
Everything in item is either a folder or a request:
{
"name": "Auth",
"item": [
{ "name": "Login", "request": { "method": "POST", "url": "{{baseUrl}}/login" } }
]
}An item with item is a folder. An item with request is a request. Folders nest as deep as you like, and their order in the array is the order the collection runner uses.
The request object
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "X-Debug", "value": "1", "disabled": true }
],
"url": {
"raw": "{{baseUrl}}/users?limit=10",
"host": ["{{baseUrl}}"],
"path": ["users"],
"query": [{ "key": "limit", "value": "10" }]
},
"body": {
"mode": "raw",
"raw": "{\"name\": \"Ada\"}",
"options": { "raw": { "language": "json" } }
},
"description": "Creates a user. Markdown is allowed here."
}urlcan be a plain string or an object. When it's an object,rawis the full URL and the other fields are its parsed parts. Importers usually trustraw.headerrows with"disabled": trueare kept but not sent.body.modeisraw,urlencoded,formdata,fileorgraphql. Each mode has a field of the same name with the content.descriptionis Markdown documentation.
Auth
Auth can sit on the collection, a folder or a request. A request without auth inherits from its folder, then from the collection. "type": "noauth" turns inheritance off.
In v2.1, each auth type is a list of key/value pairs:
"auth": {
"type": "bearer",
"bearer": [{ "key": "token", "value": "{{token}}", "type": "string" }]
}In v2.0, the same auth was an object: "bearer": { "token": "{{token}}" }. That's the main difference between the versions, and the reason an importer that only knows one of them can lose your auth silently.
Variables
"variable": [
{ "key": "baseUrl", "value": "https://api.example.com" },
{ "key": "userId", "value": "42" }
]These are collection variables. Environments are separate files (.postman_environment.json) with a values list, and each value can be "type": "secret". Globals are another file again.
Scripts
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test('status is 200', () => pm.response.to.have.status(200));",
"pm.environment.set('userId', pm.response.json().id);"
]
}
}
]exec is an array of lines, which makes diffs readable. listen is prerequest or test. Events can sit on the collection, on folders and on requests, and run in that order.
Saved responses
A request item can have a response list of saved examples, each with name, code, header and body. Docs tools and mock servers use them. Requestarium imports them as saved examples.
What survives a move between tools
The structure (folders, requests, headers, bodies, auth, variables) moves cleanly between most clients. What usually breaks:
- Scripts that call tool-specific APIs. Requestarium runs
pm.*as is, converts legacypostman.*calls, and listspm.sendRequest,pm.visualizerandpm.vaultas not supported. See Will my Postman scripts still work? - Auth types a tool doesn't have, such as NTLM.
- File bodies, because the file isn't in the JSON.
- Environments and globals, because they aren't in the collection file at all.
Exporting v2.1 from Requestarium
Export as… → Postman Collection v2.1 writes this format. If you tick environment groups in the dialog, you get a zip with the collection and one .postman_environment.json per environment. From the CLI:
requestarium export "Users API" --format postman --out users.postman_collection.jsonCredentials typed into auth fields are written as {{variables}}, so the file is safe to commit. See export a collection to Postman, Insomnia or Bruno.