Skip to main content

UserGetAPIKey

Retrieves the API key for the specified user account, which can be used for REST API authentication via the X-API-Key header.

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

Method Signature

string UserGetAPIKey(string SessionID, int UserID)

Parameters

ParameterTypeRequiredDescription
SessionIDstringYesActive session token from Login()
UserIDintYesUnique identifier of the user whose API key is being retrieved

Response

Returns the user's API key as a plain string. This key is used as the value of the X-API-Key header when calling the ECGrid REST API.

<!-- Example response XML -->
<UserGetAPIKeyResult>abc123def456ghi789jkl012mno345pqr</UserGetAPIKeyResult>

:::warning Keep API Keys Secure Never log, display in UI, or store API keys in source code. Load them from environment variables or a secrets manager. :::

Code Examples

// .NET 10 — dotnet-svcutil generated proxy
using ECGridOSClient;

var client = new ECGridOSPortTypeClient();

// Retrieve the API key for user 5001
string apiKey = await client.UserGetAPIKeyAsync(sessionID, UserID: 5001);

// Use the key — store securely, never log it
Console.WriteLine("API key retrieved successfully.");

// Example: pass to REST client configuration
httpClient.DefaultRequestHeaders.Add("X-API-Key", apiKey);

REST Equivalent

See Get API KeyGET /v2/users/key/{id}.