Skip to main content

getGroupId

Synchronously returns the group ID assigned by the Apps in Toss platform. The group ID identifies the business or service group the mini-app belongs to.

Signature

import { getGroupId } from '@apps-in-toss/web-framework';

declare function getGroupId(): string;

Parameters

None.

Returns

  • string — the group ID string provided by Apps in Toss.

Permission

No permission required — getGroupId is not bound to a PermissionName. For the typical permission flow used by other namespaces, see Guides — Permissions pattern.

Examples

Minimal

import { getGroupId } from '@apps-in-toss/web-framework';

const groupId = getGroupId();
console.log('Group ID:', groupId);

Realistic — include group ID in API request headers

import { getGroupId } from '@apps-in-toss/web-framework';
import { useEffect, useState } from 'react';

function GroupInfoPage() {
const [groupId, setGroupId] = useState('');

useEffect(() => {
const id = getGroupId();
setGroupId(id);
}, []);

async function fetchGroupData() {
const id = getGroupId();
const response = await fetch('/api/group-data', {
headers: {
'X-Group-Id': id,
},
});
return response.json();
}

return (
<div>
<p>Group ID: <code>{groupId || 'Loading...'}</code></p>
<button type="button" onClick={fetchGroupData}>Fetch group data</button>
</div>
);
}

Try it live

Open the Environment page in sdk-example and run the getGroupId card to inspect the result.

Open in sdk-example

External references