Service tokens
Service tokens provide machine-to-machine authentication for specific Posit Connect capabilities. Unlike user API keys, service tokens are not tied to a user account. This makes them suitable for automated systems that must remain functional regardless of user lifecycle changes. Service tokens do not consume a license seat.
When to use service tokens
Use service tokens when the credential should survive user deactivation, role changes, or account deletion and:
- You need to authenticate System for Cross-domain Identity Management (SCIM) identity provisioning (
identity:managescope) - You need to authenticate nameservice read access (
nameservice:readscope) - You need to authenticate Chronicle usage data collection (
content:search,groups:read,users:read,instrumentation:read,tags:read,feature-usage:read,server-settings:readscopes)
Use administrator API keys when:
- You need full administrator access for a one-time or interactive task
- The calling system already authenticates as a specific user
Available scopes
Service tokens are scoped to specific capabilities and cannot be used for general Connect API access. Service tokens support the following scopes:
| Scope | Description |
|---|---|
identity:manage |
Manage users and groups |
nameservice:read |
Access Name Service Switch (NSS) user and group data |
content:search |
Search content items |
groups:read |
List groups and group members |
users:read |
List users |
instrumentation:read |
Read content visit and Shiny usage data |
tags:read |
List tags |
tags:manage |
Add and remove tags |
feature-usage:read |
Read feature usage data |
server-settings:read |
Read server settings and runtime installations |
Creating a service token
Create a service token using the Connect API. Before running these commands, sign in with posit connect login as described in Publishing from the command line. Use a Connect administrator account.
Terminal
posit connect api v1/system/service-tokens -X POST \
-H "Content-Type: application/json" --input - <<'JSON'
{"name": "SCIM Provisioning", "scopes": ["identity:manage"]}
JSONSee the create service token API reference for request and response details.
The key value is only returned once at creation time. Store it securely before closing the response. If lost, delete the token and create a new one.
Setting an expiry
To create a service token that expires automatically, include an optional expires_at timestamp in RFC 3339 format. Without expires_at, the token remains valid until you delete it. The value must be in the future.
Terminal
posit connect api v1/system/service-tokens -X POST \
-H "Content-Type: application/json" --input - <<'JSON'
{"name": "SCIM Provisioning", "scopes": ["identity:manage"], "expires_at": "2026-12-31T00:00:00Z"}
JSONOnce the expiry passes, the token can no longer be used to authenticate.
Using a service token
Include the token in the Authorization header as a bearer token:
Terminal
curl -H "Authorization: Bearer SERVICE-TOKEN" \
https://connect.example.com/scim/v2/UsersListing service tokens
Use the list service tokens endpoint to view existing tokens.
Terminal
posit connect api v1/system/service-tokensDeleting service tokens
Use the delete service tokens endpoint to delete existing tokens.
Terminal
posit connect api v1/system/service-tokens/TOKEN-GUID -X DELETEDeleting a token immediately revokes access.
Rotating a service token
To rotate a service token:
- Create a new token with the same scope.
- Update the consuming system with the new token value.
- Delete the old token.
Update your consuming system before deleting the old token to avoid service interruptions.
Audit log behavior
Operations authenticated with a service token are attributed to the service token itself in audit logs, not to any user account.