# Examples
Source: https://docs.aden.space/docs/developers/sdk/examples

Real-world patterns for common integrations.
## Post-release automation [#post-release-automation]

After CI uploads a master to your storage, mark the track as released and
notify the team chat.

```ts title="scripts/release.ts"
import { createAdenClient } from '@adenspace/sdk'

const aden = createAdenClient({ apiKey: process.env.ADEN_API_KEY })

const trackId = Number(process.env.TRACK_ID)

const { data: track, error } = await aden.api.v1
    .tracks({ id: trackId })
    .patch({ status: 'released' })

if (error) throw error

console.log(`Released: ${track.title}`)
```

## Sync tracks into a dashboard [#sync-tracks-into-a-dashboard]

Fetch the team's tracks, transform them, and push into an internal tool.

```ts
const { data: tracks } = await aden.api.v1.tracks.get({
    query: { limit: 100 },
})

const rows = (tracks ?? []).map((track) => ({
    id: track.id,
    title: track.title,
    status: track.status,
    cover: track.cover_url_medium ?? track.cover_url,
    updated: track.updated_at,
}))

await pushToDashboard(rows)
```

## Mirror a team into Notion [#mirror-a-team-into-notion]

```ts
const { data: team } = await aden.api.v1.teams({ id: 123 }).get()
const { data: contacts } = await aden.api.v1.contacts.get({
    query: { teamId: 123 },
})

await notion.databases.update({
    database_id: NOTION_DB,
    title: [{ text: { content: team?.name ?? 'Unknown' } }],
})

for (const contact of contacts ?? []) {
    await notion.pages.create({
        parent: { database_id: NOTION_DB },
        properties: {
            Name: { title: [{ text: { content: contact.name } }] },
            Role: { select: { name: contact.role ?? 'collaborator' } },
        },
    })
}
```

## Post a chat message from a webhook [#post-a-chat-message-from-a-webhook]

Perfect for CI failures, masters-ready notifications, or dropping external
events into a team thread.

```ts title="app/api/webhooks/ci/route.ts"
import { aden } from '@/lib/aden'

export async function POST(req: Request) {
    const body = await req.json()

    await aden.api.v1.chat.messages.post({
        threadId: CI_THREAD_ID,
        content: `Build ${body.status} for ${body.sha.slice(0, 7)}`,
    })

    return new Response('ok')
}
```

## Electron desktop app [#electron-desktop-app]

The Aden desktop app uses the SDK exactly like a browser client. Pass the
Supabase session token from the renderer:

```ts title="apps/desktop/main/aden.ts"
import { createAdenClient } from '@adenspace/sdk'

export const aden = createAdenClient({
    baseUrl: 'https://www.aden.space',
    getToken: async () => getSessionFromRenderer(),
})
```

## Raycast extension [#raycast-extension]

```ts title="src/search-tracks.tsx"
import { createAdenClient } from '@adenspace/sdk'
import { getPreferenceValues } from '@raycast/api'

const { apiKey } = getPreferenceValues<{ apiKey: string }>()
const aden = createAdenClient({ apiKey })

export default async function Command() {
    const { data } = await aden.api.v1.tracks.get({ query: { limit: 25 } })
    // Render results in Raycast UI…
}
```

## Polling with `useApiReachable` [#polling-with-useapireachable]

See [React hooks](/docs/developers/sdk/react) for client-side reachability detection.