What This Table Is
The sys_ws_definition table stores the top-level definitions for Scripted REST API services. Each record represents a REST service container that groups related API resources under a single namespace, complete with authentication requirements, documentation, and access controls. This table serves as the parent container for the actual REST resources defined in sys_ws_operation records.
This table belongs to the Integration module and supports the platform's custom REST API framework. When you create a new Scripted REST API through System Web Services > Scripted REST APIs, you're creating a record in this table. The service definition establishes the API's base path, security model, and serves as the organizational unit for grouping related endpoints.
The table extends sys_metadata and acts as a parent to sys_ws_operation records, which define the actual HTTP methods and resources. The relationship is one-to-many: each service definition can contain multiple operations (GET /users, POST /users, etc.), but each operation belongs to exactly one service definition.
Enterprise instances typically contain 50-200 custom REST service definitions, with record volume remaining low since each represents a service container rather than individual API calls. Query performance is excellent due to low volume, though joining to sys_ws_operation records can become expensive if your service definitions contain hundreds of operations each.
When You'll Script Against This Table
You'll query this table in Script Includes that manage API lifecycle, Business Rules that enforce REST service governance, and Scheduled Scripts that audit or report on custom API usage. Integration developers commonly script against it when building API management dashboards, automated API documentation generators, or when implementing custom authentication flows that need to validate service definitions.
Access requires the rest_service_admin role for full CRUD operations, though web_service_admin provides read access. The table respects application scoping - global scope can see all records, while scoped applications only see their own service definitions unless explicitly granted cross-scope access.
Common scripting patterns:
- Query active service definitions to build API inventory reports
- Check service authentication requirements before processing API requests
- Validate base path uniqueness when creating new service definitions programmatically
- Join with sys_ws_operation to count endpoints per service for governance reporting
- Update service documentation or version numbers through automated deployment scripts
- Implement custom service lifecycle workflows that transition services between development and production states
- Generate OpenAPI/Swagger documentation from service and operation metadata
Table Gotchas
The base_path field must be unique across all active service definitions, but ServiceNow allows duplicate paths if one service is inactive. This can cause deployment issues when reactivating services.
Authentication configuration in the authentication_type field only sets the service-level default. Individual operations can override this, making service-level queries for auth requirements incomplete.
- The
namespacefield becomes part of the REST endpoint URL structure, but changing it after operations exist doesn't update the actual endpoint URLs until you republish the service - Service definitions in inactive applications (
sys_scope.active=false) remain visible in this table but their endpoints return 404 errors - The
doc_linkfield stores relative paths, but the platform doesn't validate that the documentation actually exists at that location
Deleting a service definition cascades to all child sys_ws_operation records without warning, immediately breaking all endpoints for that service.
- Version field is free-text and not enforced - you can have multiple services claiming to be version "1.0" with completely different implementations
Enjoying this? Get one deep-dive per week.
Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.
Related Tables
This table extends sys_metadata, inheriting application scoping and update set tracking capabilities. The parent relationship means service definitions participate in application lifecycle management and can be deployed between instances as part of scoped applications.
The primary child relationship is with sys_ws_operation, where each operation record defines a specific HTTP method and resource path within the service. Developers frequently join these tables to build complete API inventories or to validate that services have the expected operations defined. The sys_scope table provides the application context, essential for understanding which team owns each service and whether it's available in the current instance configuration.
Integration monitoring often requires joining with syslog_transaction to correlate service definitions with actual API usage patterns and performance metrics. The sys_user table becomes relevant when implementing custom authentication or authorization logic that needs to validate API consumers against service-level access controls.