DocsDataData ModelOrganization

Represent an organization that owns and manage healthcare facilities.

Schema

Property NameTypeRequired
namestringYES
slugstringYES
logostringNO
statusCodedConceptYES
metadata.descriptionstringNO
settings_idstringYES

Auto-generated by better-auth

Property NameTypeNative Type (PostgreSQL)
idstringtext
created_atstringtimestampz

Example

JSON

{
  "id": "123",
  "name": "Medika Jaya Grup",
  "slug": "medika-jaya-grup",
  "logo": "https://image.url.com",
  "status": {
    "system": "crn:status:system",
    "value": "active",
    "display": "Active"
  },
  "metadata": {
    "description": "Grup pemberi layanan kesehatan nomor satu."
  },
  "settings_id": "123",
  "created_at": "2026-10-02 21:27:00+07"
}

Important Notes

Additional Field

Better Auth Organization plugin core schema only consist of id, name, slug, logo, metadata, createdAt. The other property defined above are additional field you must add in your better auth configuration like below

const auth = betterAuth({
  plugins: [
    organization({
      schema: {
        organization: {
          additionalFields: {
            status: {
              type: "string",
              required: true,
              defaultValue: JSON.stringify({
                system: "crn:status:system",
                value: "active",
                display: "Active",
              }),
              input: true,
            },
            settings_id: {
              type: "string",
              required: true,
              input: false,
            },
          },
        },
      },
    }),
  ],
});

Read here to learn more on how to extend better auth core schema.

Case Style

Better Auth uses camelCase by default. To keep your database schema consistent in snake_case, add the following configuration:

const auth = betterAuth({
  plugins: [
    organization({
      schema: {
        organization: {
          fields: {
            createdAt: "created_at",
          },
        },
      },
    }),
  ],
});

Info

Type inference in your code will still use the original field names (e.g., organization.createdAt, not organization.created_at).

Built with LogoFlowershow