DocsCloud SDK reference

This reference is currently available in English. The Cloud console remains in your selected language.

BEEOS CLOUD / DEVELOPER REFERENCE

Identity

Client sessions for browser and mobile clients, and external-user data deletion.

Overview

The identity domain manages the product users your backend acts for. It issues, refreshes, and revokes client sessions (short-lived client tokens for a web or native client) and starts and tracks the deletion of an external user's data. Every operation here takes an Idempotency-Key, except the read of a deletion.

5 operations · SDK resource: TypeScript cloud.identity · Python cloud.identity · Go cloud.Identity · API overview

Main objects

ClientSessionInput

FieldTypeRequiredDescription
client_typestringyesHow the client token is bound to the client that will use it. It decides whether you send origin or device_attestation. Allowed values: "web" — A browser client. The token is bound to the page origin you send in origin, which must be one of the allowed origins configured for the app. device_attestation must not be sent. A request that does not match this binding returns 403 invalid_origin; "native" — A native app. The token is bound to a device key whose thumbprint you send in device_attestation.jkt. origin must not be sent. A request that does not match this binding returns 403 invalid_origin. (enum table) Structure by client_type: see the variant table.
requested_capabilitiesarray<string>yesOperations the client token may perform on the Client API, 1 or more distinct names. Each name must be one of context:read, instances:read, instances:write, agents:read, agents:invoke, files:read, files:write, files:delete, events:read, viewer:connect and terminal:connect, and must be allowed for your app's clients. Any other name returns 403 invalid_capability. Constraints: minItems=1, uniqueItems.
originstringnoOrigin of the web page that will use the token, for example https://app.example.com. Required when client_type is web, and it must exactly match one of the allowed origins configured for the app; otherwise the request returns 403 invalid_origin. Not allowed when client_type is native, which also returns 403 invalid_origin. Constraints: format=uri.
device_attestationobjectnoProof of the device key the token is bound to. Required when client_type is native; not allowed when client_type is web, which returns 403 invalid_origin.
device_attestation.jktstringyesThumbprint of the device's public key, the base64url-encoded SHA-256 JWK thumbprint, at least 16 characters. Later Client API requests must be signed with the matching private key. Constraints: minLength=16.
ttl_secondsintegernoRequested token lifetime in seconds for this issuance. Explicit values outside 60..1800 return 400 invalid_request. Default: 600. Constraints: minimum=60, maximum=1800.

Every field, and the methods that use this object: appendix.

ClientSessionResponse

FieldTypeRequiredDescription
access_tokenstringyesClient token to send as the bearer credential to the Client API. It is shown only in this response, so store it securely on the client and never log it. Write-only.
client_api_urlstringyesBase URL of the Client API that accepts access_token. Allowed values: "https://client-api.cloud.beeos.ai/v1" — The production Client API.
expires_atstringyesActual expiration of the issued token, capped by the remaining session authorization lifetime. Constraints: format=date-time.
session_idstringyesID of the client session. Use it to refresh or revoke the session. Refreshing issues a new token for the same session.
app_idstringyesID of the app the session belongs to.
external_user_idstringyesUnused. Cloud does not accept an external user id. Stored sessions leave this empty.
capabilitiesarray<string>yesOperations the token may perform on the Client API. They are the requested capabilities, without duplicates.
bindingBindingyesHow the token is bound to the client, as requested when the session was created.

Every field, and the methods that use this object: appendix.

DeletionAccepted

FieldTypeRequiredDescription
deletion_idstringyesID of the deletion. Use it to read the progress of the deletion.
statusstringyesState of the deletion when the request was accepted. Allowed values: "pending" — The deletion is queued and has not started; "processing" — The deletion is running; "failed" — The latest attempt stopped with an error, shown in error_code. The deletion is retried automatically; "completed" — All data of the user was deleted. (enum table)

Every field, and the methods that use this object: appendix.

Deletion

FieldTypeRequiredDescription
idstringyesID of the deletion.
statusstringyesState of the deletion. Poll until it is completed. Allowed values: "pending" — The deletion is queued and has not started; "processing" — The deletion is running; "failed" — The latest attempt stopped with an error, shown in error_code. The deletion is retried automatically; "completed" — All data of the user was deleted. (enum table)
deleted_resourcesmap<string, integer>yesNumber of items deleted so far, as an object that maps a kind of data to a count. The counts are final when status is completed. Kinds can be added, so do not depend on a fixed set of keys.

Every field, and the methods that use this object: appendix.

Binding

FieldTypeRequiredDescription
client_typestringyesHow the token is bound to the client. Allowed values: "web" — Bound to a web page origin, returned in origin; "native" — Bound to a device key, whose thumbprint is returned in cnf_jkt. (enum table) Structure by client_type: see the variant table.
originstringnoOrigin the token is bound to. Returned when client_type is web. Constraints: format=uri.
cnf_jktstringnoThumbprint of the device key the token is bound to. Returned when client_type is native.

Every field, and the methods that use this object: appendix.

Typical flow

  1. Create a session for a signed-in product user with identity.createClientSession and hand the token to the client.
  2. Before the token expires, rotate it with identity.refreshClientSession.
  3. End the session with identity.revokeClientSession.
  4. To erase a user's data, call identity.deleteExternalUser; it returns DeletionAccepted. Read the outcome with identity.getExternalUserDeletion.

Methods

MethodHTTPSummary
identity.createClientSessionPOST /v1/client-sessionsCreate a client session
identity.revokeClientSessionDELETE /v1/client-sessions/{sessionId}Revoke a client session
identity.refreshClientSessionPOST /v1/client-sessions/{sessionId}/refreshRefresh a client session
identity.deleteExternalUserDELETE /v1/external-users/{externalUserId}Start external user data deletion
identity.getExternalUserDeletionGET /v1/external-users/{externalUserId}/deletions/{deletionId}Get an external user data deletion

identity.createClientSession

POST /v1/client-sessions · Operation ID createClientSession

Create a client session

Issue a client token with request-scoped ttl_seconds. The omitted value normalizes to 600 before idempotency comparison; reusing an Idempotency-Key with a different normalized TTL returns 409 idempotency_conflict.

Idempotency-Key is required.

SDK methods

LanguageMethodSignature
TypeScriptcloud.identity.createClientSessioncreateClientSession(input: Models.ClientSessionInput, idempotencyKey: string): Promise<Models.CreateClientSessionResponse>
Pythoncloud.identity.create_client_sessiondef create_client_session(self, input: ClientSessionInput, options: CreateClientSessionOptions) -> ClientSessionResponse
Gocloud.Identity.CreateClientSessionfunc (r *IdentityResource) CreateClientSession(ctx context.Context, input ClientSessionInput, options CreateClientSessionOptions) (ClientSessionResponse, error)

Parameters

ParameterInTypeRequiredDescription
Idempotency-KeyheaderstringyesKey that makes retries of this request safe, 8 to 128 characters without leading or trailing whitespace. Retrying with the same key and the same content returns the original result; reusing the key with different content returns 409 idempotency_conflict. Constraints: minLength=1, maxLength=256.

Request body

application/json · required · Schema: ClientSessionInput

FieldTypeRequiredDescription
client_typestringyesHow the client token is bound to the client that will use it. It decides whether you send origin or device_attestation. Allowed values: "web" — A browser client. The token is bound to the page origin you send in origin, which must be one of the allowed origins configured for the app. device_attestation must not be sent. A request that does not match this binding returns 403 invalid_origin; "native" — A native app. The token is bound to a device key whose thumbprint you send in device_attestation.jkt. origin must not be sent. A request that does not match this binding returns 403 invalid_origin. (enum table) Structure by client_type: see the variant table.
requested_capabilitiesarray<string>yesOperations the client token may perform on the Client API, 1 or more distinct names. Each name must be one of context:read, instances:read, instances:write, agents:read, agents:invoke, files:read, files:write, files:delete, events:read, viewer:connect and terminal:connect, and must be allowed for your app's clients. Any other name returns 403 invalid_capability. Constraints: minItems=1, uniqueItems.
originstringnoOrigin of the web page that will use the token, for example https://app.example.com. Required when client_type is web, and it must exactly match one of the allowed origins configured for the app; otherwise the request returns 403 invalid_origin. Not allowed when client_type is native, which also returns 403 invalid_origin. Constraints: format=uri.
device_attestationobjectnoProof of the device key the token is bound to. Required when client_type is native; not allowed when client_type is web, which returns 403 invalid_origin.
device_attestation.jktstringyesThumbprint of the device's public key, the base64url-encoded SHA-256 JWK thumbprint, at least 16 characters. Later Client API requests must be signed with the matching private key. Constraints: minLength=16.
ttl_secondsintegernoRequested token lifetime in seconds for this issuance. Explicit values outside 60..1800 return 400 invalid_request. Default: 600. Constraints: minimum=60, maximum=1800.

Response

200 Short-lived client token · application/json · Schema: ClientSessionResponse

FieldTypeRequiredDescription
access_tokenstringyesClient token to send as the bearer credential to the Client API. It is shown only in this response, so store it securely on the client and never log it. Write-only.
client_api_urlstringyesBase URL of the Client API that accepts access_token. Allowed values: "https://client-api.cloud.beeos.ai/v1" — The production Client API.
expires_atstringyesActual expiration of the issued token, capped by the remaining session authorization lifetime. Constraints: format=date-time.
session_idstringyesID of the client session. Use it to refresh or revoke the session. Refreshing issues a new token for the same session.
app_idstringyesID of the app the session belongs to.
external_user_idstringyesUnused. Cloud does not accept an external user id. Stored sessions leave this empty.
capabilitiesarray<string>yesOperations the token may perform on the Client API. They are the requested capabilities, without duplicates.
bindingBindingyesHow the token is bound to the client, as requested when the session was created.

Errors

StatusSchemaDescription
other (default)ErrorResponseCloud Server error

The error schemas are described in Errors.

Example

import { BeeOSClient } from "@beeos-ai/cloud-sdk";

const cloud = new BeeOSClient({
  baseURL: "https://api.cloud.beeos.ai/v1",
  apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.identity.createClientSession({
  client_type: "web",
  requested_capabilities: ["example_requested_capabilities"]
}, "YOUR_IDEMPOTENCY_KEY");
console.log(result);

identity.revokeClientSession

DELETE /v1/client-sessions/{sessionId} · Operation ID revokeClientSession

Revoke a client session

Idempotency-Key is required.

SDK methods

LanguageMethodSignature
TypeScriptcloud.identity.revokeClientSessionrevokeClientSession(sessionId: string, idempotencyKey: string): Promise<Models.RevokeClientSessionResponse>
Pythoncloud.identity.revoke_client_sessiondef revoke_client_session(self, session_id: str, options: RevokeClientSessionOptions) -> None
Gocloud.Identity.RevokeClientSessionfunc (r *IdentityResource) RevokeClientSession(ctx context.Context, sessionId string, options RevokeClientSessionOptions) error

Parameters

ParameterInTypeRequiredDescription
sessionIdpathstringyesID of the client session, the session_id returned when it was created.
Idempotency-KeyheaderstringyesKey that makes retries of this request safe, 8 to 128 characters without leading or trailing whitespace. Retrying with the same key and the same content returns the original result; reusing the key with different content returns 409 idempotency_conflict. Constraints: minLength=1, maxLength=256.

Response

204 Session revoked or already revoked

No response body.

Errors

StatusSchemaDescription
other (default)ErrorResponseCloud Server error

The error schemas are described in Errors.

Example

import { BeeOSClient } from "@beeos-ai/cloud-sdk";

const cloud = new BeeOSClient({
  baseURL: "https://api.cloud.beeos.ai/v1",
  apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.identity.revokeClientSession("session_123", "YOUR_IDEMPOTENCY_KEY");
console.log(result);

identity.refreshClientSession

POST /v1/client-sessions/{sessionId}/refresh · Operation ID refreshClientSession

Refresh a client session

Rotate the client token with request-scoped ttl_seconds. The omitted value normalizes to 600 before idempotency comparison; reusing an Idempotency-Key with a different normalized TTL returns 409 idempotency_conflict.

Idempotency-Key is required.

SDK methods

LanguageMethodSignature
TypeScriptcloud.identity.refreshClientSessionrefreshClientSession(sessionId: string, input: Models.RefreshClientSessionRequest, idempotencyKey: string): Promise<Models.RefreshClientSessionResponse>
Pythoncloud.identity.refresh_client_sessiondef refresh_client_session(self, session_id: str, input: RefreshClientSessionRequest | None = None, *, options: RefreshClientSessionOptions) -> ClientSessionResponse
Gocloud.Identity.RefreshClientSessionfunc (r *IdentityResource) RefreshClientSession(ctx context.Context, sessionId string, input *RefreshClientSessionRequest, options RefreshClientSessionOptions) (ClientSessionResponse, error)

Parameters

ParameterInTypeRequiredDescription
sessionIdpathstringyesID of the client session, the session_id returned when it was created.
Idempotency-KeyheaderstringyesKey that makes retries of this request safe, 8 to 128 characters without leading or trailing whitespace. Retrying with the same key and the same content returns the original result; reusing the key with different content returns 409 idempotency_conflict. Constraints: minLength=1, maxLength=256.

Request body

application/json · optional

FieldTypeRequiredDescription
requested_capabilitiesarray<string>noOperations the new token may perform. Each must already be granted to the session; the new set can only be equal or narrower. Omit it to keep the current capabilities. Names are listed on requested_capabilities of the create operation. Constraints: uniqueItems.
ttl_secondsintegernoRequested token lifetime in seconds for this issuance. Explicit values outside 60..1800 return 400 invalid_request. Default: 600. Constraints: minimum=60, maximum=1800.

Response

200 Rotated JTI with equal or narrower capabilities · application/json · Schema: ClientSessionResponse

FieldTypeRequiredDescription
access_tokenstringyesClient token to send as the bearer credential to the Client API. It is shown only in this response, so store it securely on the client and never log it. Write-only.
client_api_urlstringyesBase URL of the Client API that accepts access_token. Allowed values: "https://client-api.cloud.beeos.ai/v1" — The production Client API.
expires_atstringyesActual expiration of the issued token, capped by the remaining session authorization lifetime. Constraints: format=date-time.
session_idstringyesID of the client session. Use it to refresh or revoke the session. Refreshing issues a new token for the same session.
app_idstringyesID of the app the session belongs to.
external_user_idstringyesUnused. Cloud does not accept an external user id. Stored sessions leave this empty.
capabilitiesarray<string>yesOperations the token may perform on the Client API. They are the requested capabilities, without duplicates.
bindingBindingyesHow the token is bound to the client, as requested when the session was created.

Errors

StatusSchemaDescription
other (default)ErrorResponseCloud Server error

The error schemas are described in Errors.

Example

import { BeeOSClient } from "@beeos-ai/cloud-sdk";

const cloud = new BeeOSClient({
  baseURL: "https://api.cloud.beeos.ai/v1",
  apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.identity.refreshClientSession("session_123", {}, "YOUR_IDEMPOTENCY_KEY");
console.log(result);

identity.deleteExternalUser

DELETE /v1/external-users/{externalUserId} · Operation ID deleteExternalUser

Start external user data deletion

Idempotency-Key is required.

SDK methods

LanguageMethodSignature
TypeScriptcloud.identity.deleteExternalUserdeleteExternalUser(externalUserId: string, idempotencyKey: string): Promise<Models.DeleteExternalUserResponse>
Pythoncloud.identity.delete_external_userdef delete_external_user(self, external_user_id: ExternalUserID, options: DeleteExternalUserOptions) -> DeletionAccepted
Gocloud.Identity.DeleteExternalUserfunc (r *IdentityResource) DeleteExternalUser(ctx context.Context, externalUserId ExternalUserID, options DeleteExternalUserOptions) (DeletionAccepted, error)

Parameters

ParameterInTypeRequiredDescription
externalUserIdpathExternalUserIDyesID of the end user whose stored data is deleted. 1 to 128 characters; . and .. are rejected. This is the path resource id, not a request header.
Idempotency-KeyheaderstringyesKey that makes retries of this request safe, 8 to 128 characters without leading or trailing whitespace. Retrying with the same key and the same content returns the original result; reusing the key with different content returns 409 idempotency_conflict. Constraints: minLength=1, maxLength=256.

Response

202 Asynchronous deletion accepted · application/json · Schema: DeletionAccepted

FieldTypeRequiredDescription
deletion_idstringyesID of the deletion. Use it to read the progress of the deletion.
statusstringyesState of the deletion when the request was accepted. Allowed values: "pending" — The deletion is queued and has not started; "processing" — The deletion is running; "failed" — The latest attempt stopped with an error, shown in error_code. The deletion is retried automatically; "completed" — All data of the user was deleted. (enum table)

Errors

StatusSchemaDescription
other (default)ErrorResponseCloud Server error

The error schemas are described in Errors.

Example

import { BeeOSClient } from "@beeos-ai/cloud-sdk";

const cloud = new BeeOSClient({
  baseURL: "https://api.cloud.beeos.ai/v1",
  apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.identity.deleteExternalUser("external_user_123", "YOUR_IDEMPOTENCY_KEY");
console.log(result);

identity.getExternalUserDeletion

GET /v1/external-users/{externalUserId}/deletions/{deletionId} · Operation ID getExternalUserDeletion

Get an external user data deletion

Idempotency-Key must not be sent.

SDK methods

LanguageMethodSignature
TypeScriptcloud.identity.getExternalUserDeletiongetExternalUserDeletion(externalUserId: string, deletionId: string): Promise<Models.GetExternalUserDeletionResponse>
Pythoncloud.identity.get_external_user_deletiondef get_external_user_deletion(self, external_user_id: ExternalUserID, deletion_id: str) -> Deletion
Gocloud.Identity.GetExternalUserDeletionfunc (r *IdentityResource) GetExternalUserDeletion(ctx context.Context, externalUserId ExternalUserID, deletionId string) (Deletion, error)

Parameters

ParameterInTypeRequiredDescription
externalUserIdpathExternalUserIDyesID of the end user whose stored data is deleted. 1 to 128 characters; . and .. are rejected. This is the path resource id, not a request header.
deletionIdpathstringyesID of the deletion, the deletion_id returned by the delete operation.

Response

200 Deletion progress scoped to the authenticated app · application/json · Schema: Deletion

FieldTypeRequiredDescription
idstringyesID of the deletion.
statusstringyesState of the deletion. Poll until it is completed. Allowed values: "pending" — The deletion is queued and has not started; "processing" — The deletion is running; "failed" — The latest attempt stopped with an error, shown in error_code. The deletion is retried automatically; "completed" — All data of the user was deleted. (enum table)
deleted_resourcesmap<string, integer>yesNumber of items deleted so far, as an object that maps a kind of data to a count. The counts are final when status is completed. Kinds can be added, so do not depend on a fixed set of keys.

Errors

StatusSchemaDescription
other (default)ErrorResponseCloud Server error

The error schemas are described in Errors.

Example

import { BeeOSClient } from "@beeos-ai/cloud-sdk";

const cloud = new BeeOSClient({
  baseURL: "https://api.cloud.beeos.ai/v1",
  apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.identity.getExternalUserDeletion("external_user_123", "deletion_123");
console.log(result);

Structures by discriminator

Binding by client_type

The structure of Binding depends on its own client_type value.

Value of client_typeDescriptionStructure
"web"Bound to a web page origin, returned in origin.BindingWeb
"native"Bound to a device key, whose thumbprint is returned in cnf_jkt.BindingNative

ClientSessionInput by client_type

The structure of ClientSessionInput depends on its own client_type value.

Value of client_typeDescriptionStructure
"web"A browser client. The token is bound to the page origin you send in origin, which must be one of the allowed origins configured for the app. device_attestation must not be sent. A request that does not match this binding returns 403 invalid_origin.ClientSessionInputWeb
"native"A native app. The token is bound to a device key whose thumbprint you send in device_attestation.jkt. origin must not be sent. A request that does not match this binding returns 403 invalid_origin.ClientSessionInputNative