You can use the ServiceNow REST API Explorer to make HTTP requests directly from the browser and see the response, which is useful for testing and learning API behavior without writing code. The common mistake is trying to access the URL via the internal ServiceNow URL scheme (https://
Set Up Your Instance for API Access
ServiceNow requires a user account with the appropriate permissions to access the API. You cannot use the default admin account directly from the browser for API calls; instead, create a dedicated service account or a user with the api_user role assigned. This role grants the necessary privileges for programmatic access without giving full administrative control.
Go to User > Users and click New to create the user if one does not already exist. Fill in the form with a username, your preferred email, and a password. In the Roles field, type api_user and save the record. This user is now ready to authenticate against the API Explorer.
Locate the REST API Explorer URL
The REST API Explorer is a built-in tool that lets you construct and execute REST requests in a user interface. You must navigate to the correct URL so the browser can load the tool and handle authentication. The URL structure is consistent across instances. You can bookmark this page for quick access.
Open your browser and go to https://. Replace with the actual name of your ServiceNow instance. Once the page loads, append the path /api/now to the end of the URL and press Enter. You should see the REST API Explorer interface in your browser window.
If you are already logged into ServiceNow, the tool automatically detects your session. If you are not logged in, you will be prompted to sign in with your ServiceNow credentials. After signing in, the API Explorer will appear with the base path already set to /api/now.
Authenticate with Basic Authentication
The ServiceNow REST API uses HTTP Basic Authentication. This means you must provide a username and password for every request. The API Explorer provides a simple way to enter these credentials. You do not need to configure a proxy or configure SSL certificates manually.
- Look for the Authentication section in the left-hand panel of the API Explorer.
- Click on Basic to select this authentication method.
- In the Username field, enter the username of the user you created in the setup step.
- In the Password field, enter the password for that user.
When you click the Send Request button, the browser will encode your username and password and send them as the Authorization header in the request. ServiceNow verifies these credentials and returns a response if they are valid.
Construct a Simple Request with Real Numbers
Let’s make a concrete example of a request to list incidents. This example uses real ServiceNow data types and demonstrates a common pattern for reading data from the system.
1. Choose the HTTP method. Select GET from the dropdown menu next to the base path. This method is used to retrieve data without changing the state of the system.
2. Set the base path. The base path should already be set to /api/now/incident. This path tells ServiceNow to look at the Incident table.
3. Specify query parameters. In the Query field, you can filter the results. For this example, leave the field empty to get a list of all incidents. If you wanted to see only open incidents, you would enter state=1 in this field.
4. Send the request. Click the Send Request button. The API Explorer will display the response below the button.
5. Read the response. The response will be in JSON format. You will see a result array containing one JSON object for each incident found. Each object will have fields like number, short_description, and state. The number field is a unique identifier for the incident, such as INC0000123.
Understand the Response Status Codes
The response status code tells you if the request was successful or if something went wrong. You should always check this code first when debugging your API calls.
- 200 OK: The request was successful. The API Explorer will show the JSON response body in the result area.
- 401 Unauthorized: The username or password is incorrect. Double-check your credentials in the Authentication section and try again.
- 403 Forbidden: The user account does not have the necessary permissions to access the requested resource. Ensure the user you are using has the
api_userrole assigned. - 404 Not Found: The path you requested does not exist. Check the URL path for typos.
- 500 Internal Server Error: There is a problem with the ServiceNow server. Try again later or check the system logs if you have access.
Use Query Parameters for Filtering Data
Query parameters allow you to limit the amount of data you receive. Instead of fetching all records and filtering them yourself, you can ask ServiceNow to do the work. This makes your API calls faster and more efficient.
ServiceNow uses a simple query language. You can combine multiple parameters with an ampersand (&). Common parameters include sysparm_limit to limit the number of results and sysparm_query to filter records.
For example, to get the last 5 incidents and only those that are open, you would use the following query string:
sysparm_limit=5&sysparm_query=state=1
Enter this string into the Query field in the API Explorer. When you send the request, the API Explorer will return at most 5 incident records, and all of them will be in the open state.
Create a New Record with a POST Request
The API Explorer is not just for reading data; you can also create new records. To do this, you use the POST HTTP method. This method sends data to the server to create a new resource.
1. Choose the HTTP method. Change the dropdown from GET to POST.
2. Set the base path. Keep the base path as /api/now/incident.
3. Prepare the request body. Click on the Body tab or section. Select JSON from the format dropdown. You will see a text area where you can type the JSON data.
4. Enter the JSON data. Paste or type the following JSON object into the body:
{
"short_description": "Test incident from API Explorer",
"description": "This incident was created using the REST API Explorer."
}
5. Send the request. Click Send Request.
6. Verify the result. If successful, you will receive a 201 Created status code. The response body will contain the newly created incident record. You can see the unique number that ServiceNow assigned to this new record.
Work with Table-Specific Endpoints
The /api/now path is the starting point for many resources. The API Explorer allows you to easily navigate to different table endpoints. You can construct the URL manually or use the explorer’s interface to build it.
For example, to work with the Task table, you would change the base path to /api/now/table/task. This will return a list of all tasks, which include both incidents and change requests. This is useful if you want to list all work items without distinguishing between their types.
When you change the base path, remember to update the query parameters if you were using them. The query language and parameters remain the same for all table endpoints.
Check Your Work with the Response Headers
The response headers provide important information about the request and response. You can view these headers in the API Explorer to understand how ServiceNow handled your request.
Look for the Headers section in the response area. Key headers to check include:
- Content-Type: This header indicates the format of the response body. For JSON data, this will typically be
application/json. - Content-Length: This header shows the size of the response body in bytes. A very large length might indicate that you are retrieving more data than you intended.
- ETag: The ETag is a unique identifier for the current version of the resource. It is useful for caching and conditional requests.
Reviewing the headers can help you detect issues, such as a response that is not in the expected format or a response that is unexpectedly large.
Troubleshoot Common Issues
Even with the API Explorer, you may encounter problems. Knowing how to diagnose these issues will help you get back on track quickly.
If you receive a 403 Forbidden error, the most common cause is missing permissions. Verify that the user account you are using has the api_user role. You can check this by navigating to the User record in ServiceNow and viewing the Roles field.
If you receive a 400 Bad Request error, the request body or parameters are malformed. Check your JSON syntax carefully. Ensure that all keys are enclosed in double quotes and that there are no trailing commas in the JSON array or object.
If the API Explorer does not load or displays an error, try clearing your browser cache and cookies. Sometimes, a corrupted cache can cause issues with loading the tool.
Keep Your Credentials Safe
While the API Explorer is a convenient tool for testing, it is not intended for long-term, automated use. The username and password you enter in the browser are visible in plain text. Anyone with access to your browser can see these credentials.
For production applications and scripts, do not use the API Explorer. Instead, use a secure method such as OAuth2 or a client credential flow. These methods use tokens instead of a username and password, which are much more secure and can be rotated easily.
When you are finished testing, consider logging out of the API Explorer. This ensures that your credentials are not left active in your browser session.