Skip to main content

Get Key

Retrieves a specific API key record for a user by user ID.

Endpoint

POST /v2/keys/get-key

Request Body

FieldTypeRequiredConstraintsDescription
userIdintYesMust be a valid user IDThe ID of the user whose key should be retrieved
{
"userId": 12345
}

Response

Returns the key record associated with the specified user, including the key string and visibility level.

{
"success": true,
"data": {
"keyId": 9001,
"userId": 12345,
"key": "ek_live_abc123xyz789...",
"visibility": "Private",
"created": "2025-01-15T10:30:00Z"
}
}

Response Fields

FieldTypeDescription
keyIdintUnique identifier for this key record
userIdintThe user this key belongs to
keystringThe API key string used for authentication
visibilitystringScope of the key — see KeyVisibility enum
createddatetimeUTC timestamp when the key was created

ENUMs

KeyVisibility

See KeyVisibility in the Appendix for the full list of values.

ValueDescription
PrivateKey is accessible only to the owning user
SharedKey is shared within the mailbox or network
PublicKey is publicly accessible
SessionKey is tied to a single session

Code Examples

curl -X POST "https://rest.ecgrid.io/v2/keys/get-key" \
-H "X-API-Key: $ECGRID_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "userId": 12345 }'

See Also