servicenow({ host: 'acme.service-now.com' }) or store it with keys.set_host(host). The instance name alone (acme) and a pasted https://acme.service-now.com/ are accepted too. Requests only go to https://<instance>.service-now.com, or https://<instance>.servicenowservices.com for a government cloud instance, so any other host is rejected. If your instance has a custom URL, use its service-now.com name.
Credentials are a username and password, sent as HTTP Basic. This plugin uses Basic credentials only; ServiceNow also supports OAuth for the Table API, which this plugin does not implement. Store them as the account’s api_key, JSON-encoded as {"username":"...","password":"..."}, which is how a single-string key carries a pair; servicenow({ key }) takes the same string.
Things to know before you call:
- Tables are not typed. Every instance extends the base tables with its own columns, and
sysparm_fieldsdecides what comes back, so a record is an open map of fields. Read the base columns for a table before writing to it. - ServiceNow wraps every success in
{ result }. A read returnsresultas an object, a list as an array. The plugin unwraps that:records.get,records.createandrecords.updatereturn the record itself,records.listreturns{ records }andtables.listreturns{ tables }, each holding the array.records.deletereturns{ deleted, table, sys_id }because a 204 carries no body. A failure returns{ error: { message, detail }, status: "failure" }with a real HTTP status, so the plugin throws aServicenowAPIErrorthat always has amessageand an optional stringdetail; a null or empty detail on the wire becomesundefined. - A table name that does not exist is a 400, not a 404. The answer is
{"error":{"message":"Invalid table <name>","detail":null}}, so the plugin matches it by message asINVALID_TABLE_ERROR; a 404 means a record is missing or an ACL hides it. - Reference fields are objects. A column like
super_classorcaller_idarrives as{ link, value }by default and as a bare sys_id only withsysparm_exclude_reference_link=true, so both shapes are accepted. - Paging is offset-based. Pass
sysparm_limitandsysparm_offset; there is no cursor. ServiceNow caps a response at 10,000 records by default, so a large table needs several calls.records.listreturns the records it received, not a total. sysparm_queryis its own syntax. An encoded query joins conditions with^, as inactive=true^priority=1^ORDERBYDESCsys_created_on. Operators include= != > < >= <= LIKE STARTSWITH ENDSWITH IN ISEMPTY ISNOTEMPTY BETWEEN.- Writes run business rules. A create or update fires the table’s business rules, notifications and flows, so a write can change more than the fields you sent.
- A delete is final for the record. ServiceNow keeps no undo. What happens to records that reference it depends on the table’s reference cascade rule: with
DeleteorCascadethey are deleted, withClear(the default) their reference is emptied, withRestrictthe delete is refused while references exist, and withNonethe reference is left pointing at an id that no longer exists.
- 6 typed API operations
Setup
1
Install
2
Add the plugin
corsair.ts
multiTenancy: true, scope calls with corsair.withTenant(id). See Quick start for KEK + Hub keys, and Multi-tenancy for account isolation.3
Choose authentication
- API Key (Recommended)
No setup required yet. When you make your first request as a tenant, Corsair prompts for the API key.More: API Key
4
Connect a tenant
Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see Connect / OAuth.
Example API calls
List open incidentsWhat’s next
API reference
Every
servicenow.api.* operation with input and output types.Connect / OAuth
createLink, Hub delivery, and tenant connect flows.
Use with agents
Expose this plugin’s operations as MCP tools.