This version of the documentation is archived and no longer supported. To learn how to upgrade your version of MongoDB Ops Manager, refer to the upgrade documentation.
You were redirected from a different version of the documentation. Click here to go back.

Enable/Disable a User API Key


Ops Manager deprecated Personal API Keys. Use Programmatic API Keys instead.

Base URL: https://{OPSMANAGER-HOST}:{PORT}/api/public/v1.0

This endpoint enables or disables an API key for a specific Ops Manager user. You must be one of the following users to successfully call this endpoint:

  • The Ops Manager user specified in the digest authentication
  • The Ops Manager user with the GLOBAL_OWNER role


You must have access to an a public API key generated from the GUI by your administrator before you can successfully use this endpoint. See Manage Personal API Keys (Deprecated) for instructions.


PATCH /users/{USER-ID}/keys/{KEY-ID}

Request Parameters

Request Path Parameters

Path Element Necessity Description
USER-ID Required Unique identifier of the Ops Manager user for whom you enable or disable a personal API key. Use the /users/byName/{USER-NAME} endpoint to retrieve one user’s ID. Specify the value of the id field in the response body to that endpoint.
KEY-ID Required Unique identifier for the Ops Manager user’s personal API key that you want to enable or disable.

Request Query Parameters

This endpoint supports the following optional request query parameters:

The following query parameters are optional:

Name Type Necessity Description Default
pretty boolean Optional Flag indicating whether the response body should be in a prettyprint format. false
envelope boolean Optional

Flag that indicates whether or not to wrap the response in an envelope.

Some API clients cannot access the HTTP response headers or status code. To remediate this, set envelope=true in the query.

For endpoints that return one result, the response body includes:

Name Description
status HTTP response code
envelope Expected response body

Request Body Parameters

Name Type Description
enabled boolean Specifies whether the user API key is enabled or disabled. Required.


Name Type Description
createdAt timestamp The time the API key was created.
description string Description of the API key.
enabled boolean Indicates whether the API key is enabled.
id string The unique identifier of the API key.
obfuscatedKey string The last twelve digits of the API key that you enabled or disabled. The remainder of the key is obfuscated for security.
usedCount number The number of times that the API key has been used by the associated user.
userId string The user ID associated with the request for a new API key.

Example Request

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
     --header "Accept: application/json" \
     --header "Content-Type: application/json" \
     --include \
     --request POST "https://<OpsManagerHost>:<Port>/api/public/v1.0/users/{USER-ID}/keys/{KEY-ID}" \
     --data '{"enabled":"false"}'

Example Response

Response Header

HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=ISO-8859-1
Date: {dateInUnixFormat}
WWW-Authenticate: Digest realm="MMS Public API", domain="", nonce="{nonce}", algorithm=MD5, op="auth", stale=false
Content-Length: {requestLengthInBytes}
Connection: keep-alive
HTTP/1.1 200 OK
Vary: Accept-Encoding
Content-Type: application/json
Strict-Transport-Security: max-age=300
Date: {dateInUnixFormat}
Connection: keep-alive
Content-Length: {requestLengthInBytes}
X-MongoDB-Service-Version: gitHash={gitHash}; versionString={ApplicationVersion}

Response Body

  "createdAt" : "2018-05-10T21:29:27Z",
  "description" : "DOCSP-2368",
  "enabled" : false,
  "id" : "5af4b9b787d9d624af93c04c",
  "obfuscatedKey" : "********-****-****-670587c49cc9",
  "usedCount" : 0,
  "userId" : "{USER-ID}"