Logo
30-day challenge API Documentation

Mocks

Number of APIs: 13


1. Update a server response

PUT https://api.getpostman.com/mocks/{{mockId}}/server-responses/{{serverResponseId}}

Updates a mock server's server stub. Include at least one of the following properties in the request body:

  • name — A string that contains the server response's name.
  • statusCode — A string that contains the server stub's response code. This property only accepts 5xx values.
  • headers — An array of objects that contains the server stub's headers:
    • key — A string that contains the header's key.
    • value — A string that contains the header key's value. This value defines the corresponding value for the header key.
  • body — A string that contains a response body that returns when you call the mock server.



2. Get a mock server

GET https://api.getpostman.com/mocks/{{mockId}}

Gets information about a mock server.



3. Get a server response

GET https://api.getpostman.com/mocks/{{mockId}}/server-responses/{{serverResponseId}}

Gets information about a mock server's server stub.



4. Create a mock server

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

In Qodex v10 and higher you cannot create mocks for collections added to an API definition.

Creates a mock server in a collection. Include a mock object in the request body that contains following properties:

  • collection — A string that contains the collection ID.

You can include the following optional properties in the request body:

  • environment — A string that contains the environment ID to associate with the mock server.
  • name — A string that contains the the mock server's name.



5. Get all mock servers

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

Gets all mock servers.



6. Delete a mock server

DELETE https://api.getpostman.com/mocks/{{mockId}}

Deletes a mock server.



7. Unpublish a mock server

DELETE https://api.getpostman.com/mocks/{{mockId}}/unpublish

Unpublishes a mock server. Unpublishing a mock server sets its Access Control configuration setting to private.



8. Get all server responses

GET https://api.getpostman.com/mocks/{{mockId}}/server-responses

Gets all of a mock server's server responses.



9. Create a server response

POST https://api.getpostman.com/mocks/{{mockId}}/server-responses

Creates a server response. Server responses let you simulate 5xx server-level responses, such as 500 or 503.

Server-level responses are agnostic to application-level logic. Server responses let you simulate this behavior on a mock server. You do not need to define each error for all exposed paths on the mock server.

If you set a server response as active, then all the calls to the mock server return with that active server response.

Note:

You can create multiple server responses for a mock server, but only one mock server can be set as active.

You must include the following properties in the request body:

* name — A string that contains the server response's name. * statusCode — An integer that contains the server stub's 5xx response code. This property only accepts 5xx values.

You can also include the following optional properties:

* headers — An array of objects that contains the server stub's headers: * key — A string that contains the header's key. * value — A string that contains the header key's value. This value defines the corresponding value for the header key. * body — A string that contains a response body that returns when you call the mock server.



10. Delete a server response

DELETE https://api.getpostman.com/mocks/{{mockId}}/server-responses/{{serverResponseId}}

Deletes a mock server's server response.



11. Publish a mock server

POST https://api.getpostman.com/mocks/{{mockId}}/publish

Publishes a mock server. Publishing a mock server sets its Access Control configuration setting to public.



12. Update a mock server

PUT https://api.getpostman.com/mocks/{{mockId}}

Updates a mock server. Include the mock object in the request body with one or more of the following properties:

  • name — A string that contains the mock server's name.
  • environment — A string that contains the environment UID.
  • private — A boolean value that, if true, sets the mock server as private.
  • versionTag — A string that contains the API's version tag ID.
  • config — An object that contains the following properties:
    • serverResponseId — A string that contains the server response ID. This sets the given server response as the default response for each request.



13. Get a mock server's call logs

GET https://api.getpostman.com/mocks/{{mockId}}/call-logs

Gets a mock server's call logs. You can get a maximum of 6.5MB of call logs or a total of 100 call logs, whichever limit is met first in one API call.

Call logs contain exchanged request and response data made to mock servers. The logs provide visibility into how the mock servers are being used. You can log data to debug, test, analyze, and more, depending upon the use case.



ENDPOINTS