Entity api_key
A secret used by integrations to call the API.
Subject areas: Auth
Attributes
| # | Name | Type | Null | Default | Key | Terms | Description |
| 1 | id | bigint | no | | PK | | |
| 2 | tenant_id | domain tenant_ref (bigint) | yes | | FK | | |
| 3 | name | text(100) | no | | | | |
| 4 | key_hash | binary(32) | no | | UQ | | |
| 5 | created_by | bigint | yes | | FK | | |
| 6 | revoked_at | timestamptz | yes | | | | |
Keys
| Kind | Name | Attributes |
| primary | pk_api_key | id |
| unique | uq_api_key_hash | key_hash |
Relationships
| Name | Role | Other entity | Cardinality | Attributes | Identifying | On delete | On update |
| api_key_created_by | child | user | zero_or_one to many | api_key.created_by -> user.id | no | set_null | no_action |
| api_key_tenant | child | tenant | one to many | api_key.tenant_id -> tenant.id | no | cascade | no_action |
Physical
lite (sqlite): main.api_key
| # | Name | Type | Null | Default | Identity | Collation | Attribute | Comment |
| 1 | id | integer | no | | by_default | | id | |
| 2 | tenant_id | integer | no | | | | tenant_id | |
| 3 | name | text | no | | | | name | |
| 4 | key_hash | blob | no | | | | key_hash | |
| 5 | created_by | integer | yes | | | | created_by | |
| 6 | revoked_at | text | yes | | | | revoked_at | |
- primary key pk_api_key (id)
- unique uq_api_key_hash (key_hash)
- foreign key fk_api_key_created_by (created_by) references user (id) on delete set_null
- foreign key fk_api_key_tenant (tenant_id) references tenant (id) on delete cascade
- index ix_api_key_created_by (created_by)
- index ix_api_key_tenant (tenant_id)
pg (postgresql): app.api_key
| # | Name | Type | Null | Default | Identity | Collation | Attribute | Comment |
| 1 | id | bigint | no | | always | | id | |
| 2 | tenant_id | bigint | no | | | | tenant_id | |
| 3 | name | varchar(100) | no | | | | name | |
| 4 | key_hash | bytea | no | | | | key_hash | |
| 5 | created_by | bigint | yes | | | | created_by | |
| 6 | revoked_at | timestamp with time zone | yes | | | | revoked_at | |
- primary key pk_api_key (id)
- unique uq_api_key_hash (key_hash)
- foreign key fk_api_key_created_by (created_by) references user (id) on delete set_null
- foreign key fk_api_key_tenant (tenant_id) references tenant (id) on delete cascade
- index ix_api_key_created_by (created_by)
- index ix_api_key_tenant (tenant_id)