Skip to main content

KeySet

Creates or updates an API key for a user with a specified visibility level.

:::caution Established API The SOAP API is in maintenance mode. For new integrations use the REST equivalent. :::

Method Signature

KeyIDInfo KeySet(string SessionID, int UserID, KeyVisibility Visibility)

Parameters

ParameterTypeRequiredDescription
SessionIDstringYesActive session token from Login()
UserIDintYesID of the user for whom to create or update the API key
VisibilityKeyVisibilityYesVisibility scope to assign to the key

Response Object — KeyIDInfo

FieldTypeDescription
KeyIDintUnique identifier for this API key record
UserIDintID of the user that owns this key
KeystringThe API key string value
VisibilityKeyVisibilityVisibility scope assigned to this key
CreateddatetimeDate and time the key was created
<!-- Example response XML -->
<KeyIDInfo>
<KeyID>1043</KeyID>
<UserID>5001</UserID>
<Key>xyz987uvw654rst321opq098nml765kj</Key>
<Visibility>Shared</Visibility>
<Created>2026-05-07T10:00:00</Created>
</KeyIDInfo>

ENUMs

KeyVisibility

ValueDescription
PrivateKey is accessible only to the owning user
SharedKey is shared within the mailbox or network
PublicKey is publicly visible
SessionKey is valid only for the current session

Code Examples

// .NET 10 — dotnet-svcutil generated proxy
// Create or update an API key with Shared visibility
var keyInfo = await client.KeySetAsync(sessionID, userId, KeyVisibility.Shared);

Console.WriteLine($"Key ID: {keyInfo.KeyID}");
Console.WriteLine($"Key: {keyInfo.Key}");
Console.WriteLine($"Visibility: {keyInfo.Visibility}");
Console.WriteLine($"Created: {keyInfo.Created:yyyy-MM-dd}");

REST Equivalent

See Create KeyPOST /v2/keys/create.