Skip to content
This page View Markdown Open in ChatGPT Open in Claude

Decrypt data

Decrypts what encrypt data produced, or what a client encrypted with encryptionAlgorithmFETransfer and secretFETransfer of the secret, and gives the original value back.

Method POST
URL /api/system-api/admin/decrypt-data : admin is the user path of your account
Body { data, algorithm?, pass? }
Answer data : the decrypted value, parsed as JSON when it is JSON
From code g.sys.system.decrypt

The call

Body
{ "data": "U2FsdGVkX19iIBA3FQy3OgFXeE4B2cC8lAfaJjCbMmUllceqb58YwvQqU33PkQEQ" }
Answer
{ "success": true, "statusCode": 200, "data": { "name": "Joseph", "card": "4111 1111 1111 1111" } }
  • algorithm and pass work as on encrypt data : give the same ones the text was encrypted with.
  • A text which does not decrypt with the key answers data: null.

From code

const value = await g.sys.system.decrypt(encryptedText);
const mine = await g.sys.system.decrypt(encryptedText, T.EEncryptionAlgorithm.AES, 'my-own-key');

Access and settings

  • Over HTTP, a system API answers once its settings give it apiAccessType: TOKEN_ACCESS (the token of an API user whose group grants this system API, in x-am-authorization) or IS_PUBLIC. Without settings it is NO_ACCESS : your code calls it through g.sys, the admin panel tests it, and an HTTP call is refused.
  • The settings can also cache the answer or require person tokens (authProviders) ; pre and post hooks run around it like around any API.
  • The request headers apply : x-am-response-case, x-am-content-type-response, x-am-internationalization, x-am-tenant-username…

Errors

Code When
400 The body is wrong : the message names the missing or invalid key.
401 No valid API user token, or the API is NO_ACCESS : You are not authorized to access this API.
403 No group grants this system API.