Skip to main content

REST API overview

The REST API is what the SDK calls under the hood. Use it directly from any language, or when you need endpoints the SDK does not wrap.

This reference covers the endpoints available to apps (service keys). An interactive version is in the API Explorer.

Base URLs​

Each service has its own host. Take your cloud domain from the issuer or cloud_stack field of your service key.

ServiceBase URLPaths
Authhttps://auth.<domain>/oauth/*, /api/v1/*
Customershttps://crm-service.<domain>/api/v2/*
Insightshttps://insights-service.<domain>/api/v2/*
Fileshttps://file-service.<domain>/{folder}

Authentication​

Every request needs a Bearer token:

Authorization: Bearer <access_token>

Get one with the client_credentials grant, see Authentication:

curl -s https://auth.scenid.cloud/oauth/token \
-H 'Content-Type: application/json' \
-d '{"grant_type":"client_credentials","client_id":"<client_id>","client_secret":"<client_secret>"}'

Tokens live one hour. Cache them and request a new one shortly before they expire.

Request format​

  • Bodies are JSON with Content-Type: application/json. The token endpoint also takes JSON (not x-www-form-urlencoded). Client credentials go in the body, not in a Basic auth header.
  • Exceptions: file upload is multipart/form-data, Insights batch also accepts application/x-ndjson.
  • Paths use humanId for Customers entities and sourceId for Insights sources. The SDK resolves source names for you, with REST you list the sources first (GET /api/v2/source).

Responses and status codes​

StatusMeaning
200OK, JSON body
201Created
204OK, no body (deletes)
400Bad request or validation error
401Missing, invalid or unsuitable token
403Not allowed
404Not found
429Rate limited (token endpoint)

Errors are described in Errors.

Code examples​

Examples throughout this reference come in four flavours: curl, JavaScript (fetch, Node 18+), Python (requests) and R (httr2, with jsonlite). Your choice is remembered across pages.

They share these conventions:

  • token holds a valid access token (see A first request and Authentication). In curl it is $TOKEN.
  • Hosts are written for scenid.cloud. Take yours from your service key.
  • Variables such as sourceId / source_id hold ids you looked up earlier.
  • The R examples set req_error(is_error = \(r) FALSE) so a 4xx or 5xx response is returned for inspection instead of raising an error, like the SDK does. Drop that line if you prefer exceptions.

A first request​

TOKEN=$(curl -s https://auth.scenid.cloud/oauth/token \
-H 'Content-Type: application/json' \
-d '{"grant_type":"client_credentials","client_id":"'$CLIENT_ID'","client_secret":"'$CLIENT_SECRET'"}' \
| jq -r .access_token)

curl -s https://crm-service.scenid.cloud/api/v2/entities/list \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d '{"entityTypes":["ou"],"fields":["data.city"]}'

What a service token may do​

A service token has token_type: "service" and the tenant of the app. Customers and Insights accept it for everything below. Journal entries carry the author SYSTEM. The scope of a service token is informational, access is decided by the token type.

Endpoint index​

AreaEndpoints
OAuthPOST /oauth/token, GET /oauth/authorize, GET /oauth/.well-known/jwks.json, POST /oauth/introspect, GET /oauth/userinfo
UsersGET /api/v1/users, GET /api/v1/userGroups
ProfileGET /api/v1/profile, PUT /api/v1/updateProfile, …
EntitiesGET /api/v2/entity/{humanId}, POST /api/v2/entities/list, POST /api/v2/entities/search
OUPOST/PUT/DELETE /api/v2/entity/ou[/{humanId}], parent, employees
PersonPOST/PUT/DELETE /api/v2/entity/person[/{humanId}], employments, merge
GroupPOST/PUT/DELETE /api/v2/entity/group[/{humanId}], members
JournalPOST /api/v2/journal
SourcesGET /api/v2/source, GET /api/v2/source/{id}, POST /api/v2/source/{id}/aggregate, POST …/push
DocumentsGET/POST/PUT/DELETE /api/v2/source/{id}/doc[/{docId}], POST …/batch, GET /api/v2/sources/{ids}/docs
FilesPOST /{folder}