Arguments
The email of the employee who is performing the impersonation
The ID of the user to be impersonated
The user agent of the employee performing the impersonation
The IP address of the employee performing the impersonation
Any additional metadata to attach to the impersonation session
Successful Response
The unique identifier for the impersonation session
The token to use for authenticating as the impersonated user
Unix timestamp when the impersonation session expires
Error Types
Impersonation is disabled for this organization
The provided employee is not authorized to perform impersonation
An unexpected error occurred during the operation
const auth = createClient({ url, integrationKey });
const result = await auth.impersonation.create({ employeeEmail: "example@acmeinc.com", targetUserId: "1189c444-8a2d-4c41-8b4b-ae43ce79a492", userAgent: "Mozilla/5.0 (Macintosh...", ipAddress: "136.38.37.199", metadata: { "example": "value" }});
if (result.ok) { console.log("Impersonation session created successfully"); console.log("Session ID:", result.data.sessionId); console.log("Token:", result.data.impersonationSessionToken);} else { console.log(`Error: ${result.error}`); // Check result.error.type to handle specific errors}client = create_client(url=url, integration_key=integration_key)
result = await client.impersonation.create( employee_email="example@acmeinc.com", target_user_id="1189c444-8a2d-4c41-8b4b-ae43ce79a492", user_agent="Mozilla/5.0 (Macintosh...", ip_address="136.38.37.199", metadata={ "example": "value" })
if is_ok(result): print("Impersonation session created successfully") print(f"Session ID: {result.data.session_id}") print(f"Token: {result.data.impersonation_session_token}")else: print(f"Error: {result.error}") # Check result.error.type to handle specific errorsPropelAuthClient client = PropelAuthClient.create(url, integrationKey);
CreateImpersonationSessionCommand command = CreateImpersonationSessionCommand.builder() .employeeEmail("example@acmeinc.com") .targetUserId("1189c444-8a2d-4c41-8b4b-ae43ce79a492") .userAgent("Mozilla/5.0 (Macintosh...") .ipAddress("136.38.37.199") .metadata(JsonValue.of(Map.of("example", "value"))) .build();
try { CreateImpersonationSessionResponse response = client.impersonation.create(command); System.out.println("Impersonation session created successfully"); System.out.println("Session ID: " + response.getSessionId()); System.out.println("Token: " + response.getImpersonationSessionToken());} catch (CreateImpersonationSessionException.UnauthorizedEmployee e) { System.out.println("Unauthorized employee: " + e.getDetails());} catch (CreateImpersonationSessionException e) { System.out.println("Error: " + e.getMessage());}var client = new PropelAuthClient(new PropelAuthOptions{ Url = url, IntegrationKey = integrationKey});
var command = new CreateImpersonationSessionCommand{ EmployeeEmail = "example@acmeinc.com", TargetUserId = "1189c444-8a2d-4c41-8b4b-ae43ce79a492", UserAgent = "Mozilla/5.0 (Macintosh...", IpAddress = "136.38.37.199", Metadata = JsonSerializer.SerializeToElement(new { example = "value" })};
try{ var response = await client.Impersonation.CreateAsync(command); Console.WriteLine("Impersonation session created successfully"); Console.WriteLine($"Session ID: {response.SessionId}"); Console.WriteLine($"Token: {response.ImpersonationSessionToken}");}catch (CreateImpersonationSessionException.UnauthorizedEmployee ex){ Console.WriteLine($"Unauthorized employee: {ex.Details}");}catch (CreateImpersonationSessionException ex){ Console.WriteLine($"Error: {ex.Message}");}{ ok: true, data: { sessionId: "l5NeYIUscTuVZz7GriwydE", impersonationSessionToken: "impersonate_l5NeYI...", expiresAt: 1756846846 }}Result( data=CreateImpersonationSessionResponse( session_id="l5NeYIUscTuVZz7GriwydE", impersonation_session_token="impersonate_l5NeYI...", expires_at=1756846846 ))CreateImpersonationSessionResponse( sessionId="l5NeYIUscTuVZz7GriwydE", impersonationSessionToken="impersonate_l5NeYI...", expiresAt=1756846846)CreateImpersonationSessionResponse{ SessionId = "l5NeYIUscTuVZz7GriwydE", ImpersonationSessionToken = "impersonate_l5NeYI...", ExpiresAt = 1756846846}