Examples of listing published bots in a workspace.
This example assumes using Coze; is in scope and apiKey contains your Coze API key.
1 2 3 4 5 6 7 8 910111213141516171819202122232425
// To list bots, you need a workspace (space) ID. You can find your workspace ID// in the Coze dashboard URL when viewing your workspace.varworkspaceId=Environment.GetEnvironmentVariable("COZE_WORKSPACE_ID")is{Length:>0}value?value:thrownewAssertInconclusiveException("COZE_WORKSPACE_ID environment variable is not found.");usingvarclient=newCozeClient(apiKey);// List published bots in the workspace using `GetSpacePublishedBotsListAsync`.// This returns bots that have been published and are available for use.varresponse=awaitclient.GetSpacePublishedBotsListAsync(spaceId:workspaceId,pageSize:10);// The response contains a `Code` field (0 means success) and a `Data` field// with the list of bots and total count.// Each bot in the list has a `BotId`, `BotName`, and optional `Description`.if(response.Data.SpaceBotsis{Count:>0}bots){varfirstBot=bots[0];Console.WriteLine($"First bot: {firstBot.BotName} (ID: {firstBot.BotId})");}