Skip to content

Grant access to encryption key

Request to authorize a user to use an encryption key:

POST /api/v2/encrypt_keys/<key-id>/authorized_users.json

The request body contains the ID of the user:

{
    "user": {
        "user_id": "5b139cee-f13a-11e5-9615-e03f497dbdff"
    }
}

The private key is re-encrypted with the public key of the user. The user's key pair is created when the user's password is set, so the user must have a password. Access can be granted only to keys with the user protection mode; keys with the app protection mode are accessible to everyone in the tenant. The API user itself must be authorized to use the key.

Response contains HTTP status code as shown in the following table.

Response Description
201 Created

The user has been authorized. The Location header contains the URL of the authorization:

HTTP/1.1 201 Created
Location: /api/v2/encrypt_keys/e9780258-f061-11e5-b9d7-e03f497dbdff/authorized_users/5b139cee-f13a-11e5-9615-e03f497dbdff.json
400 Bad Request The request body is not valid JSON or the user key is missing
403 Forbidden The request cannot be completed because API user has no permission to grant access to encryption keys
404 Not Found Encryption key with such ID does not exist, or the user does not exist or is outside the access scope of the API user
409 Conflict

The key is application-protected, the user has no key pair yet, or the user is authorized already:

{"error": "InvalidState", "explanation": "Such user is authorized already", "details": null}