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.
| Service | Base URL | Paths |
|---|---|---|
| Auth | https://auth.<domain> | /oauth/*, /api/v1/* |
| Customers | https://crm-service.<domain> | /api/v2/* |
| Insights | https://insights-service.<domain> | /api/v2/* |
| Files | https://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 (notx-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 acceptsapplication/x-ndjson. - Paths use
humanIdfor Customers entities andsourceIdfor Insights sources. The SDK resolves source names for you, with REST you list the sources first (GET /api/v2/source).
Responses and status codes
| Status | Meaning |
|---|---|
200 | OK, JSON body |
201 | Created |
204 | OK, no body (deletes) |
400 | Bad request or validation error |
401 | Missing, invalid or unsuitable token |
403 | Not allowed |
404 | Not found |
429 | Rate 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:
tokenholds 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_idhold 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
- curl
- JavaScript
- Python
- R
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"]}'
const base = 'scenid.cloud'
const { access_token: token } = await (await fetch(`https://auth.${base}/oauth/token`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
grant_type: 'client_credentials',
client_id: process.env.CLIENT_ID,
client_secret: process.env.CLIENT_SECRET
})
})).json()
const response = await fetch(`https://crm-service.${base}/api/v2/entities/list`, {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ entityTypes: ['ou'], fields: ['data.city'] })
})
console.log(response.status, await response.json())
import os, requests
base = "scenid.cloud"
token = requests.post(f"https://auth.{base}/oauth/token", json={
"grant_type": "client_credentials",
"client_id": os.environ["CLIENT_ID"],
"client_secret": os.environ["CLIENT_SECRET"],
}).json()["access_token"]
response = requests.post(
f"https://crm-service.{base}/api/v2/entities/list",
headers={"Authorization": f"Bearer {token}"},
json={"entityTypes": ["ou"], "fields": ["data.city"]},
)
print(response.status_code, response.json())
library(httr2)
base <- "scenid.cloud"
token_response <- request(paste0("https://auth.", base, "/oauth/token")) |>
req_body_json(list(
grant_type = "client_credentials",
client_id = Sys.getenv("CLIENT_ID"),
client_secret = Sys.getenv("CLIENT_SECRET")
)) |>
req_perform() |>
resp_body_json()
token <- token_response$access_token
response <- request(paste0("https://crm-service.", base, "/api/v2/entities/list")) |>
req_auth_bearer_token(token) |>
req_body_json(list(entityTypes = list("ou"), fields = list("data.city"))) |>
req_error(is_error = \(r) FALSE) |>
req_perform()
resp_status(response)
resp_body_json(response)
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
| Area | Endpoints |
|---|---|
| OAuth | POST /oauth/token, GET /oauth/authorize, GET /oauth/.well-known/jwks.json, POST /oauth/introspect, GET /oauth/userinfo |
| Users | GET /api/v1/users, GET /api/v1/userGroups |
| Profile | GET /api/v1/profile, PUT /api/v1/updateProfile, … |
| Entities | GET /api/v2/entity/{humanId}, POST /api/v2/entities/list, POST /api/v2/entities/search |
| OU | POST/PUT/DELETE /api/v2/entity/ou[/{humanId}], parent, employees |
| Person | POST/PUT/DELETE /api/v2/entity/person[/{humanId}], employments, merge |
| Group | POST/PUT/DELETE /api/v2/entity/group[/{humanId}], members |
| Journal | POST /api/v2/journal |
| Sources | GET /api/v2/source, GET /api/v2/source/{id}, POST /api/v2/source/{id}/aggregate, POST …/push |
| Documents | GET/POST/PUT/DELETE /api/v2/source/{id}/doc[/{docId}], POST …/batch, GET /api/v2/sources/{ids}/docs |
| Files | POST /{folder} |