# Slack Shared

> Common Slack types: user and channel identification.

- Name: `slack-shared`
- Categories: slack
- Detail page: https://open-types.dev/types/slack-shared

## Install

```bash
# Types only
npx shadcn add @open-types/slack-shared

# Types + Zod v4 validators
npx shadcn add @open-types/slack-shared-zod

# Types + real-world examples
npx shadcn add @open-types/slack-shared-examples
```

## Types

```typescript
export interface SlackUser {
  id: string;
  team_id: string;
  name: string;
  real_name?: string;
}

export interface SlackChannel {
  id: string;
  name: string;
  is_channel: boolean;
  is_group: boolean;
  is_im: boolean;
}
```

## Zod validator

```typescript
import * as z from "zod";
import type { SlackUser, SlackChannel } from "../types/slack-shared";

export const slackUserSchema = z.object({
  id: z.string(),
  team_id: z.string(),
  name: z.string(),
  real_name: z.string().optional(),
}) satisfies z.ZodType<SlackUser>;

export const slackChannelSchema = z.object({
  id: z.string(),
  name: z.string(),
  is_channel: z.boolean(),
  is_group: z.boolean(),
  is_im: z.boolean(),
}) satisfies z.ZodType<SlackChannel>;

export type { SlackUser, SlackChannel } from "../types/slack-shared";
```

## Examples

```typescript
// Source: https://api.slack.com/types/user, https://api.slack.com/types/channel
// Captured: 2026-05
import type { SlackUser, SlackChannel } from "../types/slack-shared";
import {
  slackIds,
  slackUserMarco,
  slackChannelEngineering,
} from "./shared/slack.examples";

export const slackUserExamples = {
  withRealName: slackUserMarco,
  noRealName: {
    id: "U87654321",
    team_id: slackIds.team,
    name: "alex",
  } satisfies SlackUser,
} as const;

export const slackChannelExamples = {
  publicChannel: slackChannelEngineering,
  dm: {
    id: slackIds.channelDm,
    name: "directmessage",
    is_channel: false,
    is_group: false,
    is_im: true,
  } satisfies SlackChannel,
  privateGroup: {
    id: slackIds.channelPrivate,
    name: "leadership",
    is_channel: false,
    is_group: true,
    is_im: false,
  } satisfies SlackChannel,
} as const;
```
