Principals

Principal is an umbrella term for user accounts and service accounts. Both entities can be uniquely identified, authenticated, and authorized in CDF. Principals are unique within an organization, and therefore also within a project in the organization. Principals can access data and create and run processes (transformations, Functions) in a CDF project.

  • A user account is associated with a person who wants to interact with CDF. Each user account has a user profile containing a unique user ID.
  • A service account is associated with an application or process that wants to interact with CDF, such as an extractor or Cognite Functions, rather than a person.

Authentication for this API

Requests to the Principals API are directed to auth.cognite.com, like for organizations.

Only OAuth tokens issued by https://auth.cognite.com (such as the ones issued when logging into Fusion) are accepted by the Principals API.

It is also possible to obtain a token by initiating a login flow against the authorization server directly. See the "Authorizations" sections for more information.

User Accounts

The Principals API lets you query user accounts in an organization, and retrieve profiles.

Get the current caller's information

Retrieves the information of the principal issuing the request.

This endpoint is useful for clients to verify their own identity. All authenticated principals can call this endpoint.

Securityorg-oidc-token
Responses
200

The principal that issued the request.

get/api/v1/principals/me
Response samples
application/json
{
  • "id": "5yAFQRAATb7vtWGp4gvbJD3wE7VS81CGuQ7EZT",
  • "type": "SERVICE_ACCOUNT",
  • "externalId": "my.known.id",
  • "name": "My service account",
  • "description": "This is a service account used by data pipeline A-xxx",
  • "createdBy": {
    },
  • "createdTime": 1730204346000,
  • "lastUpdatedTime": 1730204346000,
  • "pictureUrl": "string"
}

List principals

List principals in an organization.

All principal types are supported.

Access control

Requires the caller to be logged into the target organization, or to be an admin in any of its the ancestor organizations.

Securityorg-oidc-token
Request
path Parameters
org
required
string (OrgId) [ 3 .. 64 ] characters ^([a-z][a-z0-9-]{1,62}[a-z0-9])$

ID of an organization

Example: my-org
query Parameters
cursor
string

Cursor for paging through results. In general, if a response contains a nextCursor property, it means that there may be more results, and you should pass that value as the cursor parameter in the next request.

Note that the cursor may or may not be encrypted, but either way, it is not intended to be decoded. Its internal structure is not a part of the public API, and may change without notice. You should treat it as an opaque string and not attempt to craft your own cursors.

Example: cursor=4zj0Vy2fo0NtNMb229mI9r1V3YG5NBL752kQz1cKtwo
limit
integer [ 1 .. 100 ]
types
string (PrincipalType)

Filter by principal types. If not specified, all principal types will be included. You can filter by multiple types by providing a comma-separated list, or by repeating the parameter.

Enum: "SERVICE_ACCOUNT" "USER"
Example: types=USER,SERVICE_ACCOUNT
Responses
200

A list of principals, with a cursor pointing to the next results page (if any).

get/api/v1/orgs/{org}/principals
Response samples
application/json
{
  • "items": [
    ],
  • "nextCursor": {
    }
}

Retrieve principals by reference

Retrieve principals in an organization by ID or external ID.

Service accounts can be retrieved by ID or external ID. Users can be retrieved by ID.

Access control

Requires the caller to be logged into the target organization, or to be an admin in any of its the ancestor organizations.

Securityorg-oidc-token
Request
path Parameters
org
required
string (OrgId) [ 3 .. 64 ] characters ^([a-z][a-z0-9-]{1,62}[a-z0-9])$

ID of an organization

Example: my-org
Request Body schema: application/json
required

A request to retrieve principals by reference.

For now, only service accounts can have an external ID.

required
Array of ReferenceById (object) or ReferenceByExternalId (object) (ReferenceByIdOrExternalId) [ 1 .. 100 ] items
ignoreUnknownIds
boolean
Default: false

If true, IDs that do not match existing principals will be ignored.

If false, the request will fail if any of the IDs do not match existing principals. This is the default behavior.

Responses
200

A list of principals.

post/api/v1/orgs/{org}/principals/byids
Request samples
application/json
{
  • "items": [
    ],
  • "ignoreUnknownIds": false
}
Response samples
application/json
{
  • "items": [
    ]
}

List login sessions

List login sessions for a user principal in an organization.

Note that a login session is what a user gets after logging into Fusion, InField, or another Cognite application. It is distinct from the concept of the "sessions" that can be used for background work like Transformations or Functions; however, each such background session is backed by a login session.

This endpoint does not work for service account principals, which do not have login sessions.

Access control

Requires the caller to be an admin of the target organization (it is not sufficient to be an admin of an ancestor organization).

Securityorg-oidc-token
Request
path Parameters
org
required
string (OrgId) [ 3 .. 64 ] characters ^([a-z][a-z0-9-]{1,62}[a-z0-9])$

ID of an organization

Example: my-org
principal
required
string (PrincipalId)

ID of a principal

Example: 5yAFQRAATb7vtWGp4gvbJD3wE7VS81CGuQ7EZT
query Parameters
cursor
string

Cursor for paging through results. In general, if a response contains a nextCursor property, it means that there may be more results, and you should pass that value as the cursor parameter in the next request.

Note that the cursor may or may not be encrypted, but either way, it is not intended to be decoded. Its internal structure is not a part of the public API, and may change without notice. You should treat it as an opaque string and not attempt to craft your own cursors.

Example: cursor=4zj0Vy2fo0NtNMb229mI9r1V3YG5NBL752kQz1cKtwo
limit
integer [ 1 .. 1000 ]

The maximum number of items to return.

Responses
200

A list of login sessions, with a cursor pointing to the next results page (if any).

400

Bad parameters: the limit is out of range or not a number, or the cursor is invalid.

403

The calling user is not an admin of the organization, or the principal id references a service account rather than a user.

404

The principal id does not exist, or does not belong to this organization.

get/api/v1/orgs/{org}/principals/{principal}/sessions
Response samples
application/json
{
  • "items": [
    ],
  • "nextCursor": {
    }
}

Revoke login sessions

Revoke one or more login sessions for a user principal in an organization.

Note that a login session is what a user gets after logging into Fusion, InField, or another Cognite application. It is distinct from the concept of the "sessions" that can be used for background work like Transformations or Functions; however, each such background session is backed by a login session.

Upon successful completion of a login flow, the user receives an access token and a refresh token, which are both associated with the newly established login session. (Note that the user may have multiple concurrent login sessions.) The user may use the access token to send requests to the Cognite API, and the refresh token to obtain a new access token before the current one expires. Refreshing will also produce a new refresh token and invalidate the previous one. Every access token and refresh token in this "chain" is associated with the same login session.

Revoking a login session will set its status to REVOKED (which will be reflected in /api/v1/orgs/{org}/principals/{principal}/sessions), which within a short amount of time will prevent the user from accessing the Cognite systems via that login session. Specifically:

  • Requests to the Cognite API that use any access token that is associated with this session will be rejected.
  • Requests to refresh the login session will be rejected.
  • Background jobs that were started from this login session will stop working. Note that this might take up to one hour to take effect.

Note that the user may still have other active login sessions, which will remain active. If you want to completely prevent a user from accessing Cognite systems, you should remove them from your organization's external identity provider (e.g. your Entra ID tenant), which will prevent them from logging in again, and then call /api/v1/orgs/{org}/principals/{principal}/sessions to list all their current login sessions and then pass all their ids to this endpoint (in batches, if there are more than 10) to revoke them.

Also note that because the REVOKED status is "stronger" than the LOGGED_OUT status (background sessions remain active in the latter status but not in the former), it is possible to revoke a login session that is LOGGED_OUT (which will stop any associated background sessions). Currently, REVOKED has the same consequences as EXPIRED, but revocation might be expanded in the future to become even stronger, so it is also possible to revoke a login session that is EXPIRED. Revoking a login session that is already REVOKED will succeed but will have no effect (in particular, the deactivatedTime of the login session will not change).

This endpoint is atomic: if revocation of any of the given login sessions fails, none of the login sessions will be revoked. In other words, any other status code than 204 means that no login sessions were revoked.

This endpoint does not work for service account principals, which do not have login sessions.

Access control

Requires the caller to be an admin of the target organization (it is not sufficient to be an admin of an ancestor organization).

Securityorg-oidc-token
Request
path Parameters
org
required
string (OrgId) [ 3 .. 64 ] characters ^([a-z][a-z0-9-]{1,62}[a-z0-9])$

ID of an organization

Example: my-org
principal
required
string (PrincipalId)

ID of a principal

Example: 5yAFQRAATb7vtWGp4gvbJD3wE7VS81CGuQ7EZT
Request Body schema: application/json
required

A request to revoke login sessions for a user principal.

required
Array of objects [ 1 .. 10 ] items
Responses
204

Login sessions revoked successfully.

400

Bad request body: the number of login sessions to revoke is out of range, or one or more of the login session ids do not exist or do not belong to this organization or user principal.

403

The calling user is not an admin of the organization, or the principal id references a service account rather than a user.

404

The principal id does not exist, or does not belong to this organization.

post/api/v1/orgs/{org}/principals/{principal}/sessions/revoke
Request samples
application/json
{
  • "items": [
    ]
}
Response samples
application/json
{
  • "code": 0,
  • "message": "string"
}