Skip to main content

Generate API Key

Generates a new API key for a specific user, immediately invalidating their previous key.

caution

Generating a new API key immediately invalidates the user's existing key. Any integrations, scripts, or services still using the old key will stop authenticating until they are updated with the new key. Coordinate key rotation carefully before calling this endpoint.

Endpoint

POST /v2/users/key-generate/{id}

Path Parameters

ParameterTypeRequiredDescription
idintegerYesThe User ID for whom to generate a new API key

Response

Returns the newly generated API key string.

{
"success": true,
"data": "f9e8d7c6-b5a4-3210-fedc-ba9876543210"
}

Code Examples

curl -X POST "https://rest.ecgrid.io/v2/users/key-generate/$ID" \
-H "X-API-Key: $ECGRID_API_KEY"

See Also

  • Get API Key — retrieve the current API key for a user without rotating it
  • Reset Sessions — invalidate JWT sessions without rotating the API key
  • Authentication — how API keys are used in requests