Logo
30 Days of Postman API Documentation

Create Mock

POST https://api.getpostman.com/mocks

This endpoint allows you to create a mock on a collection. You can also provide an environment UID to resolve any environment variables in the collection.

You can also specify the context of a workspace to create a mock in directly by passing the workspace as a query param.

Requires API Key as X-Api-Key request header or apikey URL query parameter.

 

Body PARAM

Key Datatype Required Description 



HEADERS

Key Datatype Required Description 
Content-Type
string




RESPONSES

status OK

{"mock":{"id":"0fca2246-c108-41f5-8454-cc032def329f","owner":"1679925","uid":"1679925-0fca2246-c108-41f5-8454-cc032def329f","collection":"1679925-39fee52f-b806-3ffa-1173-00a6f5b183dc","environment":"1679925-0b9e9f15-3208-a2b1-22e0-d58392f01524","mockUrl":"https://0fca2246-c108-41f5-8454-cc032def329f.mock.pstmn.io"}}



Curl
curl -X POST 'https://api.getpostman.com/mocks' -H 'Content-Type: application/json' -d '{"mock":{"collection":"1679925-39fee52f-b806-3ffa-1173-00a6f5b183dc","environment":"1679925-0b9e9f15-3208-a2b1-22e0-d58392f01524"}}'

ENDPOINTS