{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":416,"path":"api-reference/rest-api-explorer/define-scripted-rest-api-schema.md","title":"Define a REST API schema","bundle":null,"doc_type":null,"release":"australia","body":"\n# Define a REST API schema\n\nSpecify the expected data structure for requests or responses within a REST API by defining a schema.\n\n## Before you begin\n\nRole required: web\\_service\\_admin\n\n## About this task\n\nSchemas are records that define the structure and format of request and response bodies and headers for a REST API in the OpenAPI 3.0.1 format. When you define a schema in the ServiceNow AI Platform, the schema is used to define the structure of requests and responses within the associated REST API. The schema data for the requests and responses is then available in the exportable OpenAPI specification for the API. For more information about exporting OpenAPI specifications, see [Export to OpenAPI specification](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/export-openapi-specification.md).\n\nThe following procedure describes the process for manual schema definition. For details about automatically generating request schema definitions in non-production instances, see [Automatically generate API request definitions](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/autogenerate-api-request-definitions.md).\n\n## Procedure\n\n1.  Create a REST Schema in one of the following ways.\n\n<table id=\"choicetable_kbq_szc_j3c\"><thead><tr><th align=\"left\" id=\"d355852e89\">\n\nOption\n\n</th><th align=\"left\" id=\"d355852e92\">\n\nProcedure\n\n</th></tr></thead><tbody><tr><td id=\"d355852e98\">\n\n**Navigate through a scripted REST API record**\n\n</td><td>\n\n1.  Navigate to **All** &gt; **System Web Services** &gt; **Scripted REST APIs**.\n2.  Select a scripted REST API record.\n3.  In the **Schemas** related list, select **New**.\n\n\n</td></tr><tr><td id=\"d355852e137\">\n\n**Navigate directly to a new REST Schema record**\n\n</td><td>\n\n1.  Navigate to **All** &gt; **Filter** and enter `sys_ws_schema.form`.\n2.  In the **API** field, select or enter the API to associate with the schema.\n\n\n</td></tr></tbody>\n</table>2.  In the **Name** field, enter a name for the schema.\n\n3.  In the **Schema** field, define the data type and structure of the new schema using the [OpenAPI version 3.0.1 format](https://spec.openapis.org/oas/v3.0.1.html).\n\n    For example, the following entry specifies that the schema is an object that contains a first name. The first name is a string data type.\n\n    ```\n    { \"type\": \"object\", \"properties\": { \"firstName\": { \"type\": \"string\" } } }\n    ```\n\n4.  Select an **OpenAPI version**.\n\n5.  In the **Description** field, summarize the expected structure of the new schema.\n\n6.  Select **Submit**.\n\n\n## What to do next\n\nDefine additional schemas as needed. Use the schemas to specify the expected structure and format in a REST request or response. For more information, see [Define an API resource request structure](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/add-schema-rest-api-request.md) or [Define an API resource response structure](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/add-schema-rest-api-response.md).\n\n**Parent Topic:**[Create a scripted REST API](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/t_CreateAScriptedRESTService.md)\n\n"}}