Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore(studio): webhook name (#43796)

Danny White611ad867bebf
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.mock.ts b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.mock.ts
index 1a10d55d272..e08791bbef6 100644
--- a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.mock.ts
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.mock.ts
@@ -14,7 +14,7 @@ export const PLATFORM_WEBHOOKS_MOCK_DATA: Record<WebhookScope, PlatformWebhooksM
],
endpoints: [
{
- id: 'org-endpoint-1',
+ id: '7f2c9d4a-6e31-4d9d-9a1f-2c4b5e6f7081',
name: 'Lovable production',
url: 'https://api.lovable.dev/webhooks/supabase',
description: 'Primary organization webhook endpoint',
@@ -28,7 +28,7 @@ export const PLATFORM_WEBHOOKS_MOCK_DATA: Record<WebhookScope, PlatformWebhooksM
createdAt: '2026-02-15T21:30:00.000Z',
},
{
- id: 'org-endpoint-2',
+ id: '1a4e8c73-5b29-44af-8c62-9f1d2b3c4d5e',
name: 'Slack notifications',
url: 'https://hooks.slack.com/services/T000/B000/ORG',
description: 'Operational alerts for organization-level events',
@@ -42,7 +42,7 @@ export const PLATFORM_WEBHOOKS_MOCK_DATA: Record<WebhookScope, PlatformWebhooksM
deliveries: [
{
id: 'org-delivery-1',
- endpointId: 'org-endpoint-1',
+ endpointId: '7f2c9d4a-6e31-4d9d-9a1f-2c4b5e6f7081',
eventType: 'project.created',
status: 'success',
responseCode: 200,
@@ -50,7 +50,7 @@ export const PLATFORM_WEBHOOKS_MOCK_DATA: Record<WebhookScope, PlatformWebhooksM
},
{
id: 'org-delivery-2',
- endpointId: 'org-endpoint-1',
+ endpointId: '7f2c9d4a-6e31-4d9d-9a1f-2c4b5e6f7081',
eventType: 'project.updated',
status: 'failure',
responseCode: 500,
@@ -58,14 +58,14 @@ export const PLATFORM_WEBHOOKS_MOCK_DATA: Record<WebhookScope, PlatformWebhooksM
},
{
id: 'org-delivery-3',
- endpointId: 'org-endpoint-1',
+ endpointId: '7f2c9d4a-6e31-4d9d-9a1f-2c4b5e6f7081',
eventType: 'project.deleted',
status: 'pending',
attemptAt: '2026-02-27T07:45:00.000Z',
},
{
id: 'org-delivery-4',
- endpointId: 'org-endpoint-2',
+ endpointId: '1a4e8c73-5b29-44af-8c62-9f1d2b3c4d5e',
eventType: 'organization.updated',
status: 'skipped',
attemptAt: '2026-02-26T14:12:00.000Z',
@@ -83,7 +83,7 @@ export const PLATFORM_WEBHOOKS_MOCK_DATA: Record<WebhookScope, PlatformWebhooksM
],
endpoints: [
{
- id: 'project-endpoint-1',
+ id: '3c9b7e21-8d54-4f63-b2a1-6e7d8c9f0a12',
name: 'Project analytics',
url: 'https://analytics.example.com/hooks/supabase-project',
description: 'Project-level status updates for analytics pipeline',
@@ -97,7 +97,7 @@ export const PLATFORM_WEBHOOKS_MOCK_DATA: Record<WebhookScope, PlatformWebhooksM
deliveries: [
{
id: 'project-delivery-1',
- endpointId: 'project-endpoint-1',
+ endpointId: '3c9b7e21-8d54-4f63-b2a1-6e7d8c9f0a12',
eventType: 'project.updated',
status: 'success',
responseCode: 200,
@@ -105,7 +105,7 @@ export const PLATFORM_WEBHOOKS_MOCK_DATA: Record<WebhookScope, PlatformWebhooksM
},
{
id: 'project-delivery-2',
- endpointId: 'project-endpoint-1',
+ endpointId: '3c9b7e21-8d54-4f63-b2a1-6e7d8c9f0a12',
eventType: 'project.resource_exhausted',
status: 'failure',
responseCode: 429,
@@ -113,7 +113,7 @@ export const PLATFORM_WEBHOOKS_MOCK_DATA: Record<WebhookScope, PlatformWebhooksM
},
{
id: 'project-delivery-3',
- endpointId: 'project-endpoint-1',
+ endpointId: '3c9b7e21-8d54-4f63-b2a1-6e7d8c9f0a12',
eventType: 'project.paused',
status: 'success',
responseCode: 202,
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.store.test.ts b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.store.test.ts
index 77e38dd6f9b..1f7c05739c8 100644
--- a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.store.test.ts
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.store.test.ts
@@ -2,11 +2,107 @@ import { describe, expect, it } from 'vitest'
import {
createInitialPlatformWebhooksState,
+ createWebhookEndpoint,
filterWebhookDeliveries,
+ filterWebhookEndpoints,
retryWebhookDelivery,
+ updateWebhookEndpoint,
} from './PlatformWebhooks.store'
+import type { PlatformWebhooksState, WebhookEndpoint } from './PlatformWebhooks.types'
+
+const EMPTY_STATE: PlatformWebhooksState = {
+ endpoints: [],
+ deliveries: [],
+}
+
+const createEndpoint = (overrides?: Partial<WebhookEndpoint>): WebhookEndpoint => ({
+ id: '3c9b7e21-8d54-4f63-b2a1-6e7d8c9f0a12',
+ name: 'Billing events',
+ url: 'https://hooks.example.com/billing',
+ description: 'Invoices and receipts',
+ enabled: true,
+ eventTypes: ['project.updated'],
+ customHeaders: [],
+ createdBy: '[email protected]',
+ createdAt: '2026-03-16T00:00:00.000Z',
+ ...overrides,
+})
describe('PlatformWebhooks.store', () => {
+ it('stores an explicit non-empty endpoint name on create', () => {
+ const result = createWebhookEndpoint(
+ EMPTY_STATE,
+ {
+ name: ' Project analytics ',
+ url: 'https://hooks.example.com/analytics',
+ description: '',
+ enabled: true,
+ eventTypes: ['project.updated'],
+ customHeaders: [],
+ },
+ {
+ endpointId: '9e4b1d62-7c35-4f18-a9d1-2b6e7f8c9012',
+ signingSecret: 'whsec_example',
+ }
+ )
+
+ expect(result.endpoint.name).toBe('Project analytics')
+ })
+
+ it('allows an empty endpoint name on create', () => {
+ const result = createWebhookEndpoint(
+ EMPTY_STATE,
+ {
+ name: ' ',
+ url: 'https://hooks.example.com/fallback',
+ description: '',
+ enabled: true,
+ eventTypes: ['project.updated'],
+ customHeaders: [],
+ },
+ {
+ endpointId: '9e4b1d62-7c35-4f18-a9d1-2b6e7f8c9012',
+ signingSecret: 'whsec_example',
+ }
+ )
+
+ expect(result.endpoint.name).toBe('')
+ })
+
+ it('allows clearing an existing endpoint name on update', () => {
+ const state: PlatformWebhooksState = {
+ endpoints: [createEndpoint()],
+ deliveries: [],
+ }
+
+ const result = updateWebhookEndpoint(state, '3c9b7e21-8d54-4f63-b2a1-6e7d8c9f0a12', {
+ name: ' ',
+ url: 'https://hooks.example.com/billing',
+ description: 'Invoices and receipts',
+ enabled: true,
+ eventTypes: ['project.updated'],
+ customHeaders: [],
+ })
+
+ expect(result.endpoints[0].name).toBe('')
+ })
+
+ it('filters endpoints by name, url, and description', () => {
+ const endpoints = [
+ createEndpoint(),
+ createEndpoint({
+ id: '1a4e8c73-5b29-44af-8c62-9f1d2b3c4d5e',
+ name: '',
+ url: 'https://hooks.example.com/slack',
+ description: 'Operational alerts',
+ }),
+ ]
+
+ expect(filterWebhookEndpoints(endpoints, 'billing')).toEqual([endpoints[0]])
+ expect(filterWebhookEndpoints(endpoints, 'slack')).toEqual([endpoints[1]])
+ expect(filterWebhookEndpoints(endpoints, 'alerts')).toEqual([endpoints[1]])
+ })
+
it('retries an individual delivery by resetting it to pending with a new timestamp', () => {
const nextState = retryWebhookDelivery(
createInitialPlatformWebhooksState('project'),
@@ -16,7 +112,7 @@ describe('PlatformWebhooks.store', () => {
expect(nextState.deliveries.find((delivery) => delivery.id === 'project-delivery-2')).toEqual({
id: 'project-delivery-2',
- endpointId: 'project-endpoint-1',
+ endpointId: '3c9b7e21-8d54-4f63-b2a1-6e7d8c9f0a12',
eventType: 'project.resource_exhausted',
status: 'pending',
responseCode: undefined,
@@ -32,7 +128,7 @@ describe('PlatformWebhooks.store', () => {
)
expect(
- filterWebhookDeliveries(nextState.deliveries, 'project-endpoint-1', '').map(
+ filterWebhookDeliveries(nextState.deliveries, '3c9b7e21-8d54-4f63-b2a1-6e7d8c9f0a12', '').map(
(delivery) => delivery.id
)
).toEqual(['project-delivery-2', 'project-delivery-1', 'project-delivery-3'])
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.store.ts b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.store.ts
index 3ec00f9d5c3..95147dd59da 100644
--- a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.store.ts
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.store.ts
@@ -8,6 +8,7 @@ import type {
WebhookEndpoint,
WebhookScope,
} from './PlatformWebhooks.types'
+import { getWebhookEndpointDisplayName } from './PlatformWebhooks.utils'
interface CreateEndpointOptions {
now?: string
@@ -42,6 +43,18 @@ const secureRandomHex = (length: number) => {
}
const randomId = (prefix: string) => `${prefix}-${secureRandomHex(8)}`
+const randomUuid = () => {
+ const cryptoApi = globalThis.crypto
+ if (cryptoApi?.randomUUID) return cryptoApi.randomUUID()
+
+ return [
+ secureRandomHex(8),
+ secureRandomHex(4),
+ `4${secureRandomHex(3)}`,
+ `${((parseInt(secureRandomHex(2), 16) & 0x3f) | 0x80).toString(16)}${secureRandomHex(2)}`,
+ secureRandomHex(12),
+ ].join('-')
+}
const generateSigningSecret = () => `whsec_${secureRandomHex(16)}`
@@ -99,12 +112,11 @@ export const createWebhookEndpoint = (
input: UpsertWebhookEndpointInput,
options?: CreateEndpointOptions
): { state: PlatformWebhooksState; endpoint: WebhookEndpoint; signingSecret: string } => {
- const endpointId = options?.endpointId ?? randomId('endpoint')
- const internalName = input.name.trim().length > 0 ? input.name.trim() : endpointId
+ const endpointId = options?.endpointId ?? randomUuid()
const signingSecret = options?.signingSecret ?? generateSigningSecret()
const endpoint: WebhookEndpoint = {
id: endpointId,
- name: internalName,
+ name: input.name.trim(),
url: input.url.trim(),
description: input.description.trim(),
enabled: input.enabled,
@@ -136,7 +148,7 @@ export const updateWebhookEndpoint = (
endpoint.id === endpointId
? {
...endpoint,
- name: input.name.trim().length > 0 ? input.name.trim() : endpoint.name,
+ name: input.name.trim(),
url: input.url.trim(),
description: input.description.trim(),
enabled: input.enabled,
@@ -214,7 +226,8 @@ export const filterWebhookEndpoints = (endpoints: WebhookEndpoint[], search: str
if (normalizedSearch.length === 0) return endpoints
return endpoints.filter((endpoint) => {
- const haystack = `${endpoint.name} ${endpoint.url} ${endpoint.description}`.toLowerCase()
+ const haystack =
+ `${getWebhookEndpointDisplayName(endpoint)} ${endpoint.url} ${endpoint.description}`.toLowerCase()
return haystack.includes(normalizedSearch)
})
}
@@ -259,7 +272,7 @@ export const usePlatformWebhooksMockStore = (scope: WebhookScope) => {
return {
...state,
createEndpoint: (input: UpsertWebhookEndpointInput) => {
- const endpointId = randomId('endpoint')
+ const endpointId = randomUuid()
const now = new Date().toISOString()
const signingSecret = generateSigningSecret()
const createdBy = '[email protected]'
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.utils.test.ts b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.utils.test.ts
new file mode 100644
index 00000000000..bec11771d10
--- /dev/null
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.utils.test.ts
@@ -0,0 +1,36 @@
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+import {
+ generateWebhookEndpointName,
+ getWebhookEndpointDisplayName,
+} from './PlatformWebhooks.utils'
+
+describe('PlatformWebhooks.utils', () => {
+ afterEach(() => {
+ vi.restoreAllMocks()
+ })
+
+ it('returns the trimmed endpoint name when present', () => {
+ expect(
+ getWebhookEndpointDisplayName({
+ name: ' Billing events ',
+ url: 'https://hooks.example.com/billing',
+ })
+ ).toBe('Billing events')
+ })
+
+ it('falls back to the endpoint url when the name is empty', () => {
+ expect(
+ getWebhookEndpointDisplayName({
+ name: ' ',
+ url: 'https://hooks.example.com/fallback',
+ })
+ ).toBe('https://hooks.example.com/fallback')
+ })
+
+ it('generates an adjective-noun endpoint name', () => {
+ vi.spyOn(Math, 'random').mockReturnValueOnce(0).mockReturnValueOnce(0.1)
+
+ expect(generateWebhookEndpointName()).toBe('swift-courier')
+ })
+})
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.utils.ts b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.utils.ts
new file mode 100644
index 00000000000..6cc989ef063
--- /dev/null
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooks.utils.ts
@@ -0,0 +1,49 @@
+import type { WebhookEndpoint } from './PlatformWebhooks.types'
+
+const WEBHOOK_NAME_ADJECTIVES = [
+ 'swift',
+ 'winged',
+ 'wayfinding',
+ 'moonlit',
+ 'fleet',
+ 'nimble',
+ 'roving',
+ 'brisk',
+ 'gliding',
+ 'steady',
+ 'northbound',
+ 'starlit',
+ 'quiet',
+ 'amber',
+ 'far-flung',
+ 'secret',
+ 'flying',
+]
+
+const WEBHOOK_NAME_NOUNS = [
+ 'pigeon',
+ 'courier',
+ 'postmark',
+ 'relay',
+ 'dispatch',
+ 'lantern',
+ 'beacon',
+ 'messenger',
+ 'waypost',
+ 'sparrow',
+ 'satchel',
+ 'signalfire',
+ 'envelope',
+ 'parcel',
+ 'gull',
+ 'kite',
+ 'beagle',
+]
+
+const getRandomItem = (values: string[]) => values[Math.floor(Math.random() * values.length)]
+
+export const generateWebhookEndpointName = () =>
+ `${getRandomItem(WEBHOOK_NAME_ADJECTIVES)}-${getRandomItem(WEBHOOK_NAME_NOUNS)}`
+
+export const getWebhookEndpointDisplayName = (endpoint: Pick<WebhookEndpoint, 'name' | 'url'>) =>
+ endpoint.name.trim() || endpoint.url
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointDetails.tsx b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointDetails.tsx
index f6df1051bc0..931a13dee6f 100644
--- a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointDetails.tsx
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointDetails.tsx
@@ -50,6 +50,8 @@ export const PlatformWebhooksEndpointDetails = ({
onRetryDelivery,
}: PlatformWebhooksEndpointDetailsProps) => {
const hasCustomHeaders = selectedEndpoint.customHeaders.length > 0
+ const hasName = selectedEndpoint.name.trim().length > 0
+ const hasDescription = selectedEndpoint.description.trim().length > 0
return (
<div className="space-y-16">
@@ -58,11 +60,15 @@ export const PlatformWebhooksEndpointDetails = ({
<Card className="overflow-hidden">
<CardContent className="pb-5">
<dl className="grid grid-cols-1 gap-x-10 gap-y-6 md:grid-cols-2">
+ {hasName && <DetailItem label="Name">{selectedEndpoint.name}</DetailItem>}
+
<DetailItem label="URL" ddClassName="text-sm break-all">
{selectedEndpoint.url}
</DetailItem>
- <DetailItem label="Description">{selectedEndpoint.description || '-'}</DetailItem>
+ {hasDescription && (
+ <DetailItem label="Description">{selectedEndpoint.description}</DetailItem>
+ )}
<DetailItem label="Event types" ddClassName="flex flex-wrap gap-2">
{(selectedEndpoint.eventTypes.includes('*')
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointList.tsx b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointList.tsx
index d08c334a002..720e05b0a7f 100644
--- a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointList.tsx
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointList.tsx
@@ -9,7 +9,6 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
- DropdownMenuSeparator,
DropdownMenuTrigger,
Table,
TableBody,
@@ -23,6 +22,7 @@ import { EmptyStatePresentational, TimestampInfo } from 'ui-patterns'
import { Input } from 'ui-patterns/DataInputs/Input'
import type { WebhookEndpoint } from './PlatformWebhooks.types'
+import { getWebhookEndpointDisplayName } from './PlatformWebhooks.utils'
interface PlatformWebhooksEndpointListProps {
filteredEndpoints: WebhookEndpoint[]
@@ -126,7 +126,7 @@ export const PlatformWebhooksEndpointList = ({
Status
</TableHeadSort>
</TableHead>
- <TableHead>URL</TableHead>
+ <TableHead>Endpoint</TableHead>
<TableHead>Events</TableHead>
<TableHead aria-sort={getAriaSort('created')}>
<TableHeadSort
@@ -141,92 +141,95 @@ export const PlatformWebhooksEndpointList = ({
</TableRow>
</TableHeader>
<TableBody>
- {sortedEndpoints.map((endpoint) => (
- <TableRow
- key={endpoint.id}
- className="relative cursor-pointer inset-focus"
- onClick={createNavigationHandler(
- `${webhooksHref}/${encodeURIComponent(endpoint.id)}`,
- router
- )}
- onAuxClick={createNavigationHandler(
- `${webhooksHref}/${encodeURIComponent(endpoint.id)}`,
- router
- )}
- onKeyDown={createNavigationHandler(
- `${webhooksHref}/${encodeURIComponent(endpoint.id)}`,
- router
- )}
- tabIndex={0}
- >
- <TableCell>
- <Badge variant={endpoint.enabled ? 'success' : 'default'}>
- {endpoint.enabled ? 'Enabled' : 'Disabled'}
- </Badge>
- </TableCell>
- <TableCell className="max-w-[420px]">
- <p className="truncate">{endpoint.url}</p>
- {endpoint.description && (
- <p className="text-xs text-foreground-lighter truncate mt-0.5">
- {endpoint.description}
- </p>
+ {sortedEndpoints.map((endpoint) => {
+ const hasName = endpoint.name.trim().length > 0
+ const displayName = getWebhookEndpointDisplayName(endpoint)
+
+ return (
+ <TableRow
+ key={endpoint.id}
+ className="relative cursor-pointer inset-focus"
+ onClick={createNavigationHandler(
+ `${webhooksHref}/${encodeURIComponent(endpoint.id)}`,
+ router
+ )}
+ onAuxClick={createNavigationHandler(
+ `${webhooksHref}/${encodeURIComponent(endpoint.id)}`,
+ router
+ )}
+ onKeyDown={createNavigationHandler(
+ `${webhooksHref}/${encodeURIComponent(endpoint.id)}`,
+ router
)}
- </TableCell>
- <TableCell className="max-w-[280px] truncate">
- {formatEventCount(endpoint.eventTypes)}
- </TableCell>
- <TableCell>
- <TimestampInfo className="text-sm" utcTimestamp={endpoint.createdAt} />
- <p className="text-xs text-foreground-lighter mt-0.5">
- by {endpoint.createdBy}
- </p>
- </TableCell>
- <TableCell className="text-right">
- <div
- className="flex justify-end items-center h-full gap-3"
- onClick={(event) => event.stopPropagation()}
- onKeyDown={(event) => event.stopPropagation()}
- >
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- type="default"
- icon={<MoreVertical />}
- className="w-7 hit-area-2"
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent side="bottom" align="end" className="w-40">
- <DropdownMenuItem
- className="gap-x-2"
- onClick={() => {
- onViewEndpoint(endpoint.id)
- }}
- >
- <Eye size={14} />
- <span>View details</span>
- </DropdownMenuItem>
-
- <DropdownMenuItem
- className="gap-x-2"
- onClick={() => onDeleteEndpoint(endpoint.id)}
- >
- <Trash2 size={14} />
- <span>Delete</span>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- <ChevronRight
- aria-hidden={true}
- size={14}
- className="text-foreground-muted/60"
- />
- <button tabIndex={-1} className="sr-only">
- Go to endpoint details
- </button>
- </div>
- </TableCell>
- </TableRow>
- ))}
+ tabIndex={0}
+ >
+ <TableCell>
+ <Badge variant={endpoint.enabled ? 'success' : 'default'}>
+ {endpoint.enabled ? 'Enabled' : 'Disabled'}
+ </Badge>
+ </TableCell>
+ <TableCell className="max-w-[420px]">
+ <p className="truncate">{displayName}</p>
+ {hasName && (
+ <p className="text-xs text-foreground-lighter truncate">{endpoint.url}</p>
+ )}
+ </TableCell>
+ <TableCell className="max-w-[280px] truncate">
+ {formatEventCount(endpoint.eventTypes)}
+ </TableCell>
+ <TableCell>
+ <TimestampInfo className="text-sm" utcTimestamp={endpoint.createdAt} />
+ <p className="text-xs text-foreground-lighter mt-0.5">
+ by {endpoint.createdBy}
+ </p>
+ </TableCell>
+ <TableCell className="text-right">
+ <div
+ className="flex justify-end items-center h-full gap-3"
+ onClick={(event) => event.stopPropagation()}
+ onKeyDown={(event) => event.stopPropagation()}
+ >
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="default"
+ icon={<MoreVertical />}
+ className="w-7 hit-area-2"
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent side="bottom" align="end" className="w-40">
+ <DropdownMenuItem
+ className="gap-x-2"
+ onClick={() => {
+ onViewEndpoint(endpoint.id)
+ }}
+ >
+ <Eye size={14} />
+ <span>View details</span>
+ </DropdownMenuItem>
+
+ <DropdownMenuItem
+ className="gap-x-2"
+ onClick={() => onDeleteEndpoint(endpoint.id)}
+ >
+ <Trash2 size={14} />
+ <span>Delete</span>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <ChevronRight
+ aria-hidden={true}
+ size={14}
+ className="text-foreground-muted/60"
+ />
+ <button tabIndex={-1} className="sr-only">
+ Go to endpoint details
+ </button>
+ </div>
+ </TableCell>
+ </TableRow>
+ )
+ })}
</TableBody>
</Table>
</Card>
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointSheet.test.tsx b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointSheet.test.tsx
new file mode 100644
index 00000000000..5a3fbff9b7a
--- /dev/null
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointSheet.test.tsx
@@ -0,0 +1,100 @@
+import { fireEvent, screen, waitFor } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import type { ComponentProps } from 'react'
+import { customRender } from 'tests/lib/custom-render'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+import type { WebhookEndpoint } from './PlatformWebhooks.types'
+import { PlatformWebhooksEndpointSheet } from './PlatformWebhooksEndpointSheet'
+
+const { generateWebhookEndpointNameMock } = vi.hoisted(() => ({
+ generateWebhookEndpointNameMock: vi.fn(() => 'winged-envelope'),
+}))
+
+vi.mock(import('./PlatformWebhooks.utils'), async (importOriginal) => {
+ const actual = await importOriginal()
+ return {
+ ...actual,
+ generateWebhookEndpointName: generateWebhookEndpointNameMock,
+ }
+})
+
+const PROJECT_EVENT_TYPES = ['project.updated', 'project.paused']
+
+const createEndpoint = (overrides?: Partial<WebhookEndpoint>): WebhookEndpoint => ({
+ id: '3c9b7e21-8d54-4f63-b2a1-6e7d8c9f0a12',
+ name: 'Billing events',
+ url: 'https://hooks.example.com/billing',
+ description: 'Invoices and receipts',
+ enabled: true,
+ eventTypes: ['project.updated'],
+ customHeaders: [],
+ createdBy: '[email protected]',
+ createdAt: '2026-03-16T00:00:00.000Z',
+ ...overrides,
+})
+
+const renderEndpointSheet = (
+ props?: Partial<ComponentProps<typeof PlatformWebhooksEndpointSheet>>
+) => {
+ const onClose = vi.fn()
+ const onSubmit = vi.fn()
+
+ customRender(
+ <PlatformWebhooksEndpointSheet
+ visible
+ mode="create"
+ scope="project"
+ eventTypes={PROJECT_EVENT_TYPES}
+ onClose={onClose}
+ onSubmit={onSubmit}
+ {...props}
+ />
+ )
+
+ return { onClose, onSubmit }
+}
+
+describe('PlatformWebhooksEndpointSheet', () => {
+ afterEach(() => {
+ vi.clearAllMocks()
+ })
+
+ it('prefills the name field when creating an endpoint', async () => {
+ renderEndpointSheet()
+
+ expect(await screen.findByDisplayValue('winged-envelope')).toBeInTheDocument()
+ })
+
+ it('loads the existing name and description in edit mode', async () => {
+ renderEndpointSheet({
+ mode: 'edit',
+ endpoint: createEndpoint(),
+ })
+
+ expect(await screen.findByDisplayValue('Billing events')).toBeInTheDocument()
+ expect(screen.getByDisplayValue('Invoices and receipts')).toBeInTheDocument()
+ })
+
+ it('submits an empty name when an existing name is cleared', async () => {
+ const user = userEvent.setup()
+ const { onSubmit } = renderEndpointSheet({
+ mode: 'edit',
+ endpoint: createEndpoint(),
+ })
+
+ const nameInput = await screen.findByDisplayValue('Billing events')
+ await user.clear(nameInput)
+ fireEvent.submit(document.getElementById('platform-webhook-endpoint-form')!)
+
+ await waitFor(() => expect(onSubmit).toHaveBeenCalledTimes(1))
+ expect(onSubmit).toHaveBeenCalledWith(
+ expect.objectContaining({
+ name: '',
+ url: 'https://hooks.example.com/billing',
+ description: 'Invoices and receipts',
+ }),
+ expect.anything()
+ )
+ })
+})
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointSheet.tsx b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointSheet.tsx
index 42bd837657f..db3bfd83430 100644
--- a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointSheet.tsx
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksEndpointSheet.tsx
@@ -1,6 +1,6 @@
import { zodResolver } from '@hookform/resolvers/zod'
-import { InlineLink } from 'components/ui/InlineLink'
import { DiscardChangesConfirmationDialog } from 'components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'
+import { InlineLink } from 'components/ui/InlineLink'
import { useConfirmOnClose } from 'hooks/ui/useConfirmOnClose'
import { ChevronDown, Trash2 } from 'lucide-react'
import { useEffect, useMemo, useState } from 'react'
@@ -21,6 +21,7 @@ import {
Separator,
Sheet,
SheetContent,
+ SheetDescription,
SheetFooter,
SheetHeader,
SheetSection,
@@ -36,9 +37,11 @@ import type {
WebhookEndpoint,
WebhookScope,
} from './PlatformWebhooks.types'
+import { generateWebhookEndpointName } from './PlatformWebhooks.utils'
const endpointFormSchema = z
.object({
+ name: z.string().trim().max(64, 'Name cannot exceed 64 characters'),
url: z.string().trim().url('Please enter a valid URL'),
description: z.string().trim().max(512, 'Description cannot exceed 512 characters'),
enabled: z.boolean().default(true),
@@ -110,7 +113,7 @@ const toControlId = (prefix: string, value: string) =>
`${prefix}-${value.replace(/[^a-zA-Z0-9_-]/g, '-')}`
export const toEndpointPayload = (values: EndpointFormValues): UpsertWebhookEndpointInput => ({
- name: '',
+ name: values.name,
url: values.url,
description: values.description,
enabled: values.enabled,
@@ -144,6 +147,7 @@ export const PlatformWebhooksEndpointSheet = ({
const form = useForm<EndpointFormValues>({
resolver: zodResolver(endpointFormSchema),
defaultValues: {
+ name: generateWebhookEndpointName(),
url: '',
description: '',
enabled: true,
@@ -180,6 +184,7 @@ export const PlatformWebhooksEndpointSheet = ({
if (!endpoint) {
form.reset({
+ name: generateWebhookEndpointName(),
url: '',
description: '',
enabled: true,
@@ -191,6 +196,7 @@ export const PlatformWebhooksEndpointSheet = ({
}
form.reset({
+ name: endpoint.name,
url: endpoint.url,
description: endpoint.description,
enabled: enabledOverride ?? endpoint.enabled,
@@ -227,6 +233,11 @@ export const PlatformWebhooksEndpointSheet = ({
<SheetContent showClose={false} size="default" className="flex flex-col gap-0">
<SheetHeader>
<SheetTitle>{mode === 'create' ? 'Create endpoint' : 'Edit endpoint'}</SheetTitle>
+ <SheetDescription className="sr-only">
+ {mode === 'create'
+ ? 'Create a webhook endpoint by setting a name, URL, and event subscriptions.'
+ : 'Edit this webhook endpoint name, URL, and event subscriptions.'}
+ </SheetDescription>
</SheetHeader>
<Separator />
<SheetSection className="overflow-auto flex-grow px-0 py-0">
@@ -237,6 +248,27 @@ export const PlatformWebhooksEndpointSheet = ({
onSubmit={form.handleSubmit(onSubmit)}
>
<div className="px-5 space-y-5">
+ <FormField_Shadcn_
+ control={form.control}
+ name="name"
+ render={({ field }) => (
+ <FormItemLayout
+ label={
+ <>
+ Name
+ {/* Technically optional but encourage, so no (optional) label */}
+ </>
+ }
+ layout="vertical"
+ className="gap-1"
+ >
+ <FormControl_Shadcn_>
+ <InputField {...field} placeholder="winged-envelope" maxLength={64} />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+
<FormField_Shadcn_
control={form.control}
name="url"
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksHeader.tsx b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksHeader.tsx
index 6b34ea2bbc4..1e1d08101d9 100644
--- a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksHeader.tsx
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksHeader.tsx
@@ -1,7 +1,6 @@
+import { DocsButton } from 'components/ui/DocsButton'
import Link from 'next/link'
import { ReactNode } from 'react'
-
-import { DocsButton } from 'components/ui/DocsButton'
import {
Badge,
BreadcrumbItem_Shadcn_ as BreadcrumbItem,
@@ -58,12 +57,15 @@ export const PlatformWebhooksHeader = ({
</PageHeaderBreadcrumb>
)}
<PageHeaderMeta>
- <PageHeaderSummary>
- <PageHeaderTitle>
- <span className="inline-flex items-center gap-2">
- <span>{headerTitle}</span>
+ <PageHeaderSummary className="min-w-0">
+ <PageHeaderTitle className="min-w-0 w-full">
+ <span className="flex w-full min-w-0 items-center gap-2">
+ <span className="block min-w-0 truncate leading-tight">{headerTitle}</span>
{hasSelectedEndpoint && endpointStatus && (
- <Badge variant={endpointStatus === 'enabled' ? 'success' : 'default'}>
+ <Badge
+ className="shrink-0 self-center"
+ variant={endpointStatus === 'enabled' ? 'success' : 'default'}
+ >
{endpointStatus === 'enabled' ? 'Enabled' : 'Disabled'}
</Badge>
)}
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksPage.tsx b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksPage.tsx
index f4c6ce6b38b..513f2340c7c 100644
--- a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksPage.tsx
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksPage.tsx
@@ -1,14 +1,12 @@
+import { useParams } from 'common'
+import { useIsPlatformWebhooksEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { InlineLink } from 'components/ui/InlineLink'
+import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
+import { EllipsisVertical, Pencil, RotateCw, Trash2 } from 'lucide-react'
import { useRouter } from 'next/router'
import { parseAsString, parseAsStringLiteral, useQueryState } from 'nuqs'
import { useEffect, useMemo, useState } from 'react'
import { toast } from 'sonner'
-import { EllipsisVertical, Pencil, RotateCw, Trash2 } from 'lucide-react'
-
-import { useParams } from 'common'
-import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
-import { InlineLink } from 'components/ui/InlineLink'
-import { Admonition } from 'ui-patterns'
-import { useIsPlatformWebhooksEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import {
AlertDialog,
AlertDialogAction,
@@ -19,17 +17,26 @@ import {
AlertDialogHeader,
AlertDialogTitle,
Button,
+ copyToClipboard,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
Label_Shadcn_,
- copyToClipboard,
} from 'ui'
+import { Admonition } from 'ui-patterns'
+import { Input } from 'ui-patterns/DataInputs/Input'
import { PageContainer } from 'ui-patterns/PageContainer'
import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
-import { Input } from 'ui-patterns/DataInputs/Input'
+
import { PLATFORM_WEBHOOKS_MOCK_DATA } from './PlatformWebhooks.mock'
+import {
+ filterWebhookDeliveries,
+ filterWebhookEndpoints,
+ usePlatformWebhooksMockStore,
+} from './PlatformWebhooks.store'
+import type { WebhookScope } from './PlatformWebhooks.types'
+import { getWebhookEndpointDisplayName } from './PlatformWebhooks.utils'
import { PlatformWebhooksDeliveryDetailsSheet } from './PlatformWebhooksDeliveryDetailsSheet'
import { PlatformWebhooksEndpointDetails } from './PlatformWebhooksEndpointDetails'
import { PlatformWebhooksEndpointList } from './PlatformWebhooksEndpointList'
@@ -38,19 +45,13 @@ import {
PlatformWebhooksEndpointSheet,
toEndpointPayload,
} from './PlatformWebhooksEndpointSheet'
+import { PlatformWebhooksHeader } from './PlatformWebhooksHeader'
import {
clearPendingSigningSecretReveal,
getPendingSigningSecretReveal,
setPendingSigningSecretReveal,
shouldHandleEndpointNotFound,
} from './PlatformWebhooksPage.utils'
-import { PlatformWebhooksHeader } from './PlatformWebhooksHeader'
-import {
- filterWebhookDeliveries,
- filterWebhookEndpoints,
- usePlatformWebhooksMockStore,
-} from './PlatformWebhooks.store'
-import type { WebhookScope } from './PlatformWebhooks.types'
const PANEL_VALUES = ['create', 'edit'] as const
@@ -112,13 +113,24 @@ export const PlatformWebhooksPage = ({ scope, endpointId }: PlatformWebhooksPage
[endpoints, endpointId]
)
const isEndpointView = !!selectedEndpoint
- const headerTitle = isEndpointView ? 'Endpoint' : scopeLabel
- const headerDescription = isEndpointView ? (selectedEndpoint?.url ?? '') : scopeDescription
+ const selectedEndpointHasName = selectedEndpoint ? selectedEndpoint.name.trim().length > 0 : false
+ const selectedEndpointDisplayName = selectedEndpoint
+ ? getWebhookEndpointDisplayName(selectedEndpoint)
+ : ''
+ const headerTitle = isEndpointView ? selectedEndpointDisplayName : scopeLabel
+ const headerDescription = isEndpointView
+ ? selectedEndpointHasName
+ ? (selectedEndpoint?.url ?? '')
+ : ''
+ : scopeDescription
const endpointPendingDelete = useMemo(
() => endpoints.find((endpoint) => endpoint.id === endpointIdPendingDelete) ?? null,
[endpoints, endpointIdPendingDelete]
)
+ const endpointPendingDeleteDisplayName = endpointPendingDelete
+ ? getWebhookEndpointDisplayName(endpointPendingDelete)
+ : ''
useEffect(() => {
if (!platformWebhooksEnabled) {
@@ -221,7 +233,7 @@ export const PlatformWebhooksPage = ({ scope, endpointId }: PlatformWebhooksPage
setDeliverySearch('')
}
setEndpointIdPendingDelete(null)
- toast.success(`Deleted endpoint "${endpointPendingDelete.url}"`)
+ toast.success(`Deleted endpoint "${endpointPendingDeleteDisplayName}"`)
}
const handleUpsertEndpoint = (values: EndpointFormValues) => {
@@ -410,7 +422,9 @@ export const PlatformWebhooksPage = ({ scope, endpointId }: PlatformWebhooksPage
<AlertDialogTitle>Delete endpoint</AlertDialogTitle>
<AlertDialogDescription>
{endpointPendingDelete
- ? `This will delete endpoint ${endpointPendingDelete.url}. This action cannot be undone.`
+ ? endpointPendingDelete.name.trim().length > 0
+ ? `This will delete endpoint "${endpointPendingDeleteDisplayName}" with URL ${endpointPendingDelete.url}. This action cannot be undone.`
+ : `This will delete endpoint ${endpointPendingDelete.url}. This action cannot be undone.`
: 'This action cannot be undone.'}
</AlertDialogDescription>
</AlertDialogHeader>
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksPage.utils.test.ts b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksPage.utils.test.ts
index acdf48259f9..52e8c831aee 100644
--- a/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksPage.utils.test.ts
+++ b/apps/studio/components/interfaces/Platform/Webhooks/PlatformWebhooksPage.utils.test.ts
@@ -9,6 +9,10 @@ import {
} from './PlatformWebhooksPage.utils'
describe('PlatformWebhooksPage.utils', () => {
+ const endpointId = '7f2c9d4a-6e31-4d9d-9a1f-2c4b5e6f7081'
+ const otherEndpointId = '1a4e8c73-5b29-44af-8c62-9f1d2b3c4d5e'
+ const missingEndpointId = '00000000-0000-4000-8000-000000000000'
+
beforeEach(() => {
resetPendingSigningSecretRevealForTests()
})
@@ -26,7 +30,7 @@ describe('PlatformWebhooksPage.utils', () => {
it('returns false when endpoint is selected', () => {
expect(
shouldHandleEndpointNotFound({
- endpointId: 'endpoint-abc12345',
+ endpointId,
hasSelectedEndpoint: true,
pendingCreatedEndpointId: null,
})
@@ -36,9 +40,9 @@ describe('PlatformWebhooksPage.utils', () => {
it('returns false while route is transitioning to a newly created endpoint', () => {
expect(
shouldHandleEndpointNotFound({
- endpointId: 'endpoint-abc12345',
+ endpointId,
hasSelectedEndpoint: false,
- pendingCreatedEndpointId: 'endpoint-abc12345',
+ pendingCreatedEndpointId: endpointId,
})
).toBe(false)
})
@@ -46,7 +50,7 @@ describe('PlatformWebhooksPage.utils', () => {
it('returns true for invalid endpoint routes', () => {
expect(
shouldHandleEndpointNotFound({
- endpointId: 'endpoint-missing',
+ endpointId: missingEndpointId,
hasSelectedEndpoint: false,
pendingCreatedEndpointId: null,
})
@@ -55,33 +59,33 @@ describe('PlatformWebhooksPage.utils', () => {
it('stores and reads pending signing secret reveal for matching endpoint route', () => {
setPendingSigningSecretReveal('project', {
- endpointId: 'endpoint-abc12345',
+ endpointId,
signingSecret: 'whsec_example',
})
- expect(getPendingSigningSecretReveal('project', 'endpoint-abc12345')).toEqual({
- endpointId: 'endpoint-abc12345',
+ expect(getPendingSigningSecretReveal('project', endpointId)).toEqual({
+ endpointId,
signingSecret: 'whsec_example',
})
})
it('ignores pending signing secret reveal when endpoint route does not match', () => {
setPendingSigningSecretReveal('project', {
- endpointId: 'endpoint-abc12345',
+ endpointId,
signingSecret: 'whsec_example',
})
- expect(getPendingSigningSecretReveal('project', 'endpoint-other')).toBeNull()
+ expect(getPendingSigningSecretReveal('project', otherEndpointId)).toBeNull()
})
it('clears pending signing secret reveal', () => {
setPendingSigningSecretReveal('project', {
- endpointId: 'endpoint-abc12345',
+ endpointId,
signingSecret: 'whsec_example',
})
clearPendingSigningSecretReveal('project')
- expect(getPendingSigningSecretReveal('project', 'endpoint-abc12345')).toBeNull()
+ expect(getPendingSigningSecretReveal('project', endpointId)).toBeNull()
})
})
diff --git a/apps/studio/components/interfaces/Platform/Webhooks/index.ts b/apps/studio/components/interfaces/Platform/Webhooks/index.ts
index ad1afa63c1d..bd9de77af43 100644
--- a/apps/studio/components/interfaces/Platform/Webhooks/index.ts
+++ b/apps/studio/components/interfaces/Platform/Webhooks/index.ts
@@ -1,5 +1,9 @@
export { PlatformWebhooksPage } from './PlatformWebhooksPage'
export { usePlatformWebhooksMockStore } from './PlatformWebhooks.store'
+export {
+ generateWebhookEndpointName,
+ getWebhookEndpointDisplayName,
+} from './PlatformWebhooks.utils'
export type {
PlatformWebhooksState,
UpsertWebhookEndpointInput,