Skip to main content

Get All Branches (T138)

Retrieve all registered branches for the authenticated taxpayer. This endpoint returns branch identifiers and names, enabling multi-branch operations such as stock transfers, branch-specific invoicing, and agent management. Request is unencrypted; response is encrypted.


Endpoint Overview​

PropertyValue
Interface CodeT138
Request Encrypted❌ No
Response Encryptedβœ… Yes
Request Bodynull (empty)
Response FormatJSON Array

Flow Description​

  1. Client calls T138 with no request payload (authentication via globalInfo).
  2. Server validates the authenticated taxpayer (tin in globalInfo).
  3. Server queries all branches registered under the taxpayer's TIN.
  4. Server returns an array of branch objects containing branchId and branchName.
  5. Client stores branch IDs for use in subsequent operations (e.g., T131 stock maintain, T139 stock transfer, T109 invoicing).

πŸ’‘ Tip: Call T138 after successful sign-in (T103) to populate your branch selector UI. Store the branchId for branch-specific API calls.


try {
// Call T138: Get All Branches
$response = $client->getRegisteredBranches();

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

if (is_array($content) && count($content) > 0) {
echo "βœ… Retrieved " . count($content) . " branch(es)\n";

foreach ($content as $branch) {
echo " β€’ {$branch['branchName']} (ID: {$branch['branchId']})\n";
}

// Store first branch for subsequent operations
$firstBranchId = $content[0]['branchId'] ?? null;
echo " β†’ Using branch ID: {$firstBranchId}\n";

} else {
echo "⚠️ No branches found for this taxpayer\n";
}

} catch (\UraEfrisSdk\Exceptions\APIException $e) {
echo "❌ Failed to retrieve branches: " . $e->getMessage() . "\n";
echo " Return Code: " . $e->getReturnCode() . "\n";
}

Request Structure​

{
"data": {
"content": "",
"signature": "",
"dataDescription": {
"codeType": "0",
"encryptCode": "0",
"zipCode": "0"
}
},
"globalInfo": {
"interfaceCode": "T138",
"appId": "AP04",
"version": "1.1.20191201",
"tin": "1000029771",
"deviceNo": "TCS9e0df01728335239",
"taxpayerID": "1",
"requestTime": "2025-02-19 10:00:00"
}
}

Request Fields​

πŸ“‹ Note: T138 requires no encrypted payload. All authentication is handled via globalInfo headers.

Field (globalInfo)RequiredTypeDescription
tinβœ… YesString (≀20)Taxpayer Identification Number (from sign-in)
deviceNoβœ… YesString (≀20)Registered device serial number
interfaceCodeβœ… YesString (5)Must be "T138"
requestTimeβœ… YesStringTimestamp format: yyyy-MM-dd HH:mm:ss

Response Structure​

{
"data": {
"content": [
{
"branchId": "206637525568955296",
"branchName": "Mr. STEPHEN BUNJO"
},
{
"branchId": "206637528324276772",
"branchName": "ARINAIT AND SONS CO. LIMITED"
}
]
},
"globalInfo": {
"interfaceCode": "T138",
"returnStateInfo": {
"returnCode": "00",
"returnMessage": "SUCCESS"
}
}
}

Response Fields​

Branch Array Items​

FieldRequiredTypeLengthDescription
branchIdβœ… YesString≀18Unique branch identifier (used in T131, T139, T109, etc.)
branchNameβœ… YesString≀500Human-readable branch name/display name

πŸ’‘ Tip: The branchId is required for branch-specific operations. Always validate that the branch belongs to the current taxpayer before use.


Return Codes​

CodeMessageDescription
00SUCCESSBranches retrieved successfully
99Unknown errorGeneric server error
100Taxpayer does not existTIN not found in system
101Taxpayer status is abnormalTIN suspended, deregistered, or inactive
102Taxpayer branch status abnormalOne or more branches have invalid status
400Device does not existdeviceNo not registered for this TIN
402Device key expiredDevice credentials expired; re-run T102
403Device status is abnormalDevice blocked or suspended
2189branchName:cannot be empty!Internal validation error
2190branchName:Byte length cannot be greater than 500!Branch name exceeds limit

πŸ’‘ Tip: An empty array ([]) in the response content indicates the taxpayer has no registered branchesβ€”this is valid for single-location taxpayers.


Common Use Cases​

  1. Branch Selection UI
    Populate dropdown menus or branch selectors in your application interface after user sign-in.

  2. Stock Transfer Operations (T139)
    Retrieve valid sourceBranchId and destinationBranchId values for inter-branch stock transfers.

  3. Branch-Specific Invoicing (T109)
    Include branchId in sellerDetails when issuing invoices from a specific branch location.

  4. Stock Management (T131)
    Specify the target branchId when maintaining stock levels for branch-specific inventory.

  5. Agent/Principal Validation
    Verify branch relationships when managing agent invoicing or principal-agent workflows.

  6. Multi-Tenant Applications
    Support taxpayers with multiple branches by storing and switching between branchId values session-wide.


Integration Checklist​

βœ… Call T138 immediately after successful T103 sign-in
βœ… Validate response is an array before iterating
βœ… Store branchId values in session/cache for subsequent API calls
βœ… Handle empty array response (single-location taxpayer) gracefully
βœ… Use branchName for display; always use branchId for API requests
βœ… Re-fetch branches periodically if taxpayer branch configuration may change
βœ… Validate that selected branchId exists in the returned list before use
βœ… Log branch selection events for audit trails in multi-branch environments