Skip to main content

Get Symmetric Key (T104)

Retrieve the AES symmetric key and signature value used to encrypt/decrypt all subsequent API communications. This endpoint is called after successful sign-in (T103) and enables secure online mode operations.


Endpoint Overview​

PropertyValue
Interface CodeT104
Request Encrypted❌ No
Response Encrypted❌ No
Request Bodynull
Response FormatJSON

Flow Description​

  1. Client calls this endpoint immediately after successful T103: Sign In.
  2. Server generates a random 8-character symmetric key (passowrdDes) and signature value (sign).
  3. Client stores these values in KeyClient for encrypting/decrypting future requests.
  4. All subsequent API calls (T106+) use this symmetric key for payload encryption.

πŸ” Security Note: The symmetric key is session-specific. Re-authenticate (T103) to obtain a fresh key if the session expires or keys are compromised.


try {
// Call T104: Get Symmetric Key
$response = $client->getSymmetricKey();

$content = $response['data']['content'] ?? $response;

if (isset($content['passowrdDes'], $content['sign'])) {
echo "βœ… Symmetric key retrieved\n";

// Store credentials in KeyClient for subsequent encryption
$keyClient->setAesKey($content['passowrdDes']);
$keyClient->setSignature($content['sign']);

echo " Key: " . substr($content['passowrdDes'], 0, 4) . "****\n";
echo " Sign: " . substr($content['sign'], 0, 6) . "...\n";
} else {
echo "⚠️ Missing symmetric key or signature in response\n";
}
} catch (\UraEfrisSdk\Exceptions\APIException $e) {
echo "❌ API Error: " . $e->getMessage() . "\n";
echo " Return Code: " . $e->getReturnCode() . "\n";
}

Response Structure​

{
"data": {
"content": {
"passowrdDes": "aB3xK9mP",
"sign": "7F2e9A1c"
}
},
"globalInfo": {
"interfaceCode": "T104",
"returnStateInfo": {
"returnCode": "00",
"returnMessage": "SUCCESS"
}
}
}

Response Fields​

FieldRequiredTypeDescription
passowrdDesβœ… YesString (8 chars)AES symmetric key for encrypting/decrypting all post-login data payloads
signβœ… YesStringSignature value used to verify message integrity for encrypted requests

⚠️ Note: Field name is passowrdDes (with typo) as per EFRIS API specification. Do not correct to passwordDes.


Return Codes​

CodeMessageDescription
00SUCCESSSymmetric key and signature generated successfully
99Unknown errorGeneric server error
06The outer message is emptyMalformed request envelope
07GlobalInfo content cannot be emptyMissing required globalInfo
11InterfaceCode cannot be emptyMissing interfaceCode in request
400Device does not existdeviceNo not registered for this TIN
402Device key expiredDevice credentials have expired; re-run T102
403Device status is abnormalDevice blocked or suspended

πŸ’‘ Tip: This endpoint must be called after T103 (Sign In) and before any encrypted endpoint (T106+). The SDK handles this automatically if you call endpoints in order.


Common Use Cases​

  1. Session Encryption Setup
    Establish AES encryption context after authentication to secure invoice uploads, stock queries, and other sensitive operations.

  2. Key Rotation Handling
    Re-fetch symmetric key when receiving 402 (key expired) or after session timeout to maintain secure communication.

  3. Offline-to-Online Transition
    When switching from offline mode (T109 with modeCode: 0) to online mode, retrieve fresh symmetric key for server-synced operations.

  4. Multi-Session Management
    Maintain separate KeyClient instances with distinct symmetric keys for concurrent sessions (e.g., multi-tenant applications).


Integration Checklist​

βœ… Call sequence: T101 β†’ T102 β†’ T103 β†’ T104 β†’ [encrypted endpoints]
βœ… Store passowrdDes and sign in secure memory (not logs or disk)
βœ… Use SDK's KeyClient to handle encryption automaticallyβ€”do not manually encrypt payloads
βœ… Re-authenticate (T103) if symmetric key operations fail with 402 or 403