{"id":2092,"date":"2024-11-06T08:10:04","date_gmt":"2024-11-06T07:10:04","guid":{"rendered":"https:\/\/snowit.co\/?p=2092"},"modified":"2024-11-06T09:58:18","modified_gmt":"2024-11-06T08:58:18","slug":"servicenow-scripted-rest-api-with-api-key","status":"publish","type":"post","link":"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/","title":{"rendered":"ServiceNow: Scripted REST API with API Key"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p>Setting up API key authentication for scripted REST APIs in ServiceNow can streamline your integration and ensure secure access to your APIs. This guide will walk you through each step, from setting up an authentication profile to testing the integration. By following these steps, you&#8217;ll have a secure and well-configured API key authentication process ready for use with your ServiceNow REST APIs.<\/p>\n<h3>Step 1: Set Up an Authentication Profile<\/h3>\n<p>To begin, configure an authentication profile in ServiceNow to manage how your API keys are processed.<\/p>\n<ol>\n<li><strong>Navigate to the Inbound Authentication Profile Section:<\/strong> Go to <strong>System Web Services<\/strong> &gt; <strong>API Access Policies<\/strong> &gt; <strong>Inbound Authentication Profile<\/strong> in your ServiceNow instance.<\/li>\n<li><strong>Create an API Key Authentication Profile:<\/strong>\n<ul>\n<li>Select the option to create a new profile dedicated to API Key authentication.<\/li>\n<li>Define the appropriate authorization parameter. Typically, you can set this to authorize users via the <strong>Auth header<\/strong> or <strong>Query parameter<\/strong>, depending on the level of security required by your integration.<\/li>\n<\/ul>\n<p>Choosing the <strong>Auth header<\/strong> ensures that sensitive information is not exposed in the URL, which is generally recommended for added security. Alternatively, if you prefer a simpler setup, using the <strong>Query parameter<\/strong> is another option, though slightly less secure.<\/li>\n<\/ol>\n<h3>Step 2: Set Up an API Key<\/h3>\n<p>The next step involves creating the actual API key that will be used for authentication.<\/p>\n<ol>\n<li><strong>Navigate to the REST API Key Section:<\/strong> Go to <strong>System Web Services<\/strong> &gt; <strong>API Access Policies<\/strong> &gt; <strong>REST API Key<\/strong>.<\/li>\n<li><strong>Create a New API Key:<\/strong>\n<ul>\n<li>Define a <strong>Name<\/strong> for the API key that is easily identifiable for future reference.<\/li>\n<li>Select the <strong>User<\/strong> who will have access to this API key. This user should have the appropriate permissions to interact with the specified REST APIs.<\/li>\n<li><strong>Copy the Token<\/strong> generated for this key. The token is a unique identifier for API access and will be used in the authorization part of your API calls. Ensure that this token is stored securely, as it provides direct access to your REST APIs.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>Step 3: Configure an API Access Policy<\/h3>\n<p>With the API key created, you need to configure an access policy to control the conditions under which the API key can access your scripted REST APIs.<\/p>\n<ol>\n<li><strong>Navigate to REST API Access Policies:<\/strong> Go to <strong>System Web Services<\/strong> &gt; <strong>API Access Policies<\/strong> &gt; <strong>REST API Access Policies<\/strong>.<\/li>\n<li><strong>Create a New API Access Policy:<\/strong>\n<ul>\n<li>Define a <strong>Name<\/strong> for the access policy that reflects its purpose.<\/li>\n<li>Select the <strong>REST API<\/strong> (specifically, the scripted REST API) that this policy will apply to.<\/li>\n<li>Configure additional attributes as needed, such as whether the policy should <strong>Apply to all methods<\/strong> (e.g., GET, POST, PUT, DELETE) and any other conditions relevant to your setup. Customizing these attributes ensures that the access policy fits the intended use case and restricts API key usage as needed.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>Step 4: Test the Integration<\/h3>\n<p>Now that your API key and access policy are configured, it\u2019s essential to test the integration and verify that everything is working as expected.<\/p>\n<ol>\n<li><strong>Test the API Key Authentication:<\/strong> Use your dedicated API token (generated in Step 2) and insert it in the manner specified in your authentication profile\u2014either in the <strong>x-sn-apikey<\/strong> header or as a query parameter, depending on the setup.<\/li>\n<li><strong>Verify Successful Authentication:<\/strong>\n<ul>\n<li>Send a request to your scripted REST API with the API key. Confirm that the request is successfully authenticated using the API key token.<\/li>\n<li>Check that the API responses are returned as expected and that no authentication errors occur.<\/li>\n<li>If there are any issues, double-check the access policy settings and the way the API key is passed in the request headers or parameters.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>Conclusion<\/h3>\n<p>Setting up API key authentication for scripted REST APIs in ServiceNow enhances security and provides a reliable means to control access. By carefully following these steps\u2014configuring an authentication profile, creating an API key, setting up an API access policy, and testing the integration\u2014you\u2019ll establish a secure foundation for managing API access. This setup also gives you the flexibility to adjust permissions, ensuring your APIs are accessed securely and as intended.<\/p>\n<p>By implementing this API key authentication method, you\u2019ll be well-prepared for secure ServiceNow REST API interactions, allowing authorized users to integrate with confidence.<\/p>\n<p>&nbsp;<\/p>\n<p><iframe title=\"#SNowIT ServiceNow   REST with API Key\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/2SXUcira7Lo?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Setting up API key authentication for scripted REST APIs in ServiceNow can streamline your integration and ensure secure access to your APIs. This guide will walk you through each step, from setting up an authentication profile to testing the integration. By following these steps, you&#8217;ll have a secure and well-configured API key authentication process [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2087,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[49,147,148,38],"class_list":["post-2092","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","tag-api-pl","tag-api-key-pl","tag-authentication-pl","tag-servicenow-pl"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>ServiceNow: Scripted REST API with API Key - SNowIT<\/title>\n<meta name=\"description\" content=\"Learn how to set up API key authentication for scripted REST APIs in ServiceNow. This guide covers configuring authentication profiles, creating API keys, setting access policies, and testing integrations to ensure secure API access.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/\" \/>\n<meta property=\"og:locale\" content=\"pl_PL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ServiceNow: Scripted REST API with API Key - SNowIT\" \/>\n<meta property=\"og:description\" content=\"Learn how to set up API key authentication for scripted REST APIs in ServiceNow. This guide covers configuring authentication profiles, creating API keys, setting access policies, and testing integrations to ensure secure API access.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/\" \/>\n<meta property=\"og:site_name\" content=\"SNowIT\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-06T07:10:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-06T08:58:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/snowit.co\/wp-content\/uploads\/2024\/10\/SNowIT-v1-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1500\" \/>\n\t<meta property=\"og:image:height\" content=\"844\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"adm_snowit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Napisane przez\" \/>\n\t<meta name=\"twitter:data1\" content=\"adm_snowit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Szacowany czas czytania\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minuty\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/\",\"url\":\"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/\",\"name\":\"ServiceNow: Scripted REST API with API Key - SNowIT\",\"isPartOf\":{\"@id\":\"https:\/\/snowit.co\/pl\/#website\"},\"datePublished\":\"2024-11-06T07:10:04+00:00\",\"dateModified\":\"2024-11-06T08:58:18+00:00\",\"author\":{\"@id\":\"https:\/\/snowit.co\/pl\/#\/schema\/person\/00dc51faeafd5a3089de5197d69cf29a\"},\"description\":\"Learn how to set up API key authentication for scripted REST APIs in ServiceNow. This guide covers configuring authentication profiles, creating API keys, setting access policies, and testing integrations to ensure secure API access.\",\"breadcrumb\":{\"@id\":\"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/#breadcrumb\"},\"inLanguage\":\"pl-PL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Strona g\u0142\u00f3wna\",\"item\":\"https:\/\/snowit.co\/pl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ServiceNow: Scripted REST API with API Key\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/snowit.co\/pl\/#website\",\"url\":\"https:\/\/snowit.co\/pl\/\",\"name\":\"SNowIT\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/snowit.co\/pl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pl-PL\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/snowit.co\/pl\/#\/schema\/person\/00dc51faeafd5a3089de5197d69cf29a\",\"name\":\"adm_snowit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pl-PL\",\"@id\":\"https:\/\/snowit.co\/pl\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8be1cacc4829f3664d0ddb02327b2f7532bdf123634e4c0d7c0f8b94fb11487d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8be1cacc4829f3664d0ddb02327b2f7532bdf123634e4c0d7c0f8b94fb11487d?s=96&d=mm&r=g\",\"caption\":\"adm_snowit\"},\"url\":\"https:\/\/snowit.co\/pl\/blog\/author\/adm_snowit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ServiceNow: Scripted REST API with API Key - SNowIT","description":"Learn how to set up API key authentication for scripted REST APIs in ServiceNow. This guide covers configuring authentication profiles, creating API keys, setting access policies, and testing integrations to ensure secure API access.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/","og_locale":"pl_PL","og_type":"article","og_title":"ServiceNow: Scripted REST API with API Key - SNowIT","og_description":"Learn how to set up API key authentication for scripted REST APIs in ServiceNow. This guide covers configuring authentication profiles, creating API keys, setting access policies, and testing integrations to ensure secure API access.","og_url":"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/","og_site_name":"SNowIT","article_published_time":"2024-11-06T07:10:04+00:00","article_modified_time":"2024-11-06T08:58:18+00:00","og_image":[{"width":1500,"height":844,"url":"https:\/\/snowit.co\/wp-content\/uploads\/2024\/10\/SNowIT-v1-scaled.jpg","type":"image\/jpeg"}],"author":"adm_snowit","twitter_card":"summary_large_image","twitter_misc":{"Napisane przez":"adm_snowit","Szacowany czas czytania":"4 minuty"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/","url":"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/","name":"ServiceNow: Scripted REST API with API Key - SNowIT","isPartOf":{"@id":"https:\/\/snowit.co\/pl\/#website"},"datePublished":"2024-11-06T07:10:04+00:00","dateModified":"2024-11-06T08:58:18+00:00","author":{"@id":"https:\/\/snowit.co\/pl\/#\/schema\/person\/00dc51faeafd5a3089de5197d69cf29a"},"description":"Learn how to set up API key authentication for scripted REST APIs in ServiceNow. This guide covers configuring authentication profiles, creating API keys, setting access policies, and testing integrations to ensure secure API access.","breadcrumb":{"@id":"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/#breadcrumb"},"inLanguage":"pl-PL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/snowit.co\/pl\/blog\/servicenow-scripted-rest-api-with-api-key\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Strona g\u0142\u00f3wna","item":"https:\/\/snowit.co\/pl\/"},{"@type":"ListItem","position":2,"name":"ServiceNow: Scripted REST API with API Key"}]},{"@type":"WebSite","@id":"https:\/\/snowit.co\/pl\/#website","url":"https:\/\/snowit.co\/pl\/","name":"SNowIT","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/snowit.co\/pl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pl-PL"},{"@type":"Person","@id":"https:\/\/snowit.co\/pl\/#\/schema\/person\/00dc51faeafd5a3089de5197d69cf29a","name":"adm_snowit","image":{"@type":"ImageObject","inLanguage":"pl-PL","@id":"https:\/\/snowit.co\/pl\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8be1cacc4829f3664d0ddb02327b2f7532bdf123634e4c0d7c0f8b94fb11487d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8be1cacc4829f3664d0ddb02327b2f7532bdf123634e4c0d7c0f8b94fb11487d?s=96&d=mm&r=g","caption":"adm_snowit"},"url":"https:\/\/snowit.co\/pl\/blog\/author\/adm_snowit\/"}]}},"_links":{"self":[{"href":"https:\/\/snowit.co\/pl\/wp-json\/wp\/v2\/posts\/2092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/snowit.co\/pl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/snowit.co\/pl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/snowit.co\/pl\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/snowit.co\/pl\/wp-json\/wp\/v2\/comments?post=2092"}],"version-history":[{"count":4,"href":"https:\/\/snowit.co\/pl\/wp-json\/wp\/v2\/posts\/2092\/revisions"}],"predecessor-version":[{"id":2103,"href":"https:\/\/snowit.co\/pl\/wp-json\/wp\/v2\/posts\/2092\/revisions\/2103"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/snowit.co\/pl\/wp-json\/wp\/v2\/media\/2087"}],"wp:attachment":[{"href":"https:\/\/snowit.co\/pl\/wp-json\/wp\/v2\/media?parent=2092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/snowit.co\/pl\/wp-json\/wp\/v2\/categories?post=2092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/snowit.co\/pl\/wp-json\/wp\/v2\/tags?post=2092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}