*** title: Write your first test updated: 2025-12-12T00:00:00.000Z topictype: tutorial max-toc-depth: 2 ---------------- *API tests* are a way to ensure that your API is behaving as you expect it to. For example, you might write a test to validate your API's error handling by sending a request with incomplete data or wrong parameters. You can write tests for your Postman API requests in JavaScript and add them to individual [requests](/docs/sending-requests/create-requests/create-requests/), [collections](/docs/sending-requests/create-requests/intro-to-collections/), and folders in a collection. Postman includes code snippets you can add and then change to suit your test logic. To write a test, do the following: 1. Go to the request you made in [Send your first API request](/docs/getting-started/first-steps/sending-the-first-request/). 2. In the request, click the **Scripts** tab, then click **Post-response**. 3. Click Code icon **Snippets** at the lower right of the code editor, then select **Status code: Code is 200**. This will enter the following test code: ```javascript pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); ``` 4. Click **Send**. After the request runs, the test will run. In the response section, click **Test Results** to review the results of your test. To learn more about writing tests, go to [Write scripts to test API response data in Postman](/docs/tests-and-scripts/write-scripts/test-scripts/).