# Create

Creating a channel will only succeed for a Sui address that has [an associated Sage user.](/user/create.md)

## Create a new Sage channel

```tsx
import { useSignAndExecuteTransaction } from '@mysten/dapp-kit';
import { useChannel } from '@sage-app/sdk/react';

interface ChannelCreateInput {
  amounts: number[];           // payment amounts set to [0, 0]
  avatarHash?: string;
  bannerHash?: string;
  channelName: string;
  description: string;
  self: string;                // user's wallet address
  soulId: string;              // address of user's owned soul
}

...

const { mutateAsync: signAndExecuteTransaction } = useSignAndExecuteTransaction();
const { create } = useChannel();

...

const createChannel = async (data: ChannelCreateInput) => {
  const { ok, err, transaction } = await create(data);
    
  const { digest } = await signAndExecuteTransaction({
    transaction
  });
};
```

## Error Codes

**Authentication** module

<table><thead><tr><th width="104">Code</th><th width="221">Value</th><th>Meaning</th></tr></thead><tbody><tr><td>370</td><td>ENotAuthenticated</td><td>User soul object does not exist, is the wrong type, or not owned by the wallet.</td></tr></tbody></table>

**Channel** module

<table><thead><tr><th width="104">Code</th><th width="230.673095703125">Value</th><th>Meaning</th></tr></thead><tbody><tr><td>370</td><td>EInvalidChannelDescription</td><td>Description must be less than 370 characters.</td></tr><tr><td>371</td><td>EInvalidChannelName</td><td>Name must be a-z, A-Z, 0-9, dash (NOT in beginning or end), and between 3 - 21 characters.</td></tr></tbody></table>

**Channel Fees** module

<table><thead><tr><th width="106">Code</th><th width="231.63067626953125">Value</th><th>Meaning</th></tr></thead><tbody><tr><td>370</td><td>EIncorrectCoinType</td><td>Custom payment type does not match configured custom payment coin.</td></tr><tr><td>371</td><td>EIncorrectCustomPayment</td><td>Incorrect custom payment value.</td></tr><tr><td>372</td><td>EIncorrectSuiPayment</td><td>Incorrect sui payment value.</td></tr></tbody></table>

## Querying for New Channel Events

```typescript
import { EventId, SuiClient, getFullnodeUrl } from '@mysten/sui/client';
import { SageClient } from '@sage-app/sdk/client';

...

interface QueryInput {
  cursor?: EventId;
}

const appId = '<YOUR_APP_ID>';
const network = 'mainnet' | 'testnet';
const suiClient = new SuiClient({ url: getFullnodeUrl(network) });

const sageClient = new SageClient({ appId, network, suiClient });

...

const pollNewChannels = async ({ cursor }) => {
  const {
    eventCount,
    events,
    hasNextPage,
    nextCursor
  } = await sageClient.queryChannelCreateEvents({ cursor }: QueryInput);
  
  // do something with events
  
  setTimeout(() => pollNewChannels({ cursor: nextCursor }), 5000);
};
```

In this case events will take the shape of an array of ChannelCreateEvent:

```typescript
interface ChannelCreateEvent {
  id: string;              // channel object address
  avatarHash: string;
  bannerHash: string;
  channelKey: string;      // <= e.g. "sui-play" (unique value, always lowercase)
  channelName: string;     // <= e.g. "sui-PLAY" (display name)
  createdAt: string;
  createdBy: string;       // user's wallet address
  description: string;
}  
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sdk.sageapp.xyz/channel/create.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
