Skip to main content

servicenow-cli

An unofficial, agent-friendly command-line client for ServiceNow. It combines convenient incident commands with generic access to every table your ServiceNow account is allowed to use.

  • Auto-JSON when stdout is piped
  • Stable error kinds and exit codes
  • Basic and bearer-token authentication
  • Named config profiles and a read-only safety mode
  • Generic Table API CRUD for standard and custom tables
  • Offline command schema and shell completions

Build and install

cargo install --path .

# Or, from this checkout:
make install

The installed binary is servicenow.

Configuration

Run servicenow config init to print the resolved config path and an example. On macOS and Linux the default is ~/.config/servicenow/config.toml, honoring XDG_CONFIG_HOME when set.

[default]
instance = "dev12345"
username = "api-user"
password = "your-password"
auth_type = "basic"
read_only = false

[profiles.production]
instance = "company"
token = "oauth-access-token"
auth_type = "bearer"
read_only = true

Keep the file private:

chmod 600 ~/.config/servicenow/config.toml

Credentials are intentionally not accepted as command-line flags because process arguments can be visible to other users. Environment variables take precedence over the active config profile:

Variable Purpose
SERVICENOW_INSTANCE Short instance name, host, or full base URL
SERVICENOW_USERNAME Basic-auth username
SERVICENOW_PASSWORD Basic-auth password
SERVICENOW_TOKEN OAuth bearer access token
SERVICENOW_AUTH_TYPE basic (default) or bearer
SERVICENOW_PROFILE Named profile
SERVICENOW_READ_ONLY Block all mutations when true

The CLI does not perform an OAuth login flow yet. In bearer mode, provide an access token issued by your ServiceNow OAuth setup.

Incidents

# List and filter with an encoded ServiceNow query
servicenow incidents list --active
servicenow incidents list --query 'priority=1^ORDERBYDESCsys_updated_on'
servicenow incidents mine

# Show by incident number or sys_id
servicenow incidents show INC0010001
servicenow incidents show 0123456789abcdef0123456789abcdef

# Create and update
servicenow incidents create \
  --short-description "VPN unavailable" \
  --description "Unable to connect since 08:30" \
  --impact 2 --urgency 2

servicenow incidents update INC0010001 \
  --state 2 --work-notes "Investigating the gateway"

Use repeated --field name=value arguments for instance-specific fields. Values that are valid JSON become their corresponding JSON type; other values remain strings.

servicenow incidents create --short-description "Laptop setup" \
  --field u_office=Amsterdam --field notify=true

Generic Table API

# Read records from any allowed table
servicenow tables list cmdb_ci \
  --query 'operational_status=1' \
  --fields sys_id,name,sys_class_name --limit 100

servicenow tables get cmdb_ci 0123456789abcdef0123456789abcdef

# Create from inline JSON or stdin
servicenow tables create u_example --data '{"name":"Demo","active":true}'
printf '%s' '{"name":"Demo"}' | servicenow tables create u_example --data -

# Update and delete
servicenow tables update u_example 0123456789abcdef0123456789abcdef \
  --field active=false
servicenow tables delete u_example 0123456789abcdef0123456789abcdef --yes

ServiceNow reference fields can be returned as raw values, display values, or both:

servicenow incidents show INC0010001 --display-value all
servicenow tables list sys_user --display-value true

Automation contract

When stdout is not a terminal, commands produce JSON automatically. Override that with --output text or --output json. Data goes to stdout; informational messages and errors go to stderr.

servicenow incidents list | jq '.result[].number'
servicenow schema | jq '.commands[].name'
servicenow completions zsh > _servicenow

Errors use this envelope in machine-readable mode:

{"error":{"kind":"not_found","message":"not found: ..."}}
Exit Meaning
0 Success
1 Unexpected or transport error
2 Invalid input or configuration
3 Authentication or authorization failure
4 Record not found
5 Other ServiceNow API error
6 Rate limited
7 Conflict or ambiguous match

Development

make check

The test suite uses a mock HTTP server and never requires a live ServiceNow instance.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

servicenow_cli-0.1.0.tar.gz (2.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

servicenow_cli-0.1.0-py3-none-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file servicenow_cli-0.1.0.tar.gz.

File metadata

  • Download URL: servicenow_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.3

File hashes

Hashes for servicenow_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dc892342af7996d57f3c1dc9554abfa10c5801e1a2cb90e81841fb3585ef425b
MD5 c474188e497b946fb7e4cd42bbb444bc
BLAKE2b-256 0ffddb12ba3401fecd0a1de3c55fd570089dad39fe4de616ab1688248e78e28a

See more details on using hashes here.

File details

Details for the file servicenow_cli-0.1.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for servicenow_cli-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d38a9bb06679bf76da022c70376c6e20bed4c336e4433b5be9b71b458c46391
MD5 5ce7d24249495798fa107c878a6a20dc
BLAKE2b-256 e51d98680daa85912ab31fbb44c92dae373d44a2525e0fd9afdb61c9b88aa85f

See more details on using hashes here.

Release history Release notifications | RSS feed

0.5.0

5 files

0.4.5

5 files

0.4.4

5 files

0.4.3

5 files

0.4.2

5 files

0.4.1

5 files

0.4.0

5 files

0.3.14

5 files

0.3.13

5 files

0.3.12

5 files

0.3.11

5 files

0.3.10

5 files

0.3.9

5 files

0.3.8

5 files

0.3.7

5 files

0.3.6

5 files

0.3.5

5 files

0.3.4

5 files

0.3.3

5 files

0.3.2

5 files

0.3.1

5 files

0.3.0

5 files

0.2.1

5 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page