Org Plugin – Why client headers needed?

Hey, I’m checking out the organization plugin right now.
Why do I need to pass the client headers to the server function?
https://www.better-auth.com/docs/plugins/organization

For example, when creating an organization.
const metadata = { someKey: "someValue" };

const data = await auth.api.createOrganization({
    body: {
        name: "My Organization", // required
        slug: "my-org", // required
        logo: "https://example.com/logo.png",
        metadata,
        userId: "some_user_id", // server-only
        keepCurrentActiveOrganization: false,
    },
    // This endpoint requires session cookies.
    headers: await headers(),
});

For example: what if I want to create an organization through my own API endpoint,
using an API token that isn’t tied to a real user or Better Auth at all?
The organization plugin allows you to manage your organization's members and teams.
Was this page helpful?